Deploying helm chart in Kubernetes with Jenkins

  • I installed my jenkins using this guide:
  • And also I created the service account according to the article:

kubectl apply -f jenkins-sa.yaml

  • My pipelines is in it github repo:

But When I execute my pipeline I got it error:

  • helm upgrade --install --wait --set ‘image.tag=22’ node-app-chart ./k8s/node-app-chart

Release “node-app-chart” does not exist. Installing it now.

Error: rendered manifests contain a resource that already exists. Unable to continue with install: could not get information about the resource ServiceAccount “node-app-chart” in namespace “jenkins”: serviceaccounts “node-app-chart” is forbidden: User “system:serviceaccount:jenkins:jenkins” cannot get resource “serviceaccounts” in API group “” in the namespace “jenkins”

script returned exit code 1

I am using minikube, helm v3, docker hub, github. The repo is public.

Any idea?

Thanks in advance.

Jose

The jenkins service account doesn’t have access to deploy.

Update the account in kubernetes or use a different account.

Hi @halkeye , I used it configuration suggested in the same article: https://raw.githubusercontent.com/jenkins-infra/jenkins.io/master/content/doc/tutorials/kubernetes/installing-jenkins-on-kubernetes/jenkins-sa.yaml .
Today I applied a rolebinding:

kubectl create rolebinding jenkins-admin --clusterrole=admin --serviceaccount=jenkins:jenkins --namespace=jenkins -o yaml

But the command failed with other error:

  • helm upgrade --install --wait --set ‘image.tag=26’ node-app-chart ./k8s/node-app-chart

Error: UPGRADE FAILED: timed out waiting for the condition

script returned exit code 1

The result is now:

❯ kubectl get po -n jenkins
NAME READY STATUS RESTARTS AGE
jenkins-0 2/2 Running 8 (33m ago) 2d
node-app-chart-78bc5df479-dqnbt 1/1 Running 0 7m51s
node-app-chart-78bc5df479-gpqdq 1/1 Running 0 7m53s
❯ helm list -n jenkins
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
jenkins jenkins 1 2023-02-10 19:02:52.978852 -0500 -05 deployed jenkins-4.3.1 2.375.2
node-app-chart jenkins 2 2023-02-13 00:15:35.872790934 +0000 UTC failed node-app-chart-0.1.0 1.17.0

What is missing?

Joe

I observed that created a new service account using the name of my chart:

❯ kubectl get serviceaccount -n jenkins
NAME SECRETS AGE
default 0 13d
jenkins 0 2d
node-app-chart 0 15m

:frowning:

Joe

This is more kubernetes knowledge than I have sorry. It sounds like you followed a tutorial on how to install jenkins, then using it to install an entirely different helm chart, and having issues.

I don’t think the service account that jenkins uses has access to deploy other things, but I have no idea what you’ve done.

I could do that works!!

  1. In values.yamls

serviceAccount: # Specifies whether a service account should be created create: false

No create service account. Because it’s trying to create a service account with the name of the chart.

  1. In jenkinsfile change the command to:

sh “helm upgrade --install --namespace jenkins {HELM_APP_NAME} --set image.tag={BUILD_NUMBER} ./${HELM_CHART_DIRECTORY}”

Thanks for your time.