From 8597ca1956d93e4211dea25bd693a03ae998cd5e Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Wed, 24 Feb 2021 18:22:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20args=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slides/k8s/configuration.md | 40 +++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/slides/k8s/configuration.md b/slides/k8s/configuration.md index c37238d2..1effd876 100644 --- a/slides/k8s/configuration.md +++ b/slides/k8s/configuration.md @@ -60,21 +60,41 @@ ## Command-line arguments -- Pass options to `args` array in the container specification +- Indicate what should run in the container -- Example ([source](https://github.com/coreos/pods/blob/master/kubernetes.yaml#L29)): +- Pass `command` and/or `args` in the container options in a Pod's template + +- Both `command` and `args` are arrays + +- Example ([source](https://github.com/jpetazzo/container.training/blob/main/k8s/consul-1.yaml#L70)): ```yaml - args: - - "--data-dir=/var/lib/etcd" - - "--advertise-client-urls=http://127.0.0.1:2379" - - "--listen-client-urls=http://127.0.0.1:2379" - - "--listen-peer-urls=http://127.0.0.1:2380" - - "--name=etcd" + args: + - "agent" + - "-bootstrap-expect=3" + - "-retry-join=provider=k8s label_selector=\"app=consul\" namespace=\"$(NS)\"" + - "-client=0.0.0.0" + - "-data-dir=/consul/data" + - "-server" + - "-ui" ``` -- The options can be passed directly to the program that we run ... +--- - ... or to a wrapper script that will use them to e.g. generate a config file +## `args` or `command`? + +- Use `command` to override the `ENTRYPOINT` defined in the image + +- Use `args` to keep the `ENTRYPOINT` defined in the image + + (the parameters specified in `args` are added to the `ENTRYPOINT`) + +- In doubt, use `command` + +- It is also possible to use *both* `command` and `args` + + (they will be strung together, just like `ENTRYPOINT` and `CMD`) + +- See the [docs](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes) to see how they interact together ---