apiVersion: apps/v1
kind: Deployment
metadata:
  name: pc-deployment
  namespace: liyuan
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-pod
  template:
    metadata:
      labels:
        app: nginx-pod
    spec:
      containers:
      - name: nginx
        image: nginx:1.17.1
        ports:
        - containerPort: 80
        volumeMounts:
        - name: nginx-web
          mountPath: /usr/share/nginx/html
      volumes:
      - name: nginx-web
        hostPath:
          path: /root/www/html
          type: DirectoryOrCreate

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
  namespace: liyuan
spec:
  selector:
    app: nginx-pod
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    nodePort: 30010

Logo

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

更多推荐