본문 바로가기

리눅스

[kubernetes] Jenkins 설치 방법

반응형

Jenkins 설치 방법

 

jenkins 네임스페이스 생성

$ kubectl create namespace jenkins

 

jenkins.yaml 파일 편집

$ vim 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: {}

 

deployment 생성

$ kubectl create -f jenkins.yaml --namespace jenkins
deployment.apps/jenkins created

 

포드 상태 확인

$ kubectl get pods -n jenkins
NAME                       READY   STATUS    RESTARTS   AGE
jenkins-794699f9bc-pwtrh   1/1     Running   0          64s

 

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

 

서비스 생성

$ kubectl create -f jenkins-service.yaml --namespace jenkins
service/jenkins created
service/jenkins-jnlp created

 

서비스 확인

$ kubectl get services --namespace jenkins
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
jenkins        NodePort    10.98.152.104   <none>        8080:30000/TCP   12s
jenkins-jnlp   ClusterIP   10.110.21.239   <none>        50000/TCP        12s

 

포드 네임 확인 후 로그에서 관리자 패스워드 확인

$ kubectl get pods -n jenkins
NAME                       READY   STATUS    RESTARTS   AGE
jenkins-794699f9bc-pwtrh   1/1     Running   0          17m

$ kubectl logs jenkins-794699f9bc-pwtrh -n jenkins
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
...
2020-11-03 05:26:51.191+0000 [id=25]	INFO	jenkins.install.SetupWizard#init:

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

73d1cc2ba7db4c9c996b573431d86d3b

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

...
2020-11-03 05:27:08.939+0000 [id=39]	INFO	hudson.model.AsyncPeriodicWork#lambda$doRun$0: Finished Download metadata. 19,740 ms

 

jenkins 웹 UI

 

원본 URL : https://www.digitalocean.com/community/tutorials/how-to-install-jenkins-on-kubernetes

 

How To Install Jenkins on Kubernetes | DigitalOcean

Jenkins is a widely-used open source automation server that can set up CI/CD pipelines. In this tutorial, we will install Jenkins on Kubernetes. To demonstrate its power and ease of use, we will then access the Jenkins UI and run a sample pipeline.

www.digitalocean.com

 

 

728x90
반응형