Closed thousmile closed 1 year ago
这是启动 ktctl connect 成功的截图
通过 pod ip 可以访问成功 (黄色部分) 通过 Ingress 反向代理也是可以访问
但是通过 service 的 IP 或者 名称。无法访问。(红色部分)
在k8s集群中,任意一个pod中也是可以通过 service 的 IP 或者 名称 访问
下面是k8s部署的yaml
################## hello deployment ################## apiVersion: apps/v1 kind: Deployment metadata: name: hello-nginx spec: replicas: 1 selector: matchLabels: app: hello-nginx template: metadata: labels: app: hello-nginx spec: containers: - name: nginx image: nginx:1.24.0 ports: - containerPort: 80 --- ################## hello Service ################## apiVersion: v1 kind: Service metadata: name: hello-nginx labels: app: hello-nginx spec: type: ClusterIP selector: app: hello-nginx ports: - port: 80 targetPort: 80 --- ################## ingress myapp ################## apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-nginx labels: app: hello-nginx spec: ingressClassName: nginx rules: - host: hello.example.com http: paths: - path: "/" pathType: Prefix backend: service: name: hello-nginx port: number: 80
这是启动 ktctl connect 成功的截图
通过 pod ip 可以访问成功 (黄色部分) 通过 Ingress 反向代理也是可以访问
但是通过 service 的 IP 或者 名称。无法访问。(红色部分)
在k8s集群中,任意一个pod中也是可以通过 service 的 IP 或者 名称 访问
下面是k8s部署的yaml