Last active
March 15, 2020 04:39
-
-
Save superbrothers/a4958b30ddbb82aa38dd1f53d9d7eb01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ kubectl version | |
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-18T23:30:10Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"darwin/amd64"} | |
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-02-07T01:05:17Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"} | |
$ kubectl create configmap env-config --from-literal=log_level=INFO | |
configmap/env-config created | |
$ cat <<EOL | kubectl create -f - | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
run: nginx | |
name: nginx | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
run: nginx | |
template: | |
metadata: | |
labels: | |
run: nginx | |
spec: | |
containers: | |
- image: nginx | |
name: nginx | |
env: | |
- name: LOG_LEVEL | |
valueFrom: | |
configMapKeyRef: | |
name: env-config | |
key: log_level | |
EOL | |
$ kubectl patch deploy nginx --patch "$(cat <<'EOL' | |
{ | |
"spec": { | |
"template": { | |
"spec": { | |
"containers": [ | |
{ | |
"name": "nginx", | |
"env": [ | |
{ | |
"name": "LOG_LEVEL", | |
"value": "INFO", | |
"valueFrom": { | |
"$patch": "delete" | |
} | |
} | |
] | |
} | |
] | |
} | |
} | |
} | |
} | |
EOL | |
)" | |
The Deployment "nginx" is invalid: spec.template.spec.containers[0].env[0].valueFrom: Invalid value: "": must specify one of: `fieldRef`, `resourceFieldRef`, `configMapKeyRef` or `secretKeyRef` | |
$ kubectl patch deploy nginx --patch "$(cat <<'EOL' | |
{ | |
"spec": { | |
"template": { | |
"spec": { | |
"containers": [ | |
{ | |
"name": "nginx", | |
"env": [ | |
{ | |
"name": "LOG_LEVEL", | |
"value": "INFO", | |
"valueFrom": null | |
} | |
] | |
} | |
] | |
} | |
} | |
} | |
} | |
EOL | |
)" | |
deployment.apps/nginx patched | |
$ kubectl get deploy nginx -o jsonpath='{.spec.template.spec.containers[*].env}' | |
[map[name:LOG_LEVEL value:INFO]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment