当前位置:   article > 正文

k8s部署jenkins

k8s部署jenkins

部署pvc

修改jenkins-pvc.yaml 文件中的信息,然后应用YAML文件

cat > /opt/k8s/jenkins/jenkins-pvc.yaml <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-data-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "nfs-storage"
  resources:
    requests:
      storage: 5Gi
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
kubectl apply -f jenkins-pvc.yaml 
kubectl get pvc
  • 1
  • 2

部署Deployment

修改jenkins-Deployment.yaml文件中的信息,然后应用YAML文件

cat > /opt/k8s/jenkins/jenkins-Deployment.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      containers:
      - name: jenkins
        image:  jenkins/jenkins:2.451-jdk17
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: jenkins-data
          mountPath: /jenkins
      volumes:
      - name: jenkins-data
        persistentVolumeClaim:
          claimName: jenkins-data-pvc
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
kubectl apply -f jenkins-Deployment.yaml 
kubectl get Deployment
  • 1
  • 2

部署Service

修改jenkins-Service.yaml文件中的信息,然后应用YAML文件

cat > /opt/k8s/jenkins/jenkins-Service.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 30080
  selector:
    app: jenkins
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
kubectl apply -f jenkins-Service.yaml 
kubectl get Service
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/518415
推荐阅读
相关标签
  

闽ICP备14008679号