ㅡ.ㅡ

[Jenkins] Jenkins 본문

WorkFlow

[Jenkins] Jenkins

ekwkqk12 2021. 9. 26. 22:35

EBS 생성

Jenkins의 데이터를 저장할 볼륨을 생성하는 과정으로 Jenkins가 설치될 노드가 생성되는 영역과 일치 시켜줘야 pod 생성 시 볼륨이 연결된다. EBS는 단일 노드에서만 사용할 수 있어 멀티 노드에서 볼륨을 공유하여 사용할 시 EFS나 NFS를 고려해봐야한다.

export VOLUME_ID=$(aws ec2 create-volume --size 20 \
--region ap-northeast-2 \
--availability-zone ap-northeast-2a \
--volume-type gp2 \
--tag-specifications 'ResourceType=volume, Tags=[{Key=Name,Value=EKS-Jenkins}]' \
| jq '.VolumeId' -r)

Jenkins Chart 다운로드 및 네임스페이스 생성

helm repo add jenkinsci https://charts.jenkins.io
helm repo update
helm pull jenkinsci/jenkins --untar
kubectl create namespace jenkins

Jenkins Chart 수정

PV 생성

jenkins/template/jenkins-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-pv
  namespace: jenkins
spec:
  storageClassName: jenkins-pv
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 20Gi
  persistentVolumeReclaimPolicy: Retain
  awsElasticBlockStore:
    volumeID: 생성된 볼륨 ID

기타 설정
48 : 계정 비밀번호 설정
95 : Prefix 설정(/jenkins 주소 사용)
122, 127 : ALB 헬스체크 PATH설정
160, 170 : 상태체크 시작 시간 수정
230 ~ 237 : 플러그인 추가
387 : 생성 노드 그룹 지정
576 ~ 607: agent설정 jdk11 이미지 지정 및 리소스 수정(DooD)
752 : PVC와 매칭될 PV 이름지정
756 : 볼륨 크기 지정

jenkins/values.yaml

46   # you should revert controller.adminUser to your preferred admin user:
47   adminUser: "admin"
48     adminPassword: "비밀번호"

94   # If you set this prefix and use ingress controller then you might want to set the ingress path below
95   jenkinsUriPrefix: "/jenkins"

120   # For minikube, set this to NodePort, elsewhere use LoadBalancer
121   # Use ClusterIP if your setup includes ingress controller
122   serviceType: ClusterIP
123   # Use Local to preserve the client source IP and avoids a second hop for LoadBalancer and Nodeport type services,
124   # but risks potentially imbalanced traffic spreading.
125   serviceExternalTrafficPolicy:
126   # Jenkins controller service annotations
127   serviceAnnotations: {alb.ingress.kubernetes.io/healthcheck-path: /jenkins}

158       # If Startup Probe is not supported on your Kubernetes cluster, you might want to use "initialDelaySeconds" instead.
159       # It delays the initial liveness probe while Jenkins is starting
160       initialDelaySeconds: 60

168       # If Startup Probe is not supported on your Kubernetes cluster, you might want to use "initialDelaySeconds" instead.
169       # It delays the initial readyness probe while Jenkins is starting
170       initialDelaySeconds: 60

231   installPlugins:
232     - kubernetes:1.30.1
233     - workflow-aggregator:2.6
234     - git:4.8.2
235     - configuration-as-code:1.52
236     - gitlab-plugin:1.5.20
237     - sonar:2.13.1
238     - generic-webhook-trigger:1.77
239     - amazon-ecr:1.6
240     - aws-credentials:1.31
241     - docker-workflow:1.26

387   nodeSelector: {alpha.eksctl.io/nodegroup-name: mng-ng}
389   terminationGracePeriodSeconds:
391   terminationMessagePath:
392   terminationMessagePolicy:

576 agent:
577   enabled: true
578   defaultsProviderTemplate: ""
579   # URL for connecting to the Jenkins contoller
580   jenkinsUrl:
581   # connect to the specified host and port, instead of connecting directly to the Jenkins controller
582   jenkinsTunnel:
583   kubernetesConnectTimeout: 5
584   kubernetesReadTimeout: 15
585   maxRequestsPerHostStr: "32"
586   namespace:
587   image: "jenkins/inbound-agent"
589   tag: "4.10-3-jdk11"

599   runAsUser: 0
600   runAsGroup:
601   resources:
602     requests:
603       cpu: "512m"
604       memory: "512Mi"
605     limits:
606       cpu: "1024m"
607       memory: "2048Mi"

752   storageClass: jenkins-pv
753   annotations: {}
754   labels: {}
755   accessMode: "ReadWriteOnce"
756   size: "20Gi"
757   volumes:
758   #  - name: nothing
759   #    emptyDir: {}
760   mounts:
761   #  - mountPath: /var/nothing
762   #    name: nothing
763   #    readOnly: true

설치 및 삭제

helm upgrade --install jenkins -n jenkins -f ./values.yaml ./
helm uninstall jenkins -n jenkins

'WorkFlow' 카테고리의 다른 글

[Argocd] Argocd, Argo-Rollouts  (0) 2021.09.29
[Jenkins] Gitlab Repo 연동  (0) 2021.09.28
[Gitlab] CD/Helm  (0) 2021.09.25
[Gitlab] CD/Kubectl  (0) 2021.09.25
[Gitlab] CI/ECR  (3) 2021.09.20