You use the kubectl create
command to imperatively create objects. Don’t use it for Pods or Deployments - YAML is a much better option - but it can work well for ConfigMaps.
The easiest option is to specify the key and value for environment variable settings as a literal:
kubectl create configmap configurable-env-lab --from-literal=Configurable__Release='21.04-lab'
kubectl describe cm configurable-env-lab
Alternatively store the values in a .env file - like configurable.env. This is not the same as storing the config in YAML, because it’s the native format and can be used outside of Kubernetes.
You’ll need to delete the literal ConfigMap to try this - that’s why desired state in YAML is a better option:
kubectl delete configmap configurable-env-lab
kubectl create configmap configurable-env-lab --from-env-file=labs/aks/configmaps/solution/configurable.env
kubectl describe cm configurable-env-lab
kubectl create configmap configurable-override-lab --from-file=labs/aks/configmaps/solution/override.json
kubectl describe cm configurable-override-lab
kubectl apply -f labs/aks/configmaps/specs/configurable/lab/
Browse to your Service and you should see the configured settings from the expected sources
Back to the exercises.