Skip to content

sunnygodiwal1991/kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Kubernetes

Table of Contente

Installing Kubernetes on AWS Using Kops

One Linux/Ubuntu Virtual Machine is Required (Our Example is Based on AWS Linux)

Insatll awscli using following

$pip install awscli

Create a new IAM user or use an existing IAM user and grant following permissions.

  • AmazonEC2FullAccess
  • AmazonRoute53FullAccess
  • AmazonS3FullAccess
  • AmazonVPCFullAccess

Configure the AWS CLI by providing the Access Key, Secret Access Key and the AWS region.

$aws configure
AWS Access Key ID [None]: AccessKeyValue
AWS Secret Access Key [None]: SecretAccessKeyValue
Default region name [None]: us-east-1
Default output format [None]:

Install kops by following its official installation guide.

$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
Checking kops version.
$kops version

Install kubectl by following its official installation guide

$curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
$curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl
$chmod +x ./kubectl
$sudo mv ./kubectl /usr/local/bin/kubectl
Checking kubectl version.
$kubectl --version

Create an AWS S3 bucket for kops to persist its state.

$bucket_name=sample-kops-state-store
$aws s3 mb s3://${bucket_name} --region us-west-2

Provide a name for the Kubernetes cluster and set the S3 bucket URL in the following environment variables.

export KOPS_CLUSTER_NAME=sample.com
export KOPS_STATE_STORE=s3://${bucket_name}

kops create cluster help command to find additional parameters.

kops create cluster --help

Create a Kubernetes cluster definition using kops by providing the required fields.

$kops create cluster \
--state=${KOPS_STATE_STORE} \
--node-count=2 \
--master-size=t2.micro \
--node-size=t2.micro \
--zones=us-west-1a \
--name=${KOPS_CLUSTER_NAME}

If it show any ssh required after running above command

kops create secret sshpublickey admin -i ~/.ssh/id_rsa.pub --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE}

Review the Kubernetes cluster definition by executing the below command

$kops edit cluster --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE}

Now create the Kubernetes cluster on AWS by executing kops update command

$kops update cluster --name=${KOPS_CLUSTER_NAME} --state=${KOPS_STATE_STORE} --yes

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

$kops validate cluster --state=${KOPS_STATE_STORE} --name=${KOPS_CLUSTER_NAME}

Execute the below command to find the Kubernetes master hostname using kubectl

$kubectl cluster-info

To connect to the master and check the connection

$ssh -i ~/.ssh/id_rsa admin@api.sample.com

This site was built using GitHub Pages.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published