Docker 无法访问kubernetes minikube上的IP和端口
我已经在kubernetes上创建了web部署和服务 当我使用Docker 无法访问kubernetes minikube上的IP和端口,docker,kubernetes,minikube,Docker,Kubernetes,Minikube,我已经在kubernetes上创建了web部署和服务 当我使用$kubectl get service命令列出服务时,列出访问网页的IP和端口,但当我尝试访问该网页时,无法访问该网站。 似乎minikube上的kubernetes并没有从docker hub提取图像 下面是我的示例脚本。。 我使用Kubernetes v1.19.2和默认驱动程序Docker 19.03.8 $kubectl create-f webpets.yaml 输出创建webpets.yaml 输出$kubectl获取服
$kubectl get service
命令列出服务时,列出访问网页的IP和端口,但当我尝试访问该网页时,无法访问该网站。
似乎minikube上的kubernetes并没有从docker hub提取图像
下面是我的示例脚本。。
我使用Kubernetes v1.19.2和默认驱动程序Docker 19.03.8
$kubectl create-f webpets.yaml
webpets.yaml
$kubectl获取服务
$kubectl获取事件
Nginx侦听端口
80
。因此,您需要在部署和服务中使用端口80
,而不是端口3000
。从中,您应该能够使用
minikube服务网站
添加kubectl descripe svc网站的输出
@ArghyaSadhu添加了正在运行的输出?否。。我没有创建任何pod如何做?添加kubectl descripe deploy web
和kubectl get pods
的输出,但如果图像未从docker hub中提取,它会工作吗?我运行了$docker images
否nginx:1.19.2-阿尔卑斯山图像仍然无法访问它我已更改为端口80否它将无法访问..您可以尝试在minikube中使用docker pull
查看是否发生任何错误我重新安装minikube,图像可以自动拖动,现在我可以使用$minikube服务网站访问它
谢谢谢谢你的帮助^^
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 1
selector:
matchLabels:
app: pets
service: web
template:
metadata:
labels:
app: pets
service: web
spec:
containers:
- image: nginx:alpine-1.19.2
name: web
ports:
- containerPort: 80
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
selector:
app: pets
service: web
$ kubectl create -f web-pets.yaml
deployment.apps/web created
service/web created
$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 11h
web NodePort 10.110.107.234 <none> 80:30100/TCP 41s
Name: web
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=pets,service=web
Type: NodePort
IP: 10.109.10.68
Port: <unset> 3000/TCP
TargetPort: 3000/TCP
NodePort: <unset> 31830/TCP
Endpoints: <none>
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kicbase/stable v0.0.12-snapshot3 25ac91b9c8d7 4 weeks ago 952MB
gcr.io/k8s-minikube/kicbase v0.0.12-snapshot3 25ac91b9c8d7 4 weeks ago 952MB
$ kubectl describe deploy web
Name: web
Namespace: default
CreationTimestamp: Thu, 24 Sep 2020 17:25:42 +0700
Labels: <none>
Annotations: <none>
Selector: app=pets,service=web
Replicas: 1 desired | 0 updated | 0 total | 0 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=pets
service=web
Containers:
web:
Image: nginx:alpine-1.19.2
Port: 3000/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
OldReplicaSets: <none>
NewReplicaSet: <none>
Events: <none>
$ kubectl get pods
No resources found in default namespace.
LAST SEEN TYPE REASON OBJECT MESSAGE
7m13s Normal Starting node/minikube Starting kubelet.
7m11s Normal NodeHasSufficientMemory node/minikube Node minikube status is now: NodeHasSufficientMemory
7m11s Normal NodeHasNoDiskPressure node/minikube Node minikube status is now: NodeHasNoDiskPressure
7m11s Normal NodeHasSufficientPID node/minikube Node minikube status is now: NodeHasSufficientPID
7m12s Normal NodeAllocatableEnforced node/minikube Updated Node Allocatable limit across pods
6m28s Normal Starting node/minikube Starting kube-proxy.