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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

552 views 15 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you