DevOps Buzz
Search…
Bash / Shell
Bitbucket
Distros
Elasticsearch
General
Guidelines / Standards
microk8s
Prometheus
RabbitMQ
VirtualBox
Ingress
K8s AKS ingress

Deploy NGINX ingress

Create a values file:
1
cat <<EOF >ingress-internal.yml
2
controller:
3
service:
4
loadBalancerIP: 10.240.0.42
5
annotations:
6
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
7
8
EOF
Copied!
Check you network CIDR to specify loadBalancerIP.
You can also omit it in order to leave Azure to allocate an IP.
Create a namespace.
1
kubectl create namespace ingress-internal
Copied!
Deploy NGINX ingress
1
helm install stable/nginx-ingress \
2
--name=ingress-internal \
3
--namespace ingress-internal \
4
-f ingress-internal.yml \
5
--set controller.replicaCount=2 \
6
--set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
7
--set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux
Copied!
Check service IP.
1
kubectl -n ingress-internal get service ingress-internal-nginx-ingress-controller
Copied!
The EXTERNAL-IP is actually the ingress internal IP.

References

Test it

1
kubectl create -f - <<EOF
2
---
3
apiVersion: v1
4
kind: Namespace
5
metadata:
6
name: test-ingress
7
---
8
apiVersion: apps/v1
9
kind: Deployment
10
metadata:
11
name: my-example
12
namespace: test-ingress
13
labels:
14
app: my-example
15
spec:
16
replicas: 1
17
selector:
18
matchLabels:
19
app: my-example
20
template:
21
metadata:
22
labels:
23
app: my-example
24
spec:
25
containers:
26
- name: my-example
27
image: nginx
28
29
ports:
30
- containerPort: 80
31
---
32
kind: Service
33
apiVersion: v1
34
metadata:
35
name: my-example
36
namespace: test-ingress
37
spec:
38
selector:
39
app: my-example
40
ports:
41
- protocol: TCP
42
port: 80
43
type: ClusterIP
44
---
45
apiVersion: extensions/v1beta1
46
kind: Ingress
47
metadata:
48
annotations:
49
kubernetes.io/ingress.class: nginx
50
name: example
51
namespace: test-ingress
52
spec:
53
rules:
54
- host: www.example.com
55
http:
56
paths:
57
- backend:
58
serviceName: my-example
59
servicePort: 80
60
path: /
61
62
EOF
Copied!
Edit your hosts file and point www.example.com to your ingress internal IP.