lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

commit 52bef5718d92e540ab9f1ddc15467375329d7328
parent f2f4276e9e383b250bd052d8cf17b1163bb9afb6
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Sat, 22 Jan 2022 18:58:28 +0100

Update software containerisation notes

Diffstat:
Mcontent/softcont-notes/_index.md | 2++
Acontent/softcont-notes/deployment-updates.md | 28++++++++++++++++++++++++++++
Acontent/softcont-notes/helm.md | 26++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/content/softcont-notes/_index.md b/content/softcont-notes/_index.md @@ -11,3 +11,5 @@ title = 'Software Containerisation' 7. [Storage](storage) 8. [StatefulSet](statefulset) 9. [ConfigMaps & Secrets](configmaps-secrets) +10. [Deployment updates](deployment-updates) +11. [Helm: Kubernetes package manager](helm) diff --git a/content/softcont-notes/deployment-updates.md b/content/softcont-notes/deployment-updates.md @@ -0,0 +1,28 @@ ++++ +title = 'Deployment updates' ++++ +# Deployment updates +## Rolling updates +If you change Deployment's pod template (`.spec.template`), deployment rollout is triggered. +To observe rollout, you can use e.g. `kubectl rollout status <deployment>` + +Each pod and ReplicaSet created by Deployment controller get the same `pod-template-hash` label. +That's generated by hashing PodTemplate of ReplicaSet. +Its purpose is to ensure that ReplicaSets created from Deployment don't overlap. + +So that the application remains available, Deployment ensures that: +- 25% max unavailable: at most 25% of desired number of Pods are down +- 25% max surge: at most 25% more than desired number of pods are up + +You can check `kubectl rollout history`. To save a change cause, use the parameter `--record`. + +To roll back, use `kubectl rollout undo --to-revision=n` + +## Canary Deployments +Problem with rolling updates is while it's happening, you have no way of testing that it's working fine. + +Canary Deployments are used to test new release with subset of users before propagating to all users. + +Involves using at least on Service to direct traffic to pods that run old code or pods that run new code. +You add a label to pods, indicating whether it's the original type or canary. +If service does not discriminate based on that label, then both types of pods get traffic directed to them. diff --git a/content/softcont-notes/helm.md b/content/softcont-notes/helm.md @@ -0,0 +1,26 @@ ++++ +title = 'Helm: Kubernetes package manager' ++++ +## Helm: Kubernetes package manager +Introduces Helm chart, which describes contents of all objects in the application using a single package. +A running instance of such a set of Kubernetes objects is a "release". +Helm charts are stored in repos. +Helm must be installed separately from Kubernetes. + +From end user POV, on microk8s you do `microk8s enable helm3`, and then use it like a standard package manager (i.e. `list`, `install`, `uninstall`...) + +### Creating charts +A chart can include other charts. +A chart contains `Chart.yaml`, a `values.yaml`, and a templates folder. + +Start by running `helm create <chart-name>`, which gives you a starting skeleton: +- `Chart.yaml`: mandatory. `type` field can be `application` (deployed standalone), or `library` (deployed as dependencies of other apps). + - dependencies may include `tags` (list of labels) and `conditions` (one or more YAML paths, and the chart can be enabled/disabled based on their values in the top-level `values.yaml`) +- `templates/`: YAML template files defined with the syntax of Go templates. You can see what's generated with e.g. `helm install --dry-run --debug <chart-path> --generate-name` +- `service.yaml`: uses Helm-specific objects `.Chart` (metadata like name and version) and `.Values` (exposes config that can be set at `helm install` time using `--set yaml.path=value`) + - `.Values` can come from the chart's `values.yaml` or that of a parent chart, or a values flag passed via `helm install -f newvalues.yaml`, or individual values passed via `helm install --set path=value` + +Then, you can install it with `helm install <release-name> <chart-dir>`, and see that it's installed with `helm ls`. + +To package it, do `helm package <chart-dir>`. +You can upgrade a release with `helm upgrade <release-name> <chart-package-tgz>`, and downgrade with `helm rollback <release-name> <revision>`.