-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
kops installation.txt
111 lines (68 loc) · 3.13 KB
/
kops installation.txt
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<<kops
Landmark Technologies
Tel: +1 437 215 2483
mylandmarktech@gailcom
www.mylandmarktech.com
kops
Setup Kubernetes (K8s) Cluster on AWS Using KOPS
#!/bin/bash
#1) Create Ubuntu EC2 instance
#2) install AWSCLI
sudo apt update -y
sudo apt install unzip wget -y
sudo curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip
sudo apt install unzip python -y
sudo unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
#3) Install kops on ubuntu instance:
#Install wget if not installed
sudo apt install wget -y
sudo wget https://github.com/kubernetes/kops/releases/download/v1.16.1/kops-linux-amd64
sudo chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
#4) Install kubectl
sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
sudo chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
aws s3 mb s3://nubonglegah.k8.local
aws s3 ls
5) Create an IAM role from Consloe or CLI with below Policies.
AmazonEC2FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess
Then Attach IAM role to ubuntu server from Console Select KOPS Server --> Actions --> Instance Settings --> Attach/Replace IAM Role --> Select the role which
You Created. --> Save.
6) create an S3 bucket Execute below commond in KOPS Server use unique bucket name if you get bucket name exists error.
aws s3 mb s3://nubonglegah.k8.local
aws s3 ls
ex:
# S3 bucket name should be unique across AWS
aws s3 mb s3://simonlegah.k8s.local s3://nubong.k8s.local
Expose environment variable:
# Add env variables in bashrc
vi .bashrc
# Give Unique Name And S3 Bucket which you created.
export NAME=s3://legah2045.k8.local
export KOPS_STATE_STORE=s3://legah2045.k8.local
source .bashrc
7) Create sshkeys before creating cluster
ssh-keygen
8)Create kubernetes cluster definitions on S3 bucket
kops create cluster --zones us-east-2c --networking weave --master-size t2.medium --master-count 1 --node-size t2.large --node-count=2 ${NAME}
kops create cluster --zones us-east-1e,zones us-east-2c --networking weave --master-size t2.medium --master-count 2 --node-size t2.micro --node-count=2 ${NAME}
kops create secret --name ${NAME} sshpublickey admin -i ~/.ssh/id_rsa.pub
9) Create kubernetes cluser
kops update cluster ${NAME} --yes
10) Validate your cluster(KOPS will take some time to create cluster ,Execute below commond after 3 or 4 mins)
kops validate cluster
11) To list nodes
kubectl get nodes
To Delete Cluster
kops delete cluster --name=${NAME} --state=${KOPS_STATE_STORE} --yes
====================================================================================================
IF you wan to SSH to Kubernates Master or Nodes Created by KOPS. You can SSH From KOPS_Server
ssh admin@<IPOrDNS>
it above command is not working
then execute
ssh -i ~/.ssh/id_rsa admin@<IPOrDNS>