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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 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.

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.
Sep 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
"""

 

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.
Sep 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.
Jul 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