From 9e16c8ca500ff9999ee15a9419900b21c07aa6ce Mon Sep 17 00:00:00 2001 From: Alex Lundberg <34074700+lundbird@users.noreply.github.com> Date: Thu, 28 Nov 2019 18:38:05 -0500 Subject: [PATCH] Add example for replicas in kustomization.yaml --- examples/replicas.md | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 examples/replicas.md diff --git a/examples/replicas.md b/examples/replicas.md new file mode 100644 index 000000000..ed1665c00 --- /dev/null +++ b/examples/replicas.md @@ -0,0 +1,67 @@ +# Demo: change replicas + + +Define a place to work: + + +``` +DEMO_HOME=$(mktemp -d) +``` + +Make a `kustomization` containing a deployment resource with replicas + + +``` +cat <$DEMO_HOME/kustomization.yaml +resources: +- deployment.yaml +replicas: +- name: myapp + count: 3 +EOF +``` + +Declare the deployment resource + + +``` +cat <$DEMO_HOME/pod.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: myapp + name: myapp +spec: + replicas: 1 + selector: + matchLabels: + app: myapp + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: myapp-container + image: busybox:1.29.0 +EOF +``` + +The `myapp` resource declares an deployment managing a pod running a busybox container. + + +Now build this `kustomization` + +``` +kustomize build $DEMO_HOME +``` + +Confirm that this replaces replicas for myapp: + + +``` +test 3 = \ + $(kustomize build $DEMO_HOME | grep replicas | awk '{print $2}); \ + echo $? +```