I'm trying to setup ingress on azure. I have a pod and service running (a website).
Googling about Ingress setup, it seems you have to create 3 things, Ingress, service and ingress controller (pod)
THis is what I have so far:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: myingress
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: ui.example.com
http:
paths:
- backend:
serviceName: ui
servicePort: 80
- host: monit.example.com
http:
paths:
- path:
backend:
serviceName: grafana
servicePort: 80
This is almost self explanatory, but what exactly does the rewrite-target
do (I have two backends)?
Next the service with LoadBalancing
apiVersion: v1
kind: Service
metadata:
name: ingressservice
spec:
ports:
- port: 80
name: http
- port: 443
name: https
selector:
k8s-app: nginx-ingress-controller
type: LoadBalancer
And the ingress controller
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
labels:
k8s-app: nginx-ingress-controller
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: nginx-ingress-controller
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
terminationGracePeriodSeconds: 60
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.15
name: nginx-ingress-controller
ports:
- containerPort: 80
hostPort: 80
- containerPort: 443
hostPort: 443
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
Questions: * How does all this work together? * Is the image for ingress-controller correct? (It should run on Azure)
doesn't matter on which cloud your kubernetes runs, ingress happens inside kubernetes, so its cloud agnostic. to setup ingress you can use the official helm chart for that. After that you would need to create ingress definitions to expose your services using the ingress you've created.
Doesn't if you are running setup on digital ocean, GCP, AWS, Azure kubernetes and it's components will work same.
SO you have to install the ingress-controller if you have not installed it.
also you can follow this tutorial to setup the ingress controller and cert-manager : https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes