我需要能够使用一个主机名将路径定向到不同的服务。我已经尝试了多个入口,多个路径...最终我会发现,除非由于时机问题,否则将路径转到相同的后端服务。
apiVersion: v1
kind: Service
metadata:
name: appname.var
labels:
app.kubernetes.io/name: appname.var
helm.sh/chart: {{ template "helmchart.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
ports:
- port: 80
targetPort: 8080
selector:
app.kubernetes.io/name: appname.var
app.kubernetes.io/instance: {{ .Release.Name }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress.var
annotations:
kubernetes.io/ingress.class: alb
ingress.kubernetes.io/force-ssl-redirect: 'true'
alb.ingress.kubernetes.io/certificate-arn: "cert.arn"
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80, "HTTPS": 443}]'
alb.ingress.kubernetes.io/security-groups: api_alb
alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=604800
labels:
app: appname.var
spec:
type: ClusterIP
rules:
- host: api.domainname
http:
paths:
- path: /widgets/*
backend:
serviceName: appname-widgets
servicePort: 80
- path: /*
backend:
serviceName: appname
servicePort: 80
此代码用于创建“ appname”服务和“ appname-widgets”服务,包括入口(入口的唯一名称)。
请求可能转到一个或另一个服务,因为这两个服务存在相同的路径。关于如何进行这项工作的任何想法?我需要/ widgets / *才能进入小部件服务,而其他所有(/ *)则进入常规api服务。