gke 入口上的 proxy_pass 相当于什么?
What is the equivalent of proxy_pass on gke ingress?
我在 GKE 上为 kibana 创建了一个入口,浏览器 returns 404(尽管它适用于原始服务),我想这是因为我需要路由到 /app/kibana
端点.我该怎么做?
这是我的入口:
kind: Ingress
metadata:
name: my-ingress
namespace: default
annotations:
ingress.kubernetes.io/affinity: cookie
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.global-static-ip-name: my-proxy
ingress.kubernetes.io/affinity: cookie
ingress.kubernetes.io/session-cookie-hash: sha1
ingress.kubernetes.io/session-cookie-name: route
nginx.ingress.kubernetes.io/affinity: cookie
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.allow-http: "false"
annotations:
spec:
tls:
- secretName: my-tls
rules:
- http:
paths:
- path: /kibana
backend:
serviceName: kibana-nodeport
servicePort: 5601
我的节点端口服务:
apiVersion: v1
kind: Service
metadata:
name: kibana-nodeport
namespace: default
spec:
ports:
- port: 5601
protocol: TCP
targetPort: 5601
selector:
k8s-app: kibana
sessionAffinity: None
type: NodePort
kibana 原始服务:
apiVersion: v1
kind: Service
metadata:
labels:
component: kibana
name: kibana-ext
namespace: default
spec:
externalTrafficPolicy: Cluster
loadBalancerSourceRanges:
- x.x.x.x/32
ports:
- name: http
port: 5601
protocol: TCP
targetPort: 5601
selector:
k8s-app: kibana
sessionAffinity: None
type: LoadBalancer
更新:
当我将 Kibana 的路径设置为“/*”时,它起作用了。否则我得到 404.
您应该添加 /* 以便子路径起作用
rules:
- http:
paths:
- path: /kibana/*
backend:
serviceName: kibana-nodeport
servicePort: 5601
由于原始问题已由用户@paltaa 提供的答案解决并由原始发布者修复:
I changed the kibana.yml to be rewritten to /kibana plus changing to your suggestion and it worked! thanks – Idan
我想添加一些额外的 resources/information 和一个“指南”,以帮助处理类似问题。
在 GKE
中使用 ingress-gke
运行 Kibana 的步骤:
Please remember that this is a basic setup for example purposes only.
- 使用 Helm 提供资源
- 创建
Ingress
资源
- 更改 GCP Cloud Console(Web UI)中的健康检查
- 测试
使用 Helm 配置资源
我在安装时参考了下面的Github页面:
Method of spawning this setup could be different but the principles should be the same (values).
使用的命令(特定于 Helm3):
$ helm repo add elastic https://helm.elastic.co
$ helm install es elastic/elasticsearch
$ helm pull elastic/kibana --untar
$ cd kibana/ && nano values.yaml
values.yaml
中所做的更改如下:
healthCheckPath: "/test/app/kibana"
# Allows you to add any config files in /usr/share/kibana/config/
# such as kibana.yml
# Will work with http://DOMAIN.NAME/test/
kibanaConfig:
kibana.yml: |
server.basePath: /test
server.rewriteBasePath: true
service:
type: NodePort # <-- Changed from ClusterIP for ingress-gke
loadBalancerIP: ""
port: 5601
nodePort: ""
labels: {}
annotations: {}
$ helm install ki .
创建一个 Ingress
资源
我使用这个 Ingress
资源访问了 Kibana:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kibana-ingress
spec:
tls:
- secretName: ssl-certificate
rules:
- host: DOMAIN.NAME
http:
paths:
- path: /test/*
backend:
serviceName: ki-kibana
servicePort: 5601
至于问题中使用的注释,请查看它们,因为其中一些可能特定于 ingress-nginx
,不适用于 ingress-gke
。
应用此资源后,由于创建的健康检查路径,我无法连接到 Kibana:
- Healthcheck 创建的路径(不正确):
/
- Healthcheck 更改路径(正确):
/test/app/kibana
您可以通过以下方式更改健康检查:
GCP Cloud Console (Web UI)
--> Kubernetes Engine
--> Services & Ingress
--> kibana-ingress
--> backend services (unhealthy)
--> Health Check
--> Edit
测试
完成上述所有步骤后,您可以打开网络浏览器并输入:
https://DOMAIN.NAME/test
并受到 Elastic Web 的欢迎 UI。
其他资源:
我在 GKE 上为 kibana 创建了一个入口,浏览器 returns 404(尽管它适用于原始服务),我想这是因为我需要路由到 /app/kibana
端点.我该怎么做?
这是我的入口:
kind: Ingress
metadata:
name: my-ingress
namespace: default
annotations:
ingress.kubernetes.io/affinity: cookie
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.global-static-ip-name: my-proxy
ingress.kubernetes.io/affinity: cookie
ingress.kubernetes.io/session-cookie-hash: sha1
ingress.kubernetes.io/session-cookie-name: route
nginx.ingress.kubernetes.io/affinity: cookie
kubernetes.io/ingress.class: gce
kubernetes.io/ingress.allow-http: "false"
annotations:
spec:
tls:
- secretName: my-tls
rules:
- http:
paths:
- path: /kibana
backend:
serviceName: kibana-nodeport
servicePort: 5601
我的节点端口服务:
apiVersion: v1
kind: Service
metadata:
name: kibana-nodeport
namespace: default
spec:
ports:
- port: 5601
protocol: TCP
targetPort: 5601
selector:
k8s-app: kibana
sessionAffinity: None
type: NodePort
kibana 原始服务:
apiVersion: v1
kind: Service
metadata:
labels:
component: kibana
name: kibana-ext
namespace: default
spec:
externalTrafficPolicy: Cluster
loadBalancerSourceRanges:
- x.x.x.x/32
ports:
- name: http
port: 5601
protocol: TCP
targetPort: 5601
selector:
k8s-app: kibana
sessionAffinity: None
type: LoadBalancer
更新:
当我将 Kibana 的路径设置为“/*”时,它起作用了。否则我得到 404.
您应该添加 /* 以便子路径起作用
rules:
- http:
paths:
- path: /kibana/*
backend:
serviceName: kibana-nodeport
servicePort: 5601
由于原始问题已由用户@paltaa 提供的答案解决并由原始发布者修复:
I changed the kibana.yml to be rewritten to /kibana plus changing to your suggestion and it worked! thanks – Idan
我想添加一些额外的 resources/information 和一个“指南”,以帮助处理类似问题。
在 GKE
中使用 ingress-gke
运行 Kibana 的步骤:
Please remember that this is a basic setup for example purposes only.
- 使用 Helm 提供资源
- 创建
Ingress
资源 - 更改 GCP Cloud Console(Web UI)中的健康检查
- 测试
使用 Helm 配置资源
我在安装时参考了下面的Github页面:
Method of spawning this setup could be different but the principles should be the same (values).
使用的命令(特定于 Helm3):
$ helm repo add elastic https://helm.elastic.co
$ helm install es elastic/elasticsearch
$ helm pull elastic/kibana --untar
$ cd kibana/ && nano values.yaml
values.yaml
中所做的更改如下:
healthCheckPath: "/test/app/kibana"
# Allows you to add any config files in /usr/share/kibana/config/
# such as kibana.yml
# Will work with http://DOMAIN.NAME/test/
kibanaConfig:
kibana.yml: |
server.basePath: /test
server.rewriteBasePath: true
service:
type: NodePort # <-- Changed from ClusterIP for ingress-gke
loadBalancerIP: ""
port: 5601
nodePort: ""
labels: {}
annotations: {}
$ helm install ki .
创建一个 Ingress
资源
我使用这个 Ingress
资源访问了 Kibana:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kibana-ingress
spec:
tls:
- secretName: ssl-certificate
rules:
- host: DOMAIN.NAME
http:
paths:
- path: /test/*
backend:
serviceName: ki-kibana
servicePort: 5601
至于问题中使用的注释,请查看它们,因为其中一些可能特定于 ingress-nginx
,不适用于 ingress-gke
。
应用此资源后,由于创建的健康检查路径,我无法连接到 Kibana:
- Healthcheck 创建的路径(不正确):
/
- Healthcheck 更改路径(正确):
/test/app/kibana
您可以通过以下方式更改健康检查:
GCP Cloud Console (Web UI)
-->Kubernetes Engine
-->Services & Ingress
-->kibana-ingress
-->backend services (unhealthy)
-->Health Check
-->Edit
测试
完成上述所有步骤后,您可以打开网络浏览器并输入:
https://DOMAIN.NAME/test
并受到 Elastic Web 的欢迎 UI。
其他资源: