Skip to content

Commit e72a762

Browse files
authored
Create README.md
1 parent f04d793 commit e72a762

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# kops-kubernetes-cluster-configuration
2+
<<kops
3+
Landmark Technologies
4+
Tel: +1 437 215 2483
5+
mylandmarktech@gailcom
6+
www.mylandmarktech.com
7+
kops
8+
Setup Kubernetes (K8s) Cluster on AWS Using KOPS
9+
10+
#!/bin/bash
11+
#1) Create Ubuntu EC2 instance in AWS
12+
13+
#2) install AWSCLI
14+
15+
sudo apt update -y
16+
sudo apt install unzip wget -y
17+
sudo curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip
18+
sudo apt install unzip python -y
19+
sudo unzip awscli-bundle.zip
20+
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
21+
22+
23+
#3) Install kops software on ubuntu instance:
24+
25+
#Install wget if not installed
26+
sudo apt install wget -y
27+
sudo wget https://github.com/kubernetes/kops/releases/download/v1.16.1/kops-linux-amd64
28+
sudo chmod +x kops-linux-amd64
29+
sudo mv kops-linux-amd64 /usr/local/bin/kops
30+
31+
#4) Install kubectl
32+
33+
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
34+
sudo chmod +x ./kubectl
35+
sudo mv ./kubectl /usr/local/bin/kubectl
36+
aws s3 mb s3://nubonglegah.k8.local
37+
aws s3 ls
38+
39+
# 5) Create an IAM role from AWS Console or CLI with below Policies.
40+
41+
AmazonEC2FullAccess
42+
AmazonS3FullAccess
43+
IAMFullAccess
44+
AmazonVPCFullAccess
45+
46+
47+
Then Attach IAM role to ubuntu server from Console Select KOPS Server --> Actions --> Instance Settings --> Attach/Replace IAM Role --> Select the role which
48+
You Created. --> Save.
49+
50+
51+
52+
#6) create an S3 bucket Execute below commond in KOPS Server use unique bucket name if you get bucket name exists error.
53+
54+
aws s3 mb s3://nubonglegah.k8.local
55+
aws s3 ls
56+
57+
ex:
58+
# S3 bucket name should be unique across AWS
59+
aws s3 mb s3://simonlegah.k8s.local s3://nubong.k8s.local
60+
61+
Expose environment variable:
62+
63+
# Add env variables in bashrc
64+
vi .bashrc
65+
66+
# Give Unique Name And S3 Bucket which you created.
67+
export NAME=s3://legah2045.k8.local
68+
export KOPS_STATE_STORE=s3://legah2045.k8.local
69+
70+
source .bashrc
71+
72+
#7) Create sshkeys before creating cluster
73+
74+
ssh-keygen
75+
76+
77+
# 8)Create kubernetes cluster definitions on S3 bucket
78+
79+
kops create cluster --zones us-east-2c --networking weave --master-size t2.medium --master-count 1 --node-size t2.large --node-count=2 ${NAME}
80+
81+
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}
82+
83+
kops create secret --name ${NAME} sshpublickey admin -i ~/.ssh/id_rsa.pub
84+
85+
# 9) Create kubernetes cluser
86+
87+
kops update cluster ${NAME} --yes
88+
89+
# 10) Validate your cluster(KOPS will take some time to create cluster ,Execute below commond after 3 or 4 mins)
90+
91+
kops validate cluster
92+
93+
# 11) To list nodes
94+
95+
kubectl get nodes
96+
97+
98+
99+
# 12) To Delete Cluster
100+
101+
kops delete cluster --name=${NAME} --state=${KOPS_STATE_STORE} --yes
102+
103+
====================================================================================================
104+
105+
106+
13# IF you wan to SSH to Kubernates Master or Nodes Created by KOPS. You can SSH From KOPS_Server
107+
108+
ssh admin@<IPOrDNS>
109+
it above command is not working
110+
then execute
111+
ssh -i ~/.ssh/id_rsa admin@<IPOrDNS>
112+

0 commit comments

Comments
 (0)