In Kubernetes any configuration of an application component which varies between environments must be passed into the relevant containers from outside. This can happen either
- by directly passing values as environment variables (such values can be provided explicitly or fetched from ConfigMaps or Secrets) or
- by using file-based ConfigMaps to mount config files in the relevant locations of a containers file system
It should never be necessary to open a shell in a container in order to set some configuration options before an application component is started.
Two NGINX deployments. One obtains its config via a ConfigMap mounted as a volume. The other one obtains parts of its config via environment variables. In the latter case, one environment variable is set explicitly, another one is read from a ConfigMap.
Use the following command to apply the deployments
kubectl apply -f examples/Check the pods and remember their IP addresses
kubectl get pods -o wideMake requests the nginx instances and check the outputs
kubectl run curl --image=curlimages/curl -i --tty --rm --restart=Never -- <Pod 1 IP>
kubectl run curl --image=curlimages/curl -i --tty --rm --restart=Never -- <Pod 2 IP>Use the following command to delete the deployments
kubectl delete -f examples/