创建配置文件 k8s_nginx_svc.yml
apiVersion: v1
kind: Service
metadata:
name: nginxsvc
spec:
type: NodePort
ports:
- port: 80
nodePort: 30001
selector:
app: nginx
~
1.创建
kubectl create -f k8s_nginx_svc.yml
2.查看
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 24h
nginxsvc NodePort 10.96.243.61 <none> 80:30001/TCP 17s
网友评论