Skip to content

Latest commit

 

History

History
100 lines (71 loc) · 2.93 KB

eks.md

File metadata and controls

100 lines (71 loc) · 2.93 KB

Provisioning EKS with Ansible

Requirements

Python libraries

As we will interact with AWS, we need a couple of Python libraries to be present in the system.

pip install --user -r requirements_eks.txt

Ansible Collections

We will also need the Ansible Amazon AWS Collection.

ansible-galaxy collection install -r collections/requirements.yml

Creating a new EKS Cluster

Follow these steps to provision an EKS cluster.

  1. Clone this repository: git clone https://github.com/nleiva/ansible-kubernetes.git

  2. Make your AWS account credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) available as environment variables (export).

export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
  1. Run the Playbook and wait a couple of minutes while EKS is being provisioned.
 ⇨  ansible-playbook main.yml -v --extra-vars "cloud_provider=aws"

<snip>
   
TASK [aws_create_eks : Print out EKS return info] ***********************************************************************************
ok: [localhost] => {
    "msg": {
        ...
        "name": "my-cluster",
        "platform_version": "eks.8",
        "resources_vpc_config": {
            "cluster_security_group_id": "sg-0ef6587703facbXXX",
            "endpoint_private_access": false,
            "endpoint_public_access": true,
            "public_access_cidrs": [
                "0.0.0.0/0"
            ],
            "security_group_ids": [
                "sg-002815218a770a775"
            ],
            "subnet_ids": [
                "subnet-08669dda493cbcXXX",
                "subnet-08f5f57ef88d6bXXX"
            ],
            "vpc_id": "vpc-0248e5e848752fXXX"
        },
        "role_arn": "arn:aws:iam::901353702XXX:role/kubernetes-role",
        "status": "ACTIVE",
        "tags": {},
        "version": "1.18"
    }
}

PLAY RECAP **************************************************************************************************************************
localhost                  : ok=20   changed=5    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0   

AWS Console view

Cluster

Worker nodes

AWS CLI

  • AWS_CONFIG_FILE: Specifies the location of the file that the AWS CLI uses to store configuration profiles.
  • AWS_SHARED_CREDENTIALS_FILE: Specifies the location of the file that the AWS CLI uses to store access keys.

Kubeconfig

Create a kubeconfig for Amazon EKS.

Links