一,准备环境:

配置k8s,java17镜像,mysql5.6镜像

二,部署

1),jvb-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jvb-pv
  namespace: jvb
  labels:
    app: jvb-pv
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    path: /kube/jvb
    server: 192.168.142.137

2), jvb-pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jvb-pvc
  namespace: jvb
  labels:
    app: jvb-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  selector:
    matchLabels:
      app: jvb-pv

3), jvb-deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jvb-deploy
  namespace: jvb
  labels:
    app: jvb-deploy
spec:
  selector:
    matchLabels:
      app: jvb-pod
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: jvb-pod
    spec:
      containers:
      - image: java:17
        name: jvb-pod
        command: ["sleep"]
        args: ["infinity"]
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9999
        volumeMounts:
        - name: jvb-dir
          mountPath: /myblog
      volumes:
      - name: jvb-dir
        persistentVolumeClaim:
            claimName: jvb-pvc

Logo

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

更多推荐