Lab 14 - Helm: install Traefik, releases and charts
Lab 14 - Helm: install Traefik, releases and charts
Goal: install Helm, then use it on a real chart: Traefik, the entry point for Labs 15 and 16. Inspect, install, upgrade, roll back. Chapter: Helm
Install Helm
# 1 -
cd ~
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4
chmod 700 get_helm.sh && ./get_helm.sh
helm version
Look before you install
# 2 - the repository
helm repo add traefik https://traefik.github.io/charts
helm repo update
helm search repo traefik/traefik
helm search repo traefik/traefik --versions | head -5
# 3 - the chart's interface
helm show chart traefik/traefik | head -12
helm show values traefik/traefik | grep -n -A6 -E '^(service|gateway|providers):'
show values is the public interface of a chart. A setting that is not there
does not exist - --set on an unknown key is silently ignored.
Prerequisite: Gateway API CRDs
Traefik will also serve Gateway API (Lab 16). The CRDs are not part of Kubernetes and the chart does not install them:
# 4 -
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.1/standard-install.yaml
kubectl api-resources --api-group=gateway.networking.k8s.io
Install Traefik
# 5 - our values: NodePort (no cloud LB here) and Gateway API on
cat > traefik-values.yaml <<'YAML'
service:
type: NodePort
ports:
web:
nodePort: 30080
websecure:
nodePort: 30443
providers:
kubernetesGateway:
enabled: true
gateway:
listeners:
web:
namespacePolicy:
from: All
YAML
# 6 - render first: what would be created?
helm template traefik traefik/traefik -n traefik -f traefik-values.yaml | grep '^kind:' | sort | uniq -c
# 7 - install
helm install traefik traefik/traefik -n traefik --create-namespace \
-f traefik-values.yaml --wait
helm list -n traefik
kubectl get pods,svc -n traefik
kubectl get ingressclass,gatewayclass
kubectl get gateway -n traefik
One release gave you: the Traefik Deployment, a NodePort Service
(80 -> 30080, 443 -> 30443), the IngressClass traefik, the GatewayClass
traefik and a Gateway traefik-gateway.
# 8 - is anybody home?
curl -s -o /dev/null -w '%{http_code}\n' http://worker01:30080/
404 - Traefik answers, it just has no routes yet. That is success.
What Helm remembers
# 9 -
helm get values traefik -n traefik # only what you overrode
helm get manifest traefik -n traefik | grep -E '^kind:' | sort | uniq -c
helm status traefik -n traefik
Upgrade and roll back
# 10 - change one value -> new revision
helm upgrade traefik traefik/traefik -n traefik -f traefik-values.yaml \
--set deployment.replicas=2 --wait
kubectl get pods -n traefik
helm history traefik -n traefik
-f again! helm upgrade without your values file would fall back to the
chart defaults - LoadBalancer, no Gateway API.
# 11 - roll back to revision 1
helm rollback traefik 1 -n traefik --wait
helm history traefik -n traefik # rollback = revision 3
kubectl get pods -n traefik # one replica again
Keep Traefik installed - Labs 15 and 16 use it.
Discovery
InfodiscoverTask A. Create your own chart myapp with helm create, render it and
install it as release demo in namespace helmlab with 2 replicas.
Task B. Change the image tag of demo to 1.27 without editing the chart,
then find out which values the release uses.
Clean up
helm uninstall demo -n helmlab --ignore-not-found
kubectl delete ns helmlab --ignore-not-found