Skip to content

showcase k8s cluster on aws using kops and ingress

Notifications You must be signed in to change notification settings

shavo007/k8s-ingress

Repository files navigation

k8s-ingress

showcase k8s cluster on aws using kops and ingress


Installation

Terraform

curl -LO https://releases.hashicorp.com/terraform/0.10.7/terraform_0.10.7_darwin_amd64.zip
unzip terraform_0.10.7_darwin_amd64.zip
sudo mv terraform /usr/local/bin/terraform
terraform

KOPS

echo "Download kops"

curl -LO https://github.com/kubernetes/kops/releases/download/1.7.1/kops-darwin-amd64 && chmod +x  kops-darwin-amd64 \
&& sudo mv kops-darwin-amd64 /usr/local/bin/kops \
&& echo "kops version installed is  $(kops version)"

Creation of S3 bucket

terraform init -- Initialization (install the plugins for aws provider)
terraform plan -- Dry run
terraform apply -- Run
terraform show -- Inspect state

Create cluster

./deploy.sh

Export kube configuration

kops export kubecfg ${NAME}

dashboard

kubectl proxy

open http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Ingress

controller and back-end on aws

  • create ingress controller (nginx) on AWS and sample app echo-header

Follow instructions below:

https://github.com/kubernetes/ingress-nginx/tree/master/deploy

  • Test accessing default back-end and echo-header service from ELB

ELB=$(kubectl get svc ingress-nginx -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')

curl $ELB
curl $ELB/backend -H 'Host: foo.bar.com'
  • Scale echo-headers deployment to three pods kubectl scale --replicas=3 deployment/echoheaders

  • kubetail -- really useful tool to tail logs

brew tap johanhaleby/kubetail && brew install kubetail
  • Test sticky session (tail logs of pods and create ingress for sticky session)
kubetail -l app=echoheaders

kubectl apply -f sticky-ingress.yaml
curl -D cookies.txt $ELB/foo -H 'Host: stickyingress.example.com'


while true; do sleep 1;curl -b cookies.txt $ELB/foo -H 'Host: stickyingress.example.com';done

see that requests are directed to only one pod

Demo

  • NGINX sample configuration
kubectl exec -it <podname> bash
cat /etc/nginx/nginx.conf

upstream sticky-default-echoheaders-x-80 {
      sticky hash=sha1 name=route  httponly;
      server 100.96.2.8:8080 max_fails=0 fail_timeout=0;
      server 100.96.1.5:8080 max_fails=0 fail_timeout=0;
      server 100.96.2.7:8080 max_fails=0 fail_timeout=0;
  }

Mobile app Cabin

Developed by guys at bitnami https://github.com/bitnami/cabin

Useful for managing your cluster on the go!

Resources

AWS Nginx ingress controller: https://github.com/kubernetes/ingress/tree/master/controllers/nginx

Create cluster args: https://github.com/kubernetes/kops/blob/master/docs/cli/kops_create_cluster.md

Releases

No releases published

Packages

No packages published