Skip to content

f #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
80 changes: 43 additions & 37 deletions 01-EKS-Create-Cluster-using-eksctl/01-01-Install-CLIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,47 @@
- Install eksctl CLI

## Step-01: Install AWS CLI
- Reference-1: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
- Reference-2: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
### Step-01-01: MAC - Install and configure AWS CLI
- Download the binary and install via command line using below two commands.
```
# Download Binary
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
# Prerequisites

* Python3 or Python2.7.9+
* Python Pip3 / Pip

# Install the binary
sudo installer -pkg ./AWSCLIV2.pkg -target /
# Install awscli
## linux based system

```bash
pip install --user awscli
export PATH=$PATH:/home/$(whoami)/.local/bin
```
- Verify the installation

_--user_ is used to install the awscli under your home directory, not to interfere with any existing libraries/installations

create file _~/.aws/credentials_

```bash
[default]
aws_access_key_id=###
aws_secret_access_key=###
region=us-east-1
output=json
```
aws --version
aws-cli/2.0.7 Python/3.7.4 Darwin/19.4.0 botocore/2.0.0dev11

which aws
## Windows, using Anaconda
after Anaconda python distribution, goto "Start" => "Anaconda" => "open anaconda shell"

```
- Reference: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
# potentially upgrade pip first
python -m pip install --upgrade pip
pip install --user awscli

### Step-01-02: Windows 10 - Install and configure AWS CLI
- The AWS CLI version 2 is supported on Windows XP or later.
- The AWS CLI version 2 supports only 64-bit versions of Windows.
- Download Binary: https://awscli.amazonaws.com/AWSCLIV2.msi
- Install the downloaded binary (standard windows install)
set path=%path%;c:\users\<<username>>\appdata\roaming\python\python37\scripts
```

## TEST

```bash
aws --version
aws-cli/2.0.8 Python/3.7.5 Windows/10 botocore/2.0.0dev12
```
- Reference: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

### Step-01-03: Configure AWS Command Line using Security Credentials
- Go to AWS Management Console --> Services --> IAM
Expand Down Expand Up @@ -102,25 +113,20 @@ kubectl version --client
```

## Step-03: Install eksctl CLI
### Step-03-01: eksctl on Mac
```
# Install Homebrew on MacOs
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
## Installation
for non-Linux OS you can find a binary download here:

# Install the Weaveworks Homebrew tap.
brew tap weaveworks/tap
https://github.com/weaveworks/eksctl/releases

# Install the Weaveworks Homebrew tap.
brew install weaveworks/tap/eksctl
on Linux, you can just execute:

# Verify eksctl version
eksctl version
```
```bash
curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp

### Step-03-02: eksctl on windows or linux
- For windows and linux OS, you can refer below documentation link.
- **Reference:** https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html#installing-eksctl
sudo mv /tmp/eksctl /usr/local/bin
```

This utility will use the same _credentials_ file as we explored for the AWS cli, located under '~/.aws/credentials'

## References:
- https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html
## Test
```eksctl version```
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@
- It will take 15 to 20 minutes to create the Cluster Control Plane
```
# Create Cluster
eksctl create cluster --name=eksdemo1 \
--region=us-east-1 \
--zones=us-east-1a,us-east-1b \
--without-nodegroup
eksctl create cluster --name=ml \
--region=eu-central-1 \
--zones=eu-central-1a,eu-central-1b \
--without-nodegroup \
--vpc-cidr="10.0.0.0/16" \
--vpc-nat-mode=Single \
--version=1.24 \
--fargate \
--alb-ingress-access \
--full-ecr-access \
--appmesh-access \
--tags Environment=Prod,Project=ML \
--kubeconfig=./ML-cluster.yaml

# Get List of clusters
eksctl get clusters
eksctl get clusters

# update-kubeconfig
aws eks update-kubeconfig --name ml --region eu-central-1
```


Expand All @@ -34,14 +46,24 @@ eksctl get clusters
# Template
eksctl utils associate-iam-oidc-provider \
--region region-code \
--cluster <cluter-name> \
--cluster ml \
--approve

# Replace with region & cluster name
eksctl utils associate-iam-oidc-provider \
--region us-east-1 \
--cluster eksdemo1 \
--region eu-central-1 \
--cluster ml \
--approve
```
# Create an IAM service account with a specific IAM policy attached
eksctl create iamserviceaccount \
--region eu-central-1 \
--name my-service-account \
--namespace default \
--cluster ml \
--attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \
--approve \
--override-existing-serviceaccounts
```


Expand All @@ -53,18 +75,37 @@ eksctl utils associate-iam-oidc-provider \

## Step-04: Create Node Group with additional Add-Ons in Public Subnets
- These add-ons will create the respective IAM policies for us automatically within our Node Group role.
```
# Create Public Node Group
eksctl create nodegroup --cluster=eksdemo1 \
--region=us-east-1 \
--name=eksdemo1-ng-public1 \
--node-type=t3.medium \

```
# Create demo Node Group
eksctl create nodegroup --cluster=ml \
--region=eu-central-1 \
--name=ml-ng \
--node-type=t3a.medium \
--nodes=2 \
--nodes-min=2 \
--nodes-max=4 \
--node-volume-size=20 \
--ssh-access \
--ssh-public-key=kube-demo \
--ssh-public-key=ml \
--managed \
--asg-access \
--external-dns-access \
--full-ecr-access \
--appmesh-access \
--alb-ingress-access
```
# Create prod Node Group
eksctl create nodegroup --cluster=EKS-Parent-cluster \
--region=eu-central-1 \
--name=eksparent-ng-prod \
--node-type=c5.xlarge \
--nodes=2 \
--nodes-min=2 \
--nodes-max=6 \
--node-volume-size=60 \
--ssh-access \
--ssh-public-key=kube-key \
--managed \
--asg-access \
--external-dns-access \
Expand All @@ -91,7 +132,7 @@ eksctl create nodegroup --cluster=eksdemo1 \
eksctl get cluster

# List NodeGroups in a cluster
eksctl get nodegroup --cluster=<clusterName>
eksctl get nodegroup --cluster=EKS-Parent-cluster

# List Nodes in current kubernetes cluster
kubectl get nodes -o wide
Expand Down Expand Up @@ -127,4 +168,4 @@ Use putty

## Additional References
- https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html
- https://docs.aws.amazon.com/eks/latest/userguide/create-service-account-iam-policy-and-role.html
- https://docs.aws.amazon.com/eks/latest/userguide/create-service-account-iam-policy-and-role.html