관리 메뉴

피터의 개발이야기

[Helm] Helm으로 jenkins 설치하기 본문

Kubernetes/Helm

[Helm] Helm으로 jenkins 설치하기

기록하는 백앤드개발자 2022. 10. 1. 18:06
반응형

ㅁ 개요

 ㅇ EKS 업그레이드 작업 테스트를 하면서 프로젝트 내에서 젠킨스의 볼륨이 날아가는 일이 반복되었다.

 ㅇ 팀에서 백업에 관한 이야기가 나왔고, 그 방법에 대해서 고민하게 되었다.

 ㅇ 젠킨스 백업 테스트를 위해 젠킨스를 구성하고 백업 방법에 대해서 테스트를 진행하려 한다.

 ㅇ 빠른 구성을 위해 helm을 이용하여 빠른 구성과 테스트를 진행하려 한다.

 

 

ㅁ 레퍼런스 탐험

 

GitHub - jenkinsci/helm-charts: Jenkins community Helm charts

Jenkins community Helm charts. Contribute to jenkinsci/helm-charts development by creating an account on GitHub.

github.com

 ㅇ github의 다음 페이지를 참조하여 작업을 수행하였다.

 

 

helm repo 추가

$ helm repo add jenkins https://charts.jenkins.io
"jenkins" has been added to your repositories
$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "jenkins" chart repository
...Successfully got an update from the "fluent" chart repository
...Successfully got an update from the "prometheus-community" chart repository
...Successfully got an update from the "stable" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈

 

ㅁ helm value 얻기

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

 ㅇ 별도의 설정을 위해서  helm show 명령어를 통해 jenkins-values.yaml 파일은 내려 받았다.

 ㅇ value에 대한 자세한 정본는 여기를 참조하면 된다.

 

 

ㅁ Install Chart

$ helm install jenkins jenkins/jenkins -f jenkins-values.yaml
NAME: jenkins
LAST DEPLOYED: Sat Oct  1 02:00:57 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:
  kubectl exec --namespace default -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:
  echo http://127.0.0.1:8080
  kubectl --namespace default port-forward svc/jenkins 8080:8080

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:///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

 ㅇ User은 admin이고, PW를 어떻게 얻을 수  있는지 설명을 해 주고 있다.

 ㅇ minikube 환경이기 때문에  jenkins 접근을 위해 port-forward 를 사용해야한다.

 

 

 

ㅁ 구성된 Obecjt 확인

$ kubectl get all -l app.kubernetes.io/name=jenkins
NAME            READY   STATUS    RESTARTS   AGE
pod/jenkins-0   2/2     Running   0          10h

NAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
service/jenkins         ClusterIP   10.110.116.243   <none>        8080/TCP    10h
service/jenkins-agent   ClusterIP   10.101.198.74    <none>        50000/TCP   10h

NAME                       READY   AGE
statefulset.apps/jenkins   1/1     10h

 ㅇ 설치된 Obecjt들을 Lable을 통해 확인할 수 있다.

 

 

ㅁ Jenkins port-forward

 ㅇ Jenkins UI에 접속하기 위해서는 port-forward를 유지시켜주어야 한다.

 

 

ㅁ Jenkins Login

 ㅇ 아이디로 admin과 pwd를 입력한다.

 

 

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

 ㅇ 비밀번호는 위의 명령어를 실행하여 jenkins 내부에 지정된 비밀번호를 확인할 수 있다.

 

 ㅇ 로그인 후 메인화면이 나타난다.

 ㅇ 새로운 item을 클릭하여 새로운 프로젝트를 생성해 보자.

 

 

ㅁ 샘플 프로젝트 생성

 ㅇ 프로젝트 이름을 입력하고 Pipeline을 선택하여 OK버튼을 클릭한다.

 

 

ㅁ Sample Pipeline 생성

 ㅇ 샘플 Pipeline을 선택한 후 Apply를 클릭한다.

 

 

 

ㅁ Build

   ㅇ "지금 빌드"를 클릭한다.

 

 

 ㅇ 콘솔을 통해 빌드 과정을 확인할 수 있다.

 

 

 ㅇ 빌드 완료 후 프로젝트 화면이다.

 

 

 

ㅁ 함께 보면 좋은 사이트

 

젠킨스 파이프라인 정리 - 1. 파이프라인 샘플 만들기

안녕하세요? 이번 시간엔 젠킨스 파이프라인을 정리해보려고 합니다. 모든 코드는 Github에 있기 때문에 함께 보시면 더 이해하기 쉬우실 것 같습니다. 젠킨스의 파이프라인이란 연속적인 이벤트

jojoldu.tistory.com

 ㅇ 젠킨스 파이프라인 정리

 

 

jenkins를 kubernetes 에 구성하기

대부분의 CSP에서 ci/cd 관련한 상품들을 제공하고 있지만, 여전히 jenkins 사용자도 많은 것 같다.  그래서 jenkins 도 kubernetes 에 pod로 구성하고, 빌드도 네이버클라우드의 kubernetes 서비스(nks)를 통해

cleanupthedesk.tistory.com

 ㅇ jenkins deployment 와 service yaml을 이용한 jenkins 구성

반응형
Comments