部署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
kubectl apply -f jenkins-pvc.yaml 
kubectl get pvc

部署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
kubectl apply -f jenkins-Deployment.yaml 
kubectl get Deployment

部署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
kubectl apply -f jenkins-Service.yaml 
kubectl get Service
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐