I think this is related to powershell issue as it has worked on my mac (bash script).
Here's the one working in bash:
kubectl create secret docker-registry gcr-json-key \
--docker-server=asia.gcr.io \
--docker-username=_json_key \
--docker-password="$(cat ./deploy/service-account.json)" \
--docker-email=email@company.com.au
Here's one in powershell:
$key=$(Get-Content ./deploy/service-account.json)
kubectl create secret docker-registry 'gcr-json-key' `
--docker-server='asia.gcr.io' `
--docker-username='_json_key' `
--docker-password=$key `
--docker-email='email@company.com.au'
What could be wrong? is it because the quote is escaped in powershell when reading json file? I also realised that the kubectl
script started giving error: exactly one NAME is required, got 5
when i included --docker-password
with json content.
I tried a couple of things that didn't work as well such as putting flags to variable and tried escaping the quote in the json (assuming if that's the issue):
$param="--docker-server='asia.gcr.io' `
--docker-username='_json_key' `
--docker-password='$key' `
--docker-email='email@company.com.au'"
kubectl create secret docker-registry 'gcr-json-key' $param