From 188af71cafdc182c86c74a6e736c3d91b253ca5f Mon Sep 17 00:00:00 2001 From: Dominik Chilla Date: Sun, 23 Aug 2020 20:34:00 +0200 Subject: [PATCH] TOC --- README.md | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a1fb29e..6d59af8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ # snippets for k3s * [Install k3s](#install-k3s) +* [Disable Traefik-ingress](#disable-traefik-ingress) +* [Enable NGINX-ingress](#enable-nginx-ingress) + * [Installation](#install-nginx-ingress) + * [Change service type from NodePort to LoadBalancer](#nginx-ingress-loadbalancer) + * [Enable nginx-ingress tcp- and udp-services for apps other than http/s](#nginx-ingress-tcp-udp-enabled) + * [Deploy my-nginx-service and expose via nginx-ingress on TCP-port 9000](#deploy-and-expose-tcp-service) + * [Stick the nginx-ingress controler and my-nginx app together](#stick-nginx-ingress-and-tcp-service) + * [Test exposed app on TCP-port 9000](#test-nginx-ingress-and-tcp-service) ## Install k3s https://k3s.io/: @@ -8,7 +16,7 @@ https://k3s.io/: curl -sfL https://get.k3s.io | sh - ``` -## Disable traeffic-ingress: +## Disable Traefik-ingress edit /etc/systemd/system/k3s.service: ``` [...] @@ -16,13 +24,13 @@ ExecStart=/usr/local/bin/k3s \ server --disable traefik \ [...] ``` -finally `systemctl daemon-reload` and `systemctl restart k3s` +Finally `systemctl daemon-reload` and `systemctl restart k3s` -## Enable nginx-ingress -### Installation +## Enable NGINX-ingress +### Installation https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal -### Change service type from NodePort to LoadBalancer +### Change service type from NodePort to LoadBalancer `kubectl edit service -n ingress-nginx` and change `type: NodePort` to `type: LoadBalancer` Port 80 and 443 should listen now on an *External-IP* `kubectl get all --all-namespaces`: @@ -46,7 +54,7 @@ dominik@muggler:~$ curl -s http://10.62.94.246 ``` -### Enable nginx-ingress tcp- and udp-services for apps other than http/s +### Enable nginx-ingress tcp- and udp-services for apps other than http/s Docs: https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/ `kubectl edit deployment -n ingress-nginx` and search for `spec:`/`template`/`spec`/`containers` section: @@ -79,7 +87,7 @@ spec: [...] ``` -### Deploy my-nginx-service and expose via nginx-ingress on TCP-port 9000 +### Deploy my-nginx-service and expose via nginx-ingress on TCP-port 9000 my-nginx-deployment.yml: ``` apiVersion: apps/v1 @@ -157,7 +165,17 @@ spec: <<< ADD [...] ``` -Finally, we need to glue nginx-ingress with the my-nginx app. This will be done with the config-map `tcp-services-config-map.yml` referenced earlier in the nginx-ingress deployment definition: +Verify nginx-ingress is listening on port 9000 with `kubectl get all --all-namespaces`: +``` +[...] +NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +[...] +ingress-nginx service/ingress-nginx-controller LoadBalancer 10.43.237.255 10.62.94.246 80:30312/TCP,443:30366/TCP,9000:31460/TCP 71m +[...] +``` + +## Stick the nginx-ingress controler and my-nginx app together +Finally, the nginx-ingress controller needs a port-mapping pointing to the my-nginx app. This will be done with the config-map `tcp-services-config-map.yml`, referenced earlier in the nginx-ingress deployment definition: ``` --- apiVersion: v1 @@ -172,17 +190,9 @@ Apply with `kubectl apply -f tcp-services-config-map.yml`: ``` configmap/tcp-services created ``` +Subsequently the config-map can be edited with `kubectl edit configmap tcp-services -n ingress-nginx` - -Verify nginx-ingress is listening on port 9000 with `kubectl get all --all-namespaces`: -``` -[...] -NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -[...] -ingress-nginx service/ingress-nginx-controller LoadBalancer 10.43.237.255 10.62.94.246 80:30312/TCP,443:30366/TCP,9000:31460/TCP 71m -[...] -``` -Test: +## Test exposed app on TCP-port 9000 ``` dominik@muggler:~$ curl -s http://10.62.94.246:9000