Helm으로 Jenkins 설치하기

Jenkins 레포지토리 추가

$ helm repo add jenkinsci https://charts.jenkins.io $ helm repo update

Helm value 얻기

$ helm show values jenkinsci/jenkins > jenkins-values.yaml

jekins-values.yaml 수정

Ingress를 사용하기 위한 설정

... jenkinsUriPrefix: "/jenkins" # 주석 해제 ...

NodePort를 사용하기 위한 설정

...
serviceType: ClusterIP # NodePort로 수정
nodePort: 32766 # 추가
...

Jenkins 설치

$ helm install jenkins jenkinsci/jenkins --create-namespace --namespace jenkins -f jenkins-values.yaml

Jenkins 업그레이드

jekins-values.yaml 파일 수정 후, 변경된 설정으로 젠킨스 재실행

$ helm upgrade jenkins jenkinsci/jenkins --namespace jenkins -f jenkins-values.yaml

초기 유저 admin의 비밀번호 얻기

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

참고: Jenkins 삭제

$ helm delete -n jenkins jenkins

참고: Jenkins - Harbor 연동

Jenkins 관리 > Manage Credencials > System > Global credentials (unrestricted) > Add Credencials 클릭

  • 세부 설정 ID는 나중에 파이프라인에서 인식할 수 있는 credentials의 ID이기에 Harbor로 기입하고 username은 구축한 harbor의 계정, pw는 말그대로 harbor계정의 pw를 입력한다. Description은 harbor credentials라는것을 이해할 수 있게끔 임의로 한다.

참고: Jenkins - 로그 확인

kubectl logs -f jenkins-0 -c init -n jenkins

참고: 실행 결과

NAME: jenkins
LAST DEPLOYED: Sun Jul  2 14:44:33 2023
NAMESPACE: jenkins
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:
  kubectl exec --namespace jenkins -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo
2. Get the Jenkins URL to visit by running these commands in the same shell:
  export NODE_PORT=$(kubectl get --namespace jenkins -o jsonpath="{.spec.ports[0].nodePort}" services jenkins)
  export NODE_IP=$(kubectl get nodes --namespace jenkins -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT

3. Login with the password from step 1 and the username: admin
4. Configure security realm and authorization strategy
5. Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file, see documentation: http://$NODE_IP:$NODE_PORT/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/