1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: cm-envfrom spec: containers: - name: app image: busybox:1.36 command: ["sh", "-c", "echo DB_HOST=\$DB_HOST DB_PORT=\$DB_PORT; sleep 3600"] envFrom: - configMapRef: name: db-env EOF
kubectl logs cm-envfrom
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: cm-valuefrom spec: containers: - name: app image: busybox:1.36 command: ["sh", "-c", "echo ENV=\$APP_ENV DEBUG=\$APP_DEBUG; sleep 3600"] env: - name: APP_ENV valueFrom: configMapKeyRef: name: app-config key: APP_ENV - name: APP_DEBUG valueFrom: configMapKeyRef: name: app-config key: APP_DEBUG EOF
kubectl logs cm-valuefrom
cat <<EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: cm-volume spec: containers: - name: app image: busybox:1.36 command: ["sh", "-c", "cat /etc/config/nginx.conf; sleep 3600"] volumeMounts: - name: config mountPath: /etc/config volumes: - name: config configMap: name: nginx-conf EOF
kubectl logs cm-volume
kubectl exec cm-volume -- ls -la /etc/config/ kubectl exec cm-volume -- cat /etc/config/nginx.conf
kubectl delete pod cm-envfrom cm-valuefrom cm-volume
|