kubectl get service 不显示服务状态

现象:

[root@k8s-master01 kubernetes]# kubectl get service
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1            443/TCP   18d

解决办法:

申明端口

kubectl expose deployment nginx --port=80 --type=LoadBalancer

查看结果:

[root@k8s-master01 kubernetes]# kubectl get service
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1            443/TCP   18d
[root@k8s-master01 kubernetes]# kubectl expose deployment nginx --port=80 --type=LoadBalancer
service/nginx exposed
[root@k8s-master01 kubernetes]# kubectl get service
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP      10.96.0.1                443/TCP        18d
nginx        LoadBalancer   10.105.158.105        80:31384/TCP   2s

 

你可能感兴趣的:(kubectl get service 不显示服务状态)