k8s Deployment与Service配置样例

一、Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pie-algorithm-farmland-detection
spec:
  replicas: 1
  selector:
    matchLabels:
      name: pie-algorithm-farmland-detection
  template:
    metadata:
      labels:
        name: pie-algorithm-farmland-detection
    spec:
      containers:
        - name: task-status
          image: 172.16.40.78:1180/pie-algorithms/pie-algorithm-farmland-detection:latest
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 19092
          volumeMounts:
          - name: pie-algorithm-farmland-detection
            mountPath: /usr/seis/data/user/admin/test/
      volumes:
      - name: pie-algorithm-farmland-detection
        nfs:
          server: 172.16.40.247
          path: /FS/piecloud/MapData/test/

二、Service

apiVersion: v1
kind: Service
metadata:
  name: pie-algorithm-farmland-detection
spec:
  type: NodePort
  ports:
  - port: 19092
    targetPort: 19092
    nodePort: 30902
  selector:
    name: pie-algorithm-farmland-detection
原文地址:https://www.cnblogs.com/runnerjack/p/12762420.html