GithubHelp home page GithubHelp logo

aaron-schnieder / k8-traefik-canary Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 13 KB

Kubernetes example project using helm, traefik ingress controller and canary deployments.

License: MIT License

HTML 100.00%

k8-traefik-canary's Introduction

hello-kube

k8 canary deployment example using the traefik ingress controller.

Pre-requisites

  1. brew install kubernetes-helm
  2. Azure CLI

Working with Azure ACS cluster

az login
az account set -s <subscription id>
az acs kubernetes get-credentials --resource-group=my-resource-group --name=my-k8-cluster

Ensure you kubectl is connected to the corrrect k8 cluster

kubectl config view

Init helm, which will deploy the tiller agent pod that allows helm charts to be deployed to the cluster

helm init --upgrade

Ensure helm's tiller pod is deployed to your k8 cluster and running

kubectl get pods --namespace kube-system

Install traefik ingress controller

Use the traefik helm chart to deploy traefik to your cluster

In dev / test, enable the traefik ingress controller dashboard to view routing


helm install --name traefik-hello-kube --namespace kube-system --set dashboard.enabled=true,dashboard.domain=traefik-ui.acs stable/traefik

In prod, just install the traefik ingress controller but don't enable the dashboard


helm install stable/traefik --name traefik-hello-kube --namespace kube-system

Get the local resource name of the traefik helm chart that was installed

helm list

Now view the status of traefik on the k8 cluster using the local resource name

helm status traefik-hello-kube

You can also view the service and pods deployed via

kubectl get svc,pods --namespace kube-system

Deployment

Build docker image for stable version and push to dockerhub

edit index.html and change version to stable
docker build -t schnieds/hello-kube:stable .
docker push schnieds/hello-kube:stable

Build docker image for canary version and push to dockerhub

edit index.html and change version canary
docker build -t schnieds/hello-kube:canary .
docker push schnieds/hello-kube:canary

Deploy ingress and ensure it is running

kubectl apply -f ingress.yaml
kubectl get ingress

Deploy service and ensure it is running

kubectl apply -f service.yaml
kubectl get svc

Deploy pods and ensure they are running

kubectl apply -f deployment-stable.yaml
kubectl apply -f deployment-canary.yaml
kubectl get pods
kubectl describe pod <podname from get pods output>

Get the external IP for the traefik ingress controller

kubectl describe service traefik-hello-kube -n kube-system | grep Ingress
<copy the LoadBalancer Ingress: value to get the external IP>

Execute a bunch of HTTP GET requests to view requests splitting between canary and stable versions


for ((i=1;i<=30;i++)); do curl -s "http://<loadbalancer ingress ip>/" | grep version: ; done

Clean up resources in cluster


kubectl delete -f service.yaml
kubectl delete -f deployment-canary.yaml
kubectl delete -f deployment-stable.yaml
helm delete traefik-hello-kube

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.