Nginx-Ingress
https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/
Install Nginx Ingress controller on our bare-metal
https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters
Download Nginx Ingress manifest to edit
Edit the deploy.yaml file:
Find the Kind: Service block and replace Type: NodePort with Type: LoadBalancer. Under the same block, under metadata add
annotations:
metallb.universe.tf/loadBalancerIPs: 192.168.1.179The Kind: Service block should look something like:
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/loadBalancerIPs: 192.168.1.179
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: 1.8.1
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- appProtocol: http
name: http
port: 80
protocol: TCP
targetPort: http
- appProtocol: https
name: https
port: 443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
type: LoadBalancerThe install with kubectl apply -f deploy.yaml
kubectl get service -A should now looks something like:
Testing the new Ingress Controller
Create foo-bar.yaml, then install it with kubectl apply -f foo-bar.yaml
Add the hostnames in the Ingress manifest above foo.tn and bar.tn in the /etc/hosts file to enable test of hostname based ingress. (If a DNS server is present, this can be done there instead.) Example:
Ingress also allows path routing. To test that, replace the following with the Ingress block above:
This can be tested with curl http://192.168.1.179/foo and curl http://192.168.1.179/bar respectively.
Enabling TLS (https)
To enable TLS for site foo.tn such that https://foo.tn
First obtain the PEM encoded key and crt file for site foo.tn
Convert both files to base64 encode
example: cat foo.tn.key | base64 -w0 and cat foo.tn.crt | base64 -w0 and put contents in the secret file below.
Save and run kubectl apply -f foo-tls-secret.yaml
Replace the corresponding Ingress section for foo.tn above with the following:
Apply the above to the cluster and test with https://foo.tn
Last updated