简略版deployment、pv、pvc资源文件模板

警告
本文最后更新于 2021-03-17 19:03,文中内容可能已过时。

deployment

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
apiVersion: v1
kind: Service
metadata:
  labels:
    app: {name}
  name: {name}
  namespace: {namespace}
spec:
  ports:
  - port: {cluster ip端口}
    protocol: TCP
    targetPort: {容器端口}
    nodePort: {宿主机端口}

  selector:
    app: {name}
  type: NodePort

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {name}
  namespace: {namespace}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {name}
  template:
    metadata:
      labels:
        app: {name}  #和matchLabels中的一致
    spec:
      imagePullSecrets:
      - name: {secret}
      containers:
      - name: {container-name}
        image: {image_name}
        ports:
        - containerPort: {容器端口}
        command: ['java']
        args: ['-Dspring.profiles.active=test','-jar','xx.jar']
        volumeMounts: # 将存储卷挂载到容器中
          - name: {name}   # 指定使用哪个存储卷
            mountPath: "/data/www/images"
      volumes: #定义存储卷
      - name: {volumes_name} #定义存储卷名称
        persistentVolumeClaim:
          claimName: {pvc_name} #指定使用哪个pvc

pv

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
apiVersion: v1
kind: PersistentVolume
metadata:
  name: {name}
spec:
  capacity:
    storage: 40Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: "/nfsdata/xxx"
    server: 10.0.0.10
    readOnly: false

pvc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {name}
  namespace: {namespace}
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 40Gi
请我喝杯水
SoulChild 微信号 微信号
SoulChild 微信打赏 微信打赏
0%