[root@master ~]# cat 6-5nodeport.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx-deployment
spec:
ports:
- port: 80
name: nginx-service80
protocol: TCP
targetPort: 80
nodePort: 31999
selector:
app: nginx
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
每个节点都会启用:
[root@node1 ~]# netstat -na | grep 31999
tcp 0 0 0.0.0.0:31999 0.0.0.0:* LISTEN
[root@master ~]# kubec