Exercise 5.1: Configure the Deployment: ConfigMaps
{ cd && mkdir primary echo c > primary/cyan echo m > primary/magenta echo y > primary/yellow echo k > primary/black echo "known as key" >> primary/black echo blue > favorite }kubectl create configmap colors \ --from-literal=text=black \ --from-file=./favorite \ --from-file=./primary/kubectl get cm colorskubectl get cm colors -o yamlcat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx env: - name: ilike valueFrom: configMapKeyRef: name: colors key: favorite EOFkubectl exec shell-demo -- /bin/bash -c 'echo $ilike'kubectl delete pod shell-democat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx envFrom: - configMapRef: name: colors EOFkubectl exec shell-demo -- /bin/bash -c 'env'kubectl delete pod shell-democat <<EOF | kubectl create -f - apiVersion: v1 kind: ConfigMap metadata: name: fast-car namespace: default data: car.make: Ford car.model: Mustang car.trim: Shelby EOFkubectl get cm fast-car -o yamlcat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx volumeMounts: - name: car-vol mountPath: /etc/cars volumes: - name: car-vol configMap: name: fast-car EOFkubectl exec shell-demo -- ls /etc/carskubectl exec shell-demo -- /bin/bash -c 'cat /etc/cars/car.trim; echo'kubectl delete pod shell-democat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: shell-demo spec: containers: - name: nginx image: nginx volumeMounts: - name: car-vol mountPath: /etc/cars readinessProbe: exec: command: - ls - /etc/cars periodSeconds: 5 volumes: - name: car-vol configMap: name: fast-car EOFkubectl get pod shell-demo{ kubectl delete pod shell-demo kubectl delete cm fast-car colors }
PreviousCHAPTER 5. DEPLOYMENT CONFIGURATIONNextExercise 5.2: Configure the Deployment: Attaching Storage
Last updated