Skip to content

zeineldin/Kops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 

Repository files navigation

Install and confiure KOPS on Ubunut 18

  1. install kubectl --> https://kubernetes.io/docs/tasks/tools/install-kubectl/

    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

  2. install Kops

    curl -Lo kops 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

    sudo mv ./kops /usr/local/bin/

  3. install AWS CLI

    apt-get update

    install -y awscli

Then do as the following https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

  1. configure the awscli using your AWS account "you could create free account"

aws configure

Note : the AWS user must have adminstration permission

  1. create new S3 bucket to save your KOPS state "it has to be at the same KOPS region"

A. make sure that it works "ex: bucket name k8s-kops-berlin-zeineldin"

 aws s3 mb s3://k8s-kops-berlin-zeineldin

B. Enable bucker versioning

aws s3api put-bucket-versioning --bucket k8s-kops-berlin-zeineldin --versioning-configuration Status=Enabled

C. Expose ENV "to save the state of the Cluster"

export KOPS_STATE_STORE=s3://k8s-kops-berlin-zeineldin
  1. Create DNS Configurations

kubernetes uses DNS for discovery inside the cluster so that you can reach out kubernetes API server from clients. create a hosted zone on Route53, say, k8s.devops.vpc. The API server endpoint will then be ex:berlin.k8s.local as (Gossip DNS)

  1. Create ssh public and private keys

    ssh-keygen

it will be created in the default location which is ~/.ssh/id_rsa.pub

  1. export cluster and bucket name

    export KOPS_CLUSTER_NAME=cluster.zeinedin.local

  2. create KOPS Cluster

    kops create cluster --name=${KOPS_CLUSTER_NAME} --ssh-public-key="~/.ssh/id_rsa.pub" --state=${KOPS_STATE_STORE} --zones=eu-west-1a --master-size=t2.micro --node-count=2 --node-size=t2.micro

Note : if you don't have DNS configuration you could just use gossip based DNS "ie: zein.cluster.k8s.local""

kops create cluster --name=${KOPS_CLUSTER_NAME} --ssh-public-key="~/.ssh/id_rsa.pub" --state=${KOPS_STATE_STORE} --zones=eu-west-1a --master-size=t2.micro --node-count=2 --node-size=t2.micro  --topology=private --networking=calico
  1. You could edit in the cluster

    kops edit cluster --name ${KOPS_CLUSTER_NAME}

  2. Run the Cluster

    kops update cluster --name ${KOPS_CLUSTER_NAME} --yes

  3. Make Sure that every thing works

    kops validate cluster

  4. login to the master server and check the cluster

    ssh -i ~/.ssh/id_rsa admin@<Mater_Node_IP>

  5. Create the 1st deployment

    kubectl run webserver --image=nginx --port= 80 -- replicas=2

  6. Export the deployment

    kubectl expose deployment webserver --name web-service --type=LoadBalancer --port=80

  7. check the service

    kubectl get service

check the port

  1. Open the port in the KOPS Cluster Security group

  2. SEE THE SERVICE FROM THE URL:PORT

  3. delete the culster if you want :)

    kops delete cluster --name ${CLUSTER_NAME} --yes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages