![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: myhttpd #只要是包含子项的第一行都需要有”-“,且与上一行对齐 image: httpd imagePullPolicy: IfNotPresent ports: - containerPort: 80 - name: mynginx image: nginx imagePullPolicy: IfNotPresent ports: - containerPort: 8080指定端口创建2个POD
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
apiVersion: v1 kind: Service metadata: name: my-svc #定义服务的名称 spec: ports: - name: tomcat port: 8080 #POD暴露的cluster-ip端口 targetPort: 8080 #container暴露的端口,容器expose暴露的端口 protocol: TCP nodePort: 30001 #物理节点对外暴露的端口,提供给外部访问service的入口 selector: app: npu type: NodePort创建一个service
标签:文件,8080,name,示例,暴露,端口,yaml,ports From: https://www.cnblogs.com/vmsysjack/p/17643757.html