Simple EKS Cluster

This example will deploy a simple EKS cluster with existing tile

simple eks architecture

Prerequisites

Steps

  1. Make sure your aws cli is well configured, you will see something like below

    $ aws configure list
        Name                    Value             Type    Location
        ----                    -----             ----    --------
    profile                <not set>             None    None
    access_key     ****************XAWA shared-credentials-file
    secret_key     ****************qEK5 shared-credentials-file
        region                us-east-2      config-file    ~/.aws/config
    
  2. Lanuch dice daemon if not existing:

    $ docker run -d -v ~/.aws:/root/.aws -p 9090:9090 docker.pkg.github.com/awslabs/aws-solutions-assembler/dice:latest
    
  3. Create a YAML config file named as simple-eks.yaml

    apiVersion: mahjong.io/v1alpha1
    kind: Deployment
    metadata:
      name: eks-simple
      version: 0.1.0
    spec:
      template:
        tiles:
          tileEks0005:
            tileReference: Eks0
            tileVersion: 0.0.5
            inputs:
              - name: clusterName
                inputValue: mahjong-cluster101
              - name: capacity
                inputValue: 3
              - name: capacityInstance
                inputValue: m5.large
              - name: version
                inputValue: 1.16
      summary:
        description:
        outputs:
          - name: EKS Cluster Name
            value: $(tileEks0005.outputs.clusterName)
          - name: Master role arn for EKS Cluster
            value: $(tileEks0005.outputs.masterRoleARN)
          - name: The API endpoint EKS Cluster
            value: $(tileEks0005.outputs.clusterEndpoint)
          - name: Instance type of worker node
            value: $(tileEks0005.outputs.capacityInstance)
          - name: Default capacity of worker node
            value: $(tileEks0005.outputs.capacity)
    
        notes: []
    
  4. Bootstrap CDK: cdk bootstrap aws://<your aws account>/<aws region>. For example:

    cdk bootstrap aws://638198787577/us-east-2
    

    This step only need to process once

  5. Deploy to AWS: mctl deploy -f ./simple-eks.yaml. If everything works fine you will get this:

    $ mctl deploy -f ./simple-eks.yaml
    
    ...
    
    []  EKS Cluster Name = mahjong-cluster101
    []  Master role arn for EKS Cluster = arn:aws:iam::638198787577:role/Eks0StacktileEks0005-Eks0EksClusterMasterRole76926-D9OV6NASDYGC
    []  The API endpoint EKS Cluster = https://8F4AEE06CDA95AA5B9B82016B406F53B.gr7.us-east-2.eks.amazonaws.com
    []  Instance type of worker node = m5.large
    []  Default capacity of worker node = 3
    
  6. Once you finished the previous step, you can check your cluster mahjong-cluster101

    1. Find your master role arn for eks cluster.

      For example:

      arn:aws:iam::638198787577:role/Eks0StacktileEks0005-Eks0EksClusterMasterRole76926-D9OV6NASDYGC
      
    2. Create kubernetes config by aws --region <region-code> eks update-kubeconfig --name <cluster_name> --role-arn arn:aws:iam::<aws_account_id>:role/<role_name>.

      For example:

      aws --region us-east-2 eks update-kubeconfig--name mahjong-cluster101 --role-arn arn:aws:iam::638198787577:role/Eks0StacktileEks0005-Eks0EksClusterMasterRole76926-D9OV6NASDYGC
      
    3. Test your kubernetes cluster

      $ kubectl get svc
      NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
      kubernetes   ClusterIP   172.20.0.1   <none>        443/TCP   4h41m
      

      Make sure you have kubernetes-cli installed to be able to use kubectl