Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,385
Community Members
 
Community Events
168
Community Groups

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

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

1 vote
Answer accepted

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

Atlassian Community Events