Update service-accounts.md

Added an automated code snippet to populate the registrykey on a serviceaccount using jq.
This commit is contained in:
cwitte4191
2017-02-03 13:52:34 -06:00
committed by mengyuan
parent 601fd27c56
commit 380fc42886
+11 -1
View File
@@ -147,8 +147,18 @@ NAME TYPE DATA
myregistrykey kubernetes.io/.dockerconfigjson 1
```
Next, read/modify/write the service account for the namespace to use this secret as an imagePullSecret
Next, read/modify/write the service account for the namespace to use this secret as an imagePullSecret.
Automated version using json and the jq utility:
```shell
kubectl get serviceaccounts default -o json |
jq 'del(.metadata.resourceVersion)'|
jq 'setpath(["imagePullSecrets"];[{"name":"myregistrykey"}])' |
kubectl replace serviceaccount default -f -
```
Interactive version requiring manual edit:
```shell
$ kubectl get serviceaccounts default -o yaml > ./sa.yaml
$ cat sa.yaml