IT
[K8S] 쿠버네티스로 Jenkins 설치하기
뽀리님
2023. 12. 18. 14:41
실행환경
MacOS - M1
Docker
1. jenkins 네임스페이스 생성
MacBookAir KbTest % kubectl create namespace jenkins
2. jenkins.yaml 파일 생성
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
ports:
- name: http-port
containerPort: 8080
- name: jnlp-port
containerPort: 50000
volumeMounts:
- name: jenkins-vol
mountPath: /var/jenkins_vol
volumes:
- name: jenkins-vol
emptyDir: {}
3. deployment 생성
MacBookAir KbTest % kubectl create -f jenkins.yaml
4. http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/deployment?namespace=default
에서 생성확인
5. jenkins-service.yaml 파일 생성
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30000
selector:
app: jenkins
---
apiVersion: v1
kind: Service
metadata:
name: jenkins-jnlp
spec:
type: ClusterIP
ports:
- port: 50000
targetPort: 50000
selector:
app: jenkins
6. 서비스 Deployment 생성
MacBookAir KbTest % kubectl create -f jenkins-service.yaml
포드 네임 확인 후 로그에서 관리자 패스워드 확인
MacBookAir KbTest % kubectl get pods -n default
NAME READY STATUS RESTARTS AGE
hasample-66cb55687f-s5cz6 1/1 Running 0 17m
jenkins-97fb8547b-9rl2w 1/1 Running 0 4m40s
MacBookAir KbTest % kubectl logs jenkins-97fb8547b-9rl2w -n default
localhost:30000 으로 접속후 플러그인 설치
참조