forked from vikas99341/k8s-masterclass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheksctl
82 lines (70 loc) · 2.8 KB
/
eksctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Setup Kubernetes on Amazon EKS
You can follow same procedure in the official AWS document [Getting started with Amazon EKS – eksctl](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html)
#### Pre-requisites:
- an EC2 Instance (Amazon Linux)
- Install AWSCLI latest verison
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
/usr/local/bin/aws --version
1. Setup kubectl
a. Download kubectl version 1.21
b. Grant execution permissions to kubectl executable
c. Move kubectl onto /usr/local/bin
d. Test that your kubectl installation was successful
```sh
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin
kubectl version --short --client
```
2. Setup eksctl
a. Download and extract the latest release
b. Move the extracted binary to /usr/local/bin
c. Test that your eksclt installation was successful
```sh
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
```
3. Create an IAM Role and attache it to EC2 instance
`Note: create IAM user with programmatic access if your bootstrap system is outside of AWS`
IAM user should have access to
IAM
EC2
CloudFormation
Admin
Note: Check eksctl documentaiton for [Minimum IAM policies](https://eksctl.io/usage/minimum-iam-policies/)
4. Create your cluster and nodes
```sh
eksctl create cluster --name cluster-name \
--region region-name \
--node-type instance-type \
--nodes-min 2 \
--nodes-max 2 \
--zones <AZ-1>,<AZ-2>
example:
eksctl create cluster --name demo-cluster --region us-east-1 --node-type t2.medium
5. To delete the EKS clsuter
```sh
eksctl delete cluster demo --region ap-south-1
```
6. Validate your cluster using by creating by checking nodes and by creating a pod
```sh
kubectl get nodes
kubectl run tomcat --image=tomcat
```
#### Deploying Nginx pods on Kubernetes
1. Deploying Nginx Container
```sh
kubectl create deployment demo-nginx --image=nginx --replicas=2 --port=80
# kubectl deployment regapp --image=demo/regapp --replicas=2 --port=8080
kubectl get all
kubectl get pod
```
1. Expose the deployment as service. This will create an ELB in front of those 2 containers and allow us to publicly access them.
```sh
kubectl expose deployment demo-nginx --port=80 --type=LoadBalancer
# kubectl expose deployment regapp --port=8080 --type=LoadBalancer
kubectl get services -o wide
```