How to pass image pull secret while using 'kubectl run' command?

后端 未结 7 869
梦谈多话
梦谈多话 2020-12-24 11:16

I am trying to use kubectl run command to pull an image from private registry and run a command from that. But I don\'t see an option to specify image pull secret. It looks

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 11:41

    On Windows, you can do patch, but as it shows a JSON error, you have to do this trick (using PowerShell):

    > $imgsec=  '{"imagePullSecrets": [{"name": "myregistrykey"}]}' | ConvertTo-Json
    > kubectl patch serviceaccount default -p $imgsec
    

    Also , if you want to update/ append imagePullSecret , then you should be using something like this :

    > $imgsec=  '[{"op":"add","path":"/imagePullSecrets/-","value":{"name":"myregistrykey2"}}]' | ConvertTo-Json
    
    > kubectl patch serviceaccount default --type='json' -p  $imgsec
    

    .

提交回复
热议问题