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,362,011
Community Members
 
Community Events
168
Community Groups

Pipeline fails

 

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

@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.

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?

@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
"""

 

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"

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,502 views 3 10
Read article

Atlassian Community Events