Skip to main content

Jenkins

Jenkins

apiVersion: v1
kind: Namespace
metadata:
  name: hyunsu-cicd
  labels:
    app.kubernetes.io/name: hyunsu-cicd
    app.kubernetes.io/part-of: hyunsu-cicd

---
    
kind: PersistentVolume
apiVersion: v1
metadata:
  name: jenkins-pv-volume
  namespace: hyunsu-cicd
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/data/tomcat/devops/jenkins/pv"

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-pv-claim
  namespace: hyunsu-cicd
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
  namespace: hyunsu-cicd
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_home
      volumes:
        - name: jenkins-vol
          persistentVolumeClaim:
            claimName: jenkins-pv-claim

---

apiVersion: v1
kind: Service
metadata:
  name: jenkins
  namespace: hyunsu-cicd
spec:
  type: LoadBalancer
  ports:
    - port: 8080
      targetPort: 8080
      nodePort: 30001
  selector:
    app: jenkins

---

apiVersion: v1
kind: Service
metadata:
  name: jenkins-jnlp
  namespace: hyunsu-cicd
spec:
  type: LoadBalancer
  ports:
    - port: 50000
      targetPort: 50000
  selector:
    app: jenkins