Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't use kubectl patch using atlassian/azure-aks-deploy

heldersatin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 3, 2021

Hello everyone,

 

I'm trying to use a kubectl patch command to update a deployment by changing a metadata label on my deployment, the command i'm using is this one:

kubectl patch deployment my-deployment -n my-namespace -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"redeploy\":\"55\"}}}}}'

When running it on power shell it works perfectly but when i add it to my pipeline i get all sorts of errors, currently my step is as follows:

 

- pipe: atlassian/azure-aks-deploy:1.0.2
              variables:
                AZURE_APP_ID: $AZURE_APP_ID
                AZURE_PASSWORD: $AZURE_PASSWORD
                AZURE_TENANT_ID: $AZURE_TENANT_ID
                AZURE_AKS_NAME: $AKS_CLUSTER_NAME
                AZURE_RESOURCE_GROUP: $AKS_RESOURCE_GROUP
                KUBECTL_COMMAND: 'patch deployment my-deployment'
                KUBECTL_ARGUMENTS: '-n my-namespace -p ''{\\"spec\\":{\\"template\\":{\\"metadata\\":{\\"labels\\":{\\"redeploy\\":\\"$BITBUCKET_BUILD_NUMBER\\"}}}}}'''

But the output of the pipeline is
INFO: running kubectl command patch deployment my-deployment using generic handler
kubectl patch deployment my-deployment -n my-namespace -p '{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"redeploy\":\"55\"}}}}}'
Error from server (BadRequest): json: cannot unmarshal string into Go value of type map[string]interface {}
I've tried scaping that string in all sorts of ways but nothing works, even tried using the yaml style for the patch command with the same outcome. Is there something obvious i'm missing here?

1 answer

1 accepted

2 votes
Answer accepted
heldersatin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 3, 2021

Answering my own question, it seems that the kubectl version being using a little far behind the current version, so the correct syntax was:

 

pipeatlassian/azure-aks-deploy:1.0.2
              variables:
                AZURE_APP_ID$AZURE_APP_ID
                AZURE_PASSWORD$AZURE_PASSWORD
                AZURE_TENANT_ID$AZURE_TENANT_ID
                AZURE_AKS_NAME$AKS_CLUSTER_NAME
                AZURE_RESOURCE_GROUP$AKS_RESOURCE_GROUP
                KUBECTL_COMMAND'patch deployment my-deployment'
                KUBECTL_ARGUMENTS'-n my-namespace -p {"spec":{"template":{"metadata":{"labels":{"redeploy":"$BITBUCKET_BUILD_NUMBER"}}}}}'

Just had to remove the backslashes and the extra single quotes that marked the patch string

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events