我正在尝试在Google Kubernetes Engine AKA GKE上获得一个新的集群设置。我正在使用helm并添加到仓库ingress-nginx https://kubernetes.github.io/ingress-nginx和grafana https://grafana.github.io/helm-charts
我一直在遵循这个指南,但我无法访问内部ip或使入口工作到我可以看到仪表板的地方。然后我尝试了这个指南,使用他们的头盔部署Loki Stack (Loki, Promtail, Grafana, Prometheus)与持久的卷声明。
这与打开端口8443相结合,我仍然得到503错误。我做了这个入口:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- http:
paths:
- path: /pro
pathType: Prefix
backend:
service:
name: loki-prometheus-server
port:
number: 9090
- path: /graf
pathType: Prefix
backend:
service:
name: loki-grafana
port:
number: 3000
我尝试了许多不同的端口,包括80,但都没有成功。
loki-prometheus-server服务:
Name: loki-prometheus-server
Namespace: ingress-nginx
Labels: app=prometheus
app.kubernetes.io/managed-by=Helm
chart=prometheus-11.16.9
component=server
heritage=Helm
release=loki
Annotations: cloud.google.com/neg: {"ingress":true}
meta.helm.sh/release-name: loki
meta.helm.sh/release-namespace: ingress-nginx
Selector: app=prometheus,component=server,release=loki
Type: ClusterIP
IP Families: <none>
IP: 10.***
IPs: 10.***
Port: http 80/TCP
TargetPort: 9090/TCP
Endpoints: 10.***:9090
Session Affinity: None
Events: <none>
loki-grafana服务:
Name: loki-grafana
Namespace: ingress-nginx
Labels: app.kubernetes.io/instance=loki
app.kubernetes.io/managed-by=Helm
app.kubernetes.io/name=grafana
app.kubernetes.io/version=7.5.0
helm.sh/chart=grafana-5.7.10
Annotations: cloud.google.com/neg: {"ingress":true}
meta.helm.sh/release-name: loki
meta.helm.sh/release-namespace: ingress-nginx
Selector: app.kubernetes.io/instance=loki,app.kubernetes.io/name=grafana
Type: ClusterIP
IP Families: <none>
IP: 10.***
IPs: 10.***
Port: service 80/TCP
TargetPort: 3000/TCP
Endpoints: 10.***:3000
Session Affinity: None
Events: <none>
Step by Step:
在gcloud上创建新的集群:
- GKE标准
- 缺省池→→节点机器类型:e2-small
- 缺省池→安全→允许完全访问所选择的所有云api
- 。
连接控制台或云shell
:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
kubectl create namespace ingress-nginx
helm install ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx
到目前为止一切都很正常。
进入VPC网络->防火墙→在Protocols/ports中找到带有80443的那个然后加上8443
安装洛基:
helm upgrade --install loki grafana/loki-stack --namespace ingress-nginx --set grafana.enabled=true,prometheus.enabled=true,prometheus.alertmanager.persistentVolume.enabled=false,prometheus.server.persistentVolume.enabled=false,loki.persistence.enabled=true,loki.persistence.storageClassName=standard,loki.persistence.size=5Gi
一切似乎仍然很好,但如果我去我的外部负载均衡器我得到404 not found/nginx
我添加了这个入口:
使用kubectl apply -f ingress.yml -n ingress-nginx
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
prometheus.io/scrape: "true"
spec:
rules:
- http:
paths:
- path: /pro
pathType: Prefix
backend:
service:
name: loki-prometheus-server
port:
number: 80
- path: /graf
pathType: Prefix
backend:
service:
name: loki-grafana
port:
number: 80
并得到一个404页没有找到的文本在/pro然后重定向到/login,在/graf
显示404 not found nginx页面我做错了什么?
Running:
helm upgrade ingress-nginx ingress-nginx/ingress-nginx --namespace ingress-nginx --set controller.metrics.enabled=true --set-string controller.podAnnotations."prometheus.io/scrape"="true" --set-string controller.podAnnotations."prometheus.io/port"="10254"
并且使用这个入口我能够使它工作:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /$1
prometheus.io/port: "10254"
prometheus.io/scrape: "true"
spec:
rules:
- http:
paths:
- path: /?(.*)
pathType: Prefix
backend:
service:
name: loki-grafana
port:
number: 80