$ run as a normal user# run as root (or with sudo)
Skills in this chapter
- Install components with Helm and Kustomize; understand CRDs and operators
Install a chart with Helm
A chart is a package of templates; a release is an installed chart with your values.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm search repo ingress-nginx
helm show values ingress-nginx/ingress-nginx > values.yaml
helm install ingress ingress-nginx/ingress-nginx -n ingress-nginx --create-namespace --set controller.replicaCount=2
helm list -A
helm status ingress -n ingress-nginxUpgrade and roll back a release
Every change is a new revision; roll back to any old one.
helm upgrade ingress ingress-nginx/ingress-nginx -n ingress-nginx -f values.yaml
helm history ingress -n ingress-nginx
helm rollback ingress 1 -n ingress-nginx
helm template ingress ingress-nginx/ingress-nginx -f values.yaml > rendered.yaml
helm uninstall ingress -n ingress-nginx| Command | Does |
|---|---|
helm install NAME CHART | Install a new release |
helm upgrade --install | Install or upgrade (good in pipelines) |
-f values.yaml, --set k=v | Your values |
helm get values NAME | The values in use |
helm template | Render YAML without installing |
helm rollback NAME REV | Go back to a revision |
Change YAML with Kustomize
A kustomization.yaml lists resources and changes (name prefix, labels, image tags, patches). kubectl apply -k builds and applies it.
resources:
- deployment.yaml
- service.yamlresources:
- ../../base
namespace: shop-prod
namePrefix: prod-
labels:
- pairs: { env: prod }
images:
- name: ghcr.io/s0sta/shop
newTag: "1.4.0"
patches:
- target: { kind: Deployment, name: web }
patch: |-
- op: replace
path: /spec/replicas
value: 4Understand CRDs and operators
A CustomResourceDefinition adds a new object type to the API (for example Certificate from cert-manager). An operator is a controller that watches those objects and does the work.