编写Service.yml文件
[root@master ~]# cat nginx.yml --- apiVersion: apps/v1 kind: Deployment metadata: name: web spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: volumes: - name: webstorage hostPath: path: /var/www/html containers: - name: web image: nginx imagePullPolicy: IfNotPresent volumeMounts: - name: webstorage mountPath: /usr/share/nginx/html ... --- apiVersion: v1 kind: Service metadata: name: web spec: type: NodePort ports: - port: 80 targetPort: 80 protocol: TCP nodePort: 30000 selector: app: nginx