gpt4 book ai didi

kubernetes - 暴露应用程序时Kubernetes Ingress Controller错误

转载 作者:行者123 更新时间:2023-12-02 12:28:52 26 4
gpt4 key购买 nike

我正在尝试使用nginx Ingress Controller 公开我的后端API服务。这是我定义的Ingress服务:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: plant-simulator-ingress
namespace: plant-simulator-ns
annotations:
ingress.kubernetes.io/enable-cors: "true"
kubernetes.io/ingress.class: nginx
# nginx.ingress.kubernetes.io/rewrite-target: /
prometheus.io/scrape: 'true'
prometheus.io/path: /metrics
prometheus.io/port: '80'
spec:
rules:
- host: grafana.local
http:
paths:
- backend:
serviceName: grafana-ip-service
servicePort: 8080

- host: prometheus.local
http:
paths:
- backend:
serviceName: prometheus-ip-service
servicePort: 8080

- host: plant-simulator.local
http:
paths:
- backend:
serviceName: plant-simulator-service
servicePort: 9000

plant-simulator-service被定义为服务:
apiVersion: v1
kind: Service
metadata:
name: plant-simulator-service
namespace: plant-simulator-ns
labels:
name: plant-simulator-service
spec:
ports:
- port: 9000
targetPort: 9000
protocol: TCP
name: plant-simulator-service-port
selector:
app: plant-simulator
type: LoadBalancer

我已在Minikube上成功部署了它,这是正在运行的Pod集:
Joes-MacBook-Pro:~ joesan$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6955765f44-cvblh 1/1 Running 0 39m
kube-system coredns-6955765f44-xh2wg 1/1 Running 0 39m
kube-system etcd-minikube 1/1 Running 0 39m
kube-system kube-apiserver-minikube 1/1 Running 0 39m
kube-system kube-controller-manager-minikube 1/1 Running 0 39m
kube-system kube-proxy-n6scg 1/1 Running 0 39m
kube-system kube-scheduler-minikube 1/1 Running 0 39m
kube-system storage-provisioner 1/1 Running 0 39m
plant-simulator-ns flux-5476b788b9-g7xtn 1/1 Running 0 20m
plant-simulator-ns memcached-86bdf9f56b-zgshx 1/1 Running 0 20m
plant-simulator-ns plant-simulator-6d46dc89cb-xsjgv 1/1 Running 0 65s

以下是服务列表:
Joes-MacBook-Pro:~ joesan$ minikube service list
|--------------------|-------------------------|-----------------------------|-----|
| NAMESPACE | NAME | TARGET PORT | URL |
|--------------------|-------------------------|-----------------------------|-----|
| default | kubernetes | No node port |
| kube-system | kube-dns | No node port |
| plant-simulator-ns | memcached | No node port |
| plant-simulator-ns | plant-simulator-service | http://192.168.99.103:32638 |
|--------------------|-------------------------|-----------------------------|-----|

我想要实现的是,可以通过在Ingress中配置的dns条目访问应用程序后端-

plant-simulator.local



关于我所缺少的任何想法吗?

最佳答案

OP报告通过在/etc/hosts中添加IP和主机名解决了该案例

$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
192.168.99.103 plant-simulator.local

关于kubernetes - 暴露应用程序时Kubernetes Ingress Controller错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60701369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com