https://github.com/abhishek010397/kubernetes-kops-aws-terraform
https://github.com/abhishek010397/kubernetes-kops-aws-terraform
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abhishek010397/kubernetes-kops-aws-terraform
- Owner: Abhishek010397
- Created: 2020-05-07T15:18:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T14:45:18.000Z (almost 5 years ago)
- Last Synced: 2025-02-15T11:18:54.045Z (8 months ago)
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes-Kops-AWS-Terraform
# Kubernetes on AWS using Kops
### 1. Launch Linux EC2 instance in AWS
### 2. Create and attach IAM role to EC2 Instance.
Kops need permissions to access
S3
EC2
VPC
Route53
Autoscaling
etc..
### 3. Install Kops on EC2
```sh
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
```### 4. Install kubectl
```sh
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
```
### 5. Create S3 bucket in AWS
S3 bucket is used by kubernetes to persist cluster state, lets create s3 bucket using aws cli
**Note:** Make sure you choose bucket name that is uniqe accross all aws accounts```sh
aws s3 mb s3:// --region
```
### 6. Create private hosted zone in AWS Route53
1. Head over to aws Route53 and create hostedzone
2. Choose name for example (xyz.in)
3. Choose type as privated hosted zone for VPC
4. Select default vpc in the region you are setting up your cluster
5. Hit create### 7 Configure environment variables.
Open .bashrc file
```
vi ~/.bashrc
```
Add following content into .bashrc, you can choose any arbitary name for cluster and make sure buck name matches the one you created in previous step.```sh
export KOPS_CLUSTER_NAME=
export KOPS_STATE_STORE=s3://
```
Then running command to reflect variables added to .bashrc
```
source ~/.bashrc
```
### 8. Create ssh key pair
This keypair is used for ssh into kubernetes cluster, hit enter repeated times after applying this command for making default usages```sh
ssh-keygen
```### 9. Create a Kubernetes cluster definition, change the node-count,master-node-size,zones as per your need
```sh
kops create cluster \
--state=${KOPS_STATE_STORE} \
--node-count=2 \
--master-size=t2.micro \
--node-size=t2.micro \
--zones=us-east-2c \
--name=${KOPS_CLUSTER_NAME} \
--dns private \
--master-count 1
--networking calico
```### 10. Create kubernetes cluster
```sh
kops update cluster --yes
```
You can export KOPS_STATE_STORE=s3://clusters.dev.example.com and then kops will use this location by default. We suggest putting this in your bash profile or similar```sh
KOPS_STATE_STORE=s3://
```Above command may take some time to create the required infrastructure resources on AWS. Execute the validate command to check its status and wait until the cluster becomes ready
```sh
kops validate cluster
```
For the above above command, you might see validation failed error initially when you create cluster and it is expected behaviour, you have to wait for some more time and check again.### 11. To connect to the master
```sh
ssh admin@api.
```
# Destroy the kubernetes cluster
```sh
kops delete cluster --yes
```https://kops.sigs.k8s.io/getting_started/install/