How To Setup or Deploy a Kubernetes Cluster with Amazon EKS

    11
    24



    Pre-requisites:
    AWSCLI
    Install kubectl
    Install aws-iam-authenticator
    step:0 AWS CLI needed to interact with AWS cloud resources. A profile with administrative access should be configured.
    step:1 Create Role (for accessing eks cluster create role with AmazonEKSClusterPolicy and
    AmazonEKSServicePolicy policies)
    Kubernetes clusters managed by Amazon EKS make calls to other AWS services on your behalf to manage the resources that you use with the service. Before you can create Amazon EKS clusters, you must create an IAM role with the following IAM policies:

    AmazonEKSClusterPolicy

    Note
    Prior to April 16, 2020, AmazonEKSServicePolicy was also required and the suggested name was eksServiceRole. With the AWSServiceRoleForAmazonEKS service-linked role, that policy is no longer required.
    https://docs.aws.amazon.com/eks/latest/userguide/service_IAM_role.html

    step:2 Create VPC by using Cloudformation template
    step:3 Create Cluster using AWSCLI
    step:4 Update Cluster
    step:5 Create nodes for the cluster using Cloudformation template
    step:6 Map Nodes to Master
    step:7 Check nodes of the cluster

    Download 1.14.6 version of kubectl and aws-iam-authenticator

    https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html
    https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html

    https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-01-
    09/amazon-eks-vpc-sample.yaml
    CloudFormation will begin to create the VPC. Once done, be sure to note the various values created — SecurityGroups, VpcId and SubnetIds. You will need these in subsequent steps.

    aws eks create-cluster
    –name eks-cluster
    –region us-east-1
    –role-arn arn:aws:iam::791382328408:role/eks-role
    –resources-vpc-config subnetIds=subnet-06e094781818119c9,subnet-02942a18072a8a494,subnet-0d04b795c369cd727,securityGroupIds=sg-047a0533d14aa70bb

    status check for eks cluster
    —————————-
    aws eks –region us-east-1 describe-cluster –name eks-cluster –query cluster.status

    update eks cluster
    ——————
    aws eks –region us-east-1 update-kubeconfig –name eks-cluster

    cloudformation-worker-node
    —————————
    https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/amazon-eks-nodegroup.yaml

    https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
    ami-0dc7713312a7ec987

    To enable worker nodes to join your cluster
    ——————————————-
    curl -o aws-auth-cm.yaml https://amazon-eks.s3-us-west-2.amazonaws.com/cloudformation/2019-02-11/aws-auth-cm.yaml
    vi aws-auth-cm.yaml

    kubectl apply -f aws-auth-cm.yaml

    kubectl get nodes –watch

    Deploy nginx image
    ——————
    kubectl run –image=nginx nginx-app –port=80

    kubectl expose deployment nginx-app –port=80 –name=nginx-http –type LoadBalancer

    source

    Previous articleScaling an AKS (Azure Kubernetes Services) cluster explained in plain English
    Next articleDocker on AWS with Amazon ECR & ECS (Part 1)

    24 COMMENTS

    1. Hi Thanks for the video.

      I have one question here, when we are using EKS, for example i have 3 pod should always up and running, for some reason my one of the pod went for pending state, when the pod status pending the EKS will provision the new worker node and schedule the pending pod on the new worker node itself?

    2. i dont understand when inputting create cluster with cli, he said "An error occurred (AccessDeniedException) when calling the CreateCluster operation: User: arn:aws:sts::951216862528:assumed-role/ec2-role-for-eks-cluster/i-02c9 2d5e50c8330a3 is not authorized to perform: eks:CreateCluster on resource: arn:a ws:eks:us-east-1:951216862528:cluster/eks-cluster-demo with an explicit deny
      "

      what should i do,mr?