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

Pipeline fails

Brad Vrabete September 28, 2021

 

The pipe configuration below fails:

 


             - echo "Kustomize the deployment"
            - pipeatlassian/aws-eks-kubectl-run:2.1.0 # runs kubectl apply -k against the specific folder; basically patching the initial files in base directory
              variables:
                AWS_ACCESS_KEY_ID"$AWS_DEV_ACCESS_KEY_ID"
                AWS_SECRET_ACCESS_KEY"$AWS_DEV_SECRET_ACCESS_KEY"
                AWS_DEFAULT_REGION"$AWS_DEV_DEFAULT_REGION"
                CLUSTER_NAME"$AWS_CLUSTER_NAME"
                KUBECTL_COMMAND"apply"
                KUBECTL_ARGS
                  - "--dry-run=server"
                RESOURCE_PATH"k8s/deploy/aws-dev"
                KUBECTL_APPLY_ARGS"-k"
                LABELS
                  - "test.label=Test-deployment"
                WITH_DEFAULT_LABELS"False"
                DEBUG"True"


The error is:

INFO: Successfully updated the kube config.
Traceback (most recent call last):
File "/pipe.py", line 47, in <module>
File "/root/.local/lib/python3.8/site-packages/kubectl_run/pipe.py", line 157, in run
self.handle_apply()
File "/root/.local/lib/python3.8/site-packages/kubectl_run/pipe.py", line 114, in handle_apply
self.update_labels_in_metadata(template_file, labels)
File "/root/.local/lib/python3.8/site-packages/kubectl_run/pipe.py", line 37, in update_labels_in_metadata
yaml_doc['metadata'].setdefault('labels', {}).update(labels)
TypeError: 'NoneType' object is not iterable


A label is defined so this should work. What can I do to fix it?

1 answer

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

@Brad Vrabete Hi. Thanks for your question.  This error can occur only if `LABELS` is empty. We will try investigate this case and give you feedback soon.


Regards, Igor.

Brad Vrabete September 29, 2021

Thanks, Igor. I tried to disable the labels as the branch name was longer than 63 characters accepted by Kubectl for a label. 

Now, if you can see the script, LABELS is definitely not empty:

LABELS
                  - "test.label=Test-deployment"
So how would label need to be defined?
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2021

@Brad Vrabete  Seems like you doing it right and the problem on our side. 

The only one temporary solution i can provide is to pass labels directly to your template file "k8s/deploy/aws-dev" under `kind: Deployment metadata`.
Example of the template:

template = """
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
<pass your custom labels here>
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:1.7.9
name: nginx
ports:
- containerPort: 80
"""

 

Brad Vrabete September 29, 2021

I actually found an easier way: 

 

  script:
            # shrink bitbucket branch name to less than 63 characters
            - branch="${BITBUCKET_BRANCH}"
            - export BITBUCKET_BRANCH=${branch:0:62}
            - pipeatlassian/aws-eks-kubectl-run:2.1.0 # runs kubectl apply -k against the specific folder; basically patching the initial files in base directory
              variables:
                AWS_ACCESS_KEY_ID"$AWS_DEV_ACCESS_KEY_ID"
                AWS_SECRET_ACCESS_KEY"$AWS_DEV_SECRET_ACCESS_KEY"
                AWS_DEFAULT_REGION"$AWS_DEV_DEFAULT_REGION"
                CLUSTER_NAME"$AWS_DEV_CLUSTER_NAME"
                KUBECTL_COMMAND"apply"
                KUBECTL_ARGS
                  - "--dry-run=server"
                RESOURCE_PATH"k8s/deploy/aws-dev"
                KUBECTL_APPLY_ARGS"-k"
                WITH_DEFAULT_LABELS"True"
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2021

Good to know you found a solution for your case. Anyway, thanks for your feedback about problem with LABELS you have found.

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2023

Hi @Brad Vrabete . The issue with LABELS fixed in aws-eks-kubectl-run:2.3.0 pipe .

Regards, Igor

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events