Helm namespaces

I’ve been creating my own Helm chart for an application. I initially tried to shoe-horn the namespace into the values.yaml and then pull it through into the service and deployment yaml files. Turns out that isn’t a good way to do it, which is kind of obvious when you think about it. It’s a common scenario for an application to exist multiple times in the same cluster, separated by namespace.

When you install the chart for the first time, provide the name of the namespace which already exists.
Here’s the steps from Creating a new Helm Chart to deploying and then upgrading it.

helm create nginx-webapp
#tweak the values.yml
cd nginx-webapp/
kubectl create namespace whatthehack-webapps2
helm install --name nginx-webapp . --namespace whatthehack-webapps2
#make a change to the application
helm upgrade nginx-webapp .
kubectl get svc --all-namespaces
helm upgrade nginx-webapp .

Kubectl apply annotation for rollback history

The great thing about Kubernetes is the declarative nature of the YAML files you write to describe your deployments. You can always be sure that your deployment will match what’s in your YAML. More often than not, i’m hacking something together and submitting my deployments to Kubernetes incrementally by changing my YAML file and then performing a kubectl apply command. As such, I don’t get a lot of information in my history. EG. if I run kubectl rollout history deployments then the change-cause is just empty.

I’ve been going through a hack, where rollbacks have become a critical part of the exercise – so felt this needed more exploration. I wanted to start getting an annotation coming through to serve as a quick change log. Here’s how I did it.
kubectl apply -f contentweb.yaml
kubectl annotate deployment content-web kubernetes.io/change-cause="my release note" --record=false --overwrite=true
kubectl rollout history deployments

Minikube cheat sheet


Some of the common commands needed for a local Minikube install on a Windows10 Hyper-v setup.

Ref: https://github.com/kubernetes/minikube

install choclatey
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

install kubectl
choco install kubernetes-cli

start minikube (my hyper-v switch is called vSwitch)
minikube.exe start --kubernetes-version="v1.8.0" --vm-driver="hyperv" --memory=1024 --hyperv-virtual-switch="vSwitch" --v=7 --alsologtostderr

get cluster information
kubectl cluster-info

open k8s web dashboard
minikube dashboard