我正在运行 minikube。Minikube 状态结果为:
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
Run Code Online (Sandbox Code Playgroud)
我定义了一个服务,端口配置如下:
type: NodePort
ports:
- protocol: TCP
port: 8082
targetPort: 8082
nodePort: 30082
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问以下 URL 上的服务时,它无法访问:
http://192.168.99.100:30082
http://192.168.99.100:8082
Run Code Online (Sandbox Code Playgroud)
是否必须另外定义一个 Ingress?我可以没有 Ingress 吗?哪个港口?
谢谢 - 基督徒
在服务的完整 yaml 下方:
apiVersion: v1
kind: Service
metadata:
annotations:
description: LAC 51 Service
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"description":"LAC 51 Service"},"labels":{"name":"lac51","service":"lac51-svc"},"name":"lac51-svc","namespace":"default"},"spec":{"ports":[{"name":"lac51-http-port","nodePort":30082,"port":8082,"protocol":"TCP","targetPort":8082}],"selector":{"app":"lac51"},"type":"NodePort"}}
creationTimestamp: null
labels:
name: lac51
service: lac51-svc
name: lac51-svc
selfLink: /api/v1/namespaces/default/services/lac51-svc
spec:
externalTrafficPolicy: Cluster
ports:
- name: lac51-http-port
port: 8082
protocol: TCP
targetPort: 8082
selector:
app: lac51
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
Run Code Online (Sandbox Code Playgroud)
似乎与docker启动minikube. 为了避免这些问题,您可以强制使用特定的驱动程序(例如“virtualbox”)。为此,请按照以下步骤操作:
minikube delete
Run Code Online (Sandbox Code Playgroud)
minikube start --memory=4096 --driver=virtualbox
Run Code Online (Sandbox Code Playgroud)
minikube ip。你会看到类似的输出192.168.99.100。我在这个问题中找到了这个信息:https : //github.com/kubernetes/minikube/issues/7344#issuecomment-703225254
小智 5
如果您在 Linux 上使用 Docker 驱动器,则需要终端此代码来转发端口。
minikube service serviceName --url
or
minikube service --all
Run Code Online (Sandbox Code Playgroud)
然后你可以curl minikube url来连接你的服务
| 归档时间: |
|
| 查看次数: |
4311 次 |
| 最近记录: |