For simulated Practice problems visit KillerCoda.
-
Solution
k create configmap myconfig --from-literal=var1=val1
-
echo "username=admin" > user.txt
Solution
k create configmap fileconfig --from-file=userdetails=user.txt
-
create
gconfig
configmap withability=thunder
. Run a pod namedaries
withnginx
image having env variable namedpower
getting value fromability
key ofgconfig
configmap.Solution
# create configmap k create configmap gconfig --from-literal=ability=thunder # generate pod yaml file $dr(export dr="--dry-run=client -o yaml") k run aries --image=nginx $dr > pod.yaml # modify pod.yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: aries name: aries spec: containers: - image: nginx name: aries env: - name: power valueFrom: configMapKeyRef: name: gconfig key: ability dnsPolicy: ClusterFirst restartPolicy: Always status: {} # to check the env variable k exec aries -ti -- env
-
create
tconfig
configmap withvar9=val9
. Run a pod namedtarz
withnginx
image having mountingtconfig
as a volume at path/delta
and namecore
. Do all these intaurus
namespace.Solution
# create the ns k create ns taurus # set it as default namespace k config set-context --current --namespace=taurus # create configmap k create configmap tconfig --from-literal=var9=val9 # generate pod yaml file $dr(export dr="--dry-run=client -o yaml") k run tarz --image=nginx $dr > pod.yaml # modify pod.yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: tarz name: tarz spec: volumes: - name: core configMap: name: tconfig containers: - image: nginx name: tarz volumeMounts: - name: core mountPath: /delta dnsPolicy: ClusterFirst restartPolicy: Always status: {}