Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Pipe kubectl-run not updating LABELS

Andrew Male December 6, 2021

Hi

Our build process has a Pipe defined that uses `kubectl-run` to update a Deployment with a new image (built in the previous Pipelines step) and to then update labels on that Deployment with version information (the $BITBUCKET_COMMIT ENV).

The Deployment's image is updated correctly but the labels on the Deployment do not change.

There are no errors in the Pipelines log window or within the Pod's event log.

In the Pipelines log output I can see the part of the `docker run` command for `kubectl-run` with the relevant arguments are all correct:

...
--env=KUBECTL_COMMAND="set image deployment/APPNAME APPNAME=GROUP/IMAGE:$BITBUCKET_COMMIT" \

--env=KUBE_CONFIG="$KUBECONFIG_QA" \
--env=LABELS_0="DD_TAGS=version:$BITBUCKET_COMMIT" \
--env=LABELS_1="VERSION=$BITBUCKET_COMMIT" \
--env=LABELS_COUNT="2" \
...

When I inspect the Deployment the `DD_TAGS` and `VERSION` labels have not been updated.

Is there some additional config that needs to be done within my Pipe to get this to work?

Regards
Andrew

2 answers

1 accepted

0 votes
Answer accepted
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 23, 2021

@Andrew Male hi. According to k8s managing resources labels update works only with 

KUBECTL_COMMAND='apply'

command.

So if you want update labels your should use something like this:

script:
# execute pipe with your custom command
- pipe: atlassian/kubectl-run:3.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG
KUBECTL_COMMAND: '<your custom command>'
...
script
:
# update labels here - pipe: atlassian/kubectl-run:3.1.2 variables: KUBE_CONFIG: $KUBE_CONFIG KUBECTL_COMMAND: 'apply' RESOURCE_PATH: '<your path.yml>' LABELS: - 'label1=value1' - 'label2=value2'

 We will update the pipe README to point that labels update should be used only with `apply` command.

Regards, Igor

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 10, 2021

@Andrew Male  hi. Thanks for your question. We will investigate this and notify you about the results.

 

Regards, Igor.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events