Helm 을 이용한 Jenkins 설치 - Kubernetes

목차

Jenkins 란

Erorr : You must be logged in to the server (Unauthorized)

참고

1. Repository 추가

helm repo add jenkins https://charts.jenkins.io

2. value.yaml 준비

Jenkins 버전 및 JDK 버전 설정

controller:
# Used for label app.kubernetes.io/component
componentName: "jenkins-controller"
image: "jenkins/jenkins"
# tag: "2.375.3-jdk11"
tagLabel: jdk11
imagePullPolicy: "Always"
imagePullSecretName:

StorageClass 지정

persistence:
enabled: true
storageClass: jenkins-ebs
annotations: {}
labels: {}
accessMode: "ReadWriteOnce"
size: "8Gi"

3. Jenkins 설치

Jenkins 를 설치하고자 하는 Kubernetes 의 Namespace 와 Version 을 설정한 후 설치를 진행한다.

helm install jenkins jenkins/jenkins --version <version> -n <namespace>

Jenkins 가 정상적으로 설치되면 admin Passwrod 를 확인할 수 있는 방법과 포트포워딩을 통해 jenkins 에 접속하는 방법에 대한 설명이 나온다.

NAME: jenkins
LAST DEPLOYED: Tue Mar 7 15:11:52 2023
NAMESPACE: cicd
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:
kubectl exec --namespace cicd -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo
1. Get the Jenkins URL to visit by running these commands in the same shell:
echo http://127.0.0.1:8080
kubectl --namespace cicd port-forward svc/jenkins 8080:8080

1. Login with the password from step 1 and the username: admin
2. Configure security realm and authorization strategy
3. Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file, see documentation: http://127.0.0.1:8080/configuration-as-code and examples: https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos

For more information on running Jenkins on Kubernetes, visit:
https://cloud.google.com/solutions/jenkins-on-container-engine

For more information about Jenkins Configuration as Code, visit:
https://jenkins.io/projects/jcasc/


NOTE: Consider using a custom image with pre-installed plugins

4. Jenkins Admin Password 확인

kubectl exec -n cicd -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo

Jenkinsfile

Agent 추가

additionalAgents: 
maven:
podName: maven
customJenkinsLabels: maven
# An example of overriding the jnlp container
# sideContainerName: jnlp
image: jenkins/jnlp-agent-maven
tag: jdk11
node:
podName: node
customJenkinsLabels: maven
# An example of overriding the jnlp container
# sideContainerName: jnlp
image: jenkins/jnlp-agent-node
tag: latest
# python:
# podName: python
# customJenkinsLabels: python
# sideContainerName: python
# image: python
# tag: "3"
# command: "/bin/sh -c"
# args: "cat"
# TTYEnabled: true
Share