在Google Cloud 平台/容器引擎上运行 - 如何将其设置为指向此Ingress,如下所示?
我已经使用Helm在Kubernetes上安装了Nginx-ingress,它适用于 default backend - 404
.
我希望能够使用不同的http uri路径,如 <domain.com>/v1
, <domain.com>/v2
等 .
对于我想要使用Ingress的图表,我在 values.yaml
中有以下内容:
# Default values for app-go.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: gcr.io/<project name>/app-go
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port:
# kubernetes.io/tls-acme: "true",
ingress:
enabled: true
annotations: {
kubernetes.io/ingress.class: "nginx",
kubernetes.io/ingress.global-static-ip-name: "kube-ingress"
}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- <domain.com>
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
如何为不同路径指定Nginx-ingress的注释 .
helm version
Client: &version.Version{SemVer:"v2.8.1", GitCommit:"6af75a8fd72e2aa18a2b278cfe5c7a1c5feca7f2", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.8.0", GitCommit:"14af25f1de6832228539259b821949d20069a222", GitTreeState:"clean"}
2 回答
如果您的意思是在同一域名中使用基于URI的不同入口注释(可用于指向不同服务的不同路径),那么简单的答案是:您不能 .
注释是kubernetes API对象上元数据的一部分,您的整个Ingress就是这样一个对象,因此您无法根据http uri路径对它进行区分 .
我继续并转载你的用例 .
假设通过helm安装nginx入口控制器顺利进行,当列出资源时,一切似乎都很好,你需要在入口yaml文件中指定路径,如下所示:
然后,卷曲-H -I 'Host: test.demo.com' http://external-lb-ip/path1,例如,应该返回200 .