Reputation: 25964
Running on Google Cloud platform / Container Engine - How do I set it up to point to this Ingress in the following?
I have installed Nginx-ingress on Kubernetes with Helm and it works for the default backend - 404
.
I want to be able to use different http uri path, like <domain.com>/v1
, <domain.com>/v2
and others.
For my own Chart that I want to use Ingress I have the following in 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: {}
How do I specify annotations for Nginx-ingress for different paths.
helm version
Client: &version.Version{SemVer:"v2.8.1", GitCommit:"6af75a8fd72e2aa18a2b278cfe5c7a1c5feca7f2", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.8.0", GitCommit:"14af25f1de6832228539259b821949d20069a222", GitTreeState:"clean"}
Upvotes: 4
Views: 13424
Reputation: 8786
I went ahead and reproduced your use case.
Assuming the installation of nginx ingress controller though helm went smoothly and when listing resources everything seems to be fine, you need to specify the paths in the ingress yaml file, as follows:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-resource
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: test.demo.com
http:
paths:
- path: /path1
backend:
serviceName: s1
servicePort: 8080
- path: /path2
backend:
serviceName: s1
servicePort: 8080
- path: /path3
backend:
serviceName: s2
servicePort: 80
- host: demo.test.com
http:
paths:
- backend:
serviceName: s2
servicePort: 80
Then, curl -H -I 'Host: test.demo.com' http://external-lb-ip/path1, for example, should return 200.
Upvotes: 3
Reputation: 22884
How do I specify annotations for Nginx-ingress for different paths.
If you mean having different ingress annotations based on URI within the same domain name (which can be used to point different paths to different services), then the simple answer is: you can't.
Annotations are part of the metadata on a kubernetes API object, your whole Ingress is such an object, so you cant have it differ based on http uri path.
Upvotes: 1