我正在Kubernetes上尝试学习https://www.youtube.com/watch?v=d6WC5n9G_sM&t=5478s课程。我创建了一个部署,我有3个pod运行nginx。我可以单独访问每个pod,但我无法通过Minikube中的集群IP和暴露端口访问整个服务。我不知道它会是什么,因为我正在按照视频中的确切步骤操作。也许有人能发现问题?谢谢!!!!!!!
ejandro@alejandro-Latitude-7390:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 38d
alejandro@alejandro-Latitude-7390:~$ kubectl describe service kubernetes
Name: kubernetes
Namespace: default
Labels: component=apiserver
provider=kubernetes
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.96.0.1
IPs: 10.96.0.1
Port: https 443/TCP
TargetPort: 8443/TCP
Endpoints: 192.168.59.100:8443
Session Affinity: None
Events: <none>
alejandro@alejandro-Latitude-7390:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 38d
alejandro@alejandro-Latitude-7390:~$ kubectl expose deployment nginx-deployment --port=80 --target-port=80
service/nginx-deployment exposed
alejandro@alejandro-Latitude-7390:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 38d
nginx-deployment ClusterIP 10.98.250.240 <none> 80/TCP 3s
alejandro@alejandro-Latitude-7390:~$ kubectl describe service nginx-deployment
Name: nginx-deployment
Namespace: default
Labels: app=nginx-deployment
Annotations: <none>
Selector: app=nginx-deployment
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.98.250.240
IPs: 10.98.250.240
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 172.17.0.3:80,172.17.0.4:80,172.17.0.5:80
Session Affinity: None
Events: <none>
alejandro@alejandro-Latitude-7390:~$ sudo ssh -o StrictHostKeyChecking=no docker@192.168.59.100
[sudo] password for alejandro:
docker@192.168.59.100's password:
_ _
_ _ ( ) ( )
___ ___ (_) ___ (_)| |/') _ _ | |_ __
/' _ ` _ `\| |/' _ `\| || , < ( ) ( )| '_`\ /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )( ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)
$ curl 10.98.250.240:80
^C
$
1条答案
按热度按时间gblwokeq1#
您对
kubectl expose ...
的想法是正确的,但这在Minikube中是行不通的,因为Minikube中的移植设置是不同的。这只是Minikube特定的,但是当在非minikube K8集群上工作时,它是
kubectl expose...
。此外,ClusterIP
服务类型用于集群内部的网络流量,但是对于调试/测试,暴露它是好的。其他服务对象,如NodePort
和LoadBalancer
,是为外部互联网流量设计的。