This repository is used to create prerequisites that are required to access/create/delete Elastic Container Service For Kubernetes.
- Prerequisites
- Install Vagrant Box
- Vagrant Box Details
- Create EKS cluster
- Access EKS cluster
- Delete EKS cluster
- Add-Ons provided
- Login Vagrant VM
- Stop Vagrant VM
- Restart Vagrant VM
- Destroy Vagrant VM
- Example
- Enable Virtualization(VT) in BIOS for Hyper-V
- Git command line utility which is used to target an existing repository and create a clone, or copy of the target repository
- Vagrant (Version >= 2.2.0) is an open-source software product for building and maintaining portable virtual software development environments, e.g. for VirtualBox, Hyper-V, Docker containers, VMware, and AWS
- Oracle VM VirtualBox (Version >= 6.0) lets you run multiple operating systems on Mac OS, Windows, Linux, or Oracle Solaris.
- Minimum laptop/desktop configuration - 8GBRAM , 4CPU , support for VT-X
Default settings:env.yaml
. These settings can be changed as per your requirements and the below are minimum requirements.
VM:
password: aws-eks
ip: 100.10.10.108
cpus: 2
memory: 2048
vmname: aws-eks-centos
hostname: aws-eks-centos.com
Open windows (OR) bash
terminal from your local windows
machine
$ git clone https://github.com/SubhakarKotta/aws-eks-vagrant-centos.git
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant up
Name | IP | OS | RAM | CPU |
---|---|---|---|---|
aws-eks-centos | 100.10.10.108 | CentOS7 | 2G | 2 |
Login to vagrant box from your local machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant ssh aws-eks-centos
$ sudo su
Provide AWS Credentials
$ aws configure
............... AWS Access Key ID [None]:
............... AWS Secret Access Key [None]:
............... Default region name [None]:
............... Default output format [None]:
Create EKS Cluster
$ eksctl create cluster --version=1.11 --name=<YOUR_CLUSTER_NAME> --region=<YOUR_REGION_NAME> --nodes-min=<MIN_NODES> --nodes-max=<MAX_NODES> --node-type=m4.xlarge --tags Owner=<YOUR_NAME>
Install Tiller
$ kubectl --namespace kube-system create serviceaccount tiller
$ kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
$ helm init --service-account tiller --upgrade
Install kubernetes dashboard by following the steps given in the link
Access Kubernetes Dashboard by following the steps given in the link
From local system execute the below commands
$ ssh -L 8001:localhost:8001 root@100.10.10.108
[password : aws-eks]
Use the below command to generate access token login to Dashboard
$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')
Start proxy to access kubernetes dashboard
$ kubectl proxy
Login to vagrant box from your local machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant ssh aws-eks-centos
$ sudo su
Provide AWS Credentials
$ aws configure
............... AWS Access Key ID [None]:
............... AWS Secret Access Key [None]:
............... Default region name [None]:
............... Default output format [None]:
Fetch/Update kubeconfig on your vagrant box
$ aws eks --region <region> update-kubeconfig --name <cluster_name>
Verify Nodes
$ kubectl get nodes
[Verify kubectl is connected to eks cluster]
Access Kubernetes Dashboard by following the steps given in the link
Login to vagrant box from your local machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant ssh aws-eks-centos
$ sudo su
Provide AWS Credentials
$ aws configure
............... AWS Access Key ID [None]:
............... AWS Secret Access Key [None]:
............... Default region name [None]:
............... Default output format [None]:
Delete EKS Cluster When the cluster is no longer needed, use the eksctl delete cluster command to remove all the related resources.
$ eksctl delete cluster --name=<YOUR_CLUSTER_NAME> --region=<YOUR_REGION_NAME>
kubectl (1.11.5)
aws-iam-authenticator
aws-cli
pip
eksctl
(https://github.com/weaveworks/eksctl)helm
terraform
(https://www.terraform.io)
The Vagrant VM can be accessed in two ways from your local windows machine
vagrant ssh
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant ssh aws-eks-centos
putty/mobaxterm
100.10.10.108
[vagrant/vagrant (Or) root/aws-eks]
Run the below command to stop the Vagrant Box from your local windows machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant halt
Run the below command to restart the Vagrant Box if the vagrant box is stopped from your local windows machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant up
Run the below command to delete the Vagrant Box from your local windows machine
$ cd aws-eks-vagrant-centos/provisioning
$ vagrant destroy
Here we will see a simple example creating a EKS cluster in us-east-2 region
Understand the parameters that we are going to authenticate AWS.
AWS Access Key <access key to authenticate AWS>
AWS Secret Access Key <secret access key to authenticate AWS>
Default Region name <region where we are going to create cluster>
Default output format <we can leave this empty>
Run the below command to authenticate AWS Credentials
$ aws configure
............... AWS Access Key ID [None]:AKIAI4MUM3N25AHL3O5Q
............... AWS Secret Access Key [None]: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
............... Default region name [None]: us-east-2
............... Default output format [None]:
Understand the parameters that we are going to pass to create EKS Cluster
--version <Kubernetes Version that AWS Supports>
--name <Name of the EKS Cluster>
--region <Region that you are going to create cluster>
--nodes-min <Mimimum number of EC2 instances in EKS Cluster>
--nodes-min <Maximum number of EC2 instances in EKS Cluster>
--node-type <The configuration of each EC2 machine with what CPU and MEMRORY should be>
--tags <The tag that needs to be added in each resource that will be created with EKS Cluster i.e who added, what is the purpose etc>
Run the below command to create new EKS Cluster
$ eksctl create cluster --version=1.11 --name=my-pega-cluster --region=us-east-2 --nodes-min=2 --nodes-max=5 --node-type=m4.xlarge --tags Owner=pega
To learn more about eksctl parameters please check the below link which has full details.
eksctl
(https://github.com/weaveworks/eksctl)