From f6b8acdb36210b13ba58a9eaf92869cf8f001b0c Mon Sep 17 00:00:00 2001 From: Dominik Chilla Date: Sun, 23 Aug 2020 20:43:50 +0200 Subject: [PATCH] TOC re-order --- README.md | 82 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 6d59af8..a929cfe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# snippets for k3s +# Snippets for k3s * [Install k3s](#install-k3s) * [Disable Traefik-ingress](#disable-traefik-ingress) @@ -6,7 +6,8 @@ * [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) + * [Enable client-IP transparency and expose TCP-port 9000](#enable-client-ip-transp-expose-tcp-9000) + * [Deploy my-nginx-service][#deploy-my-nginx-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) @@ -87,7 +88,45 @@ spec: [...] ``` -### Deploy my-nginx-service and expose via nginx-ingress on TCP-port 9000 +## Enable client-IP transparency and expose TCP-port 9000 +Enable client-IP transparency and expose my-nginx app on nginx-ingress TCP-port 9000: `kubectl edit service -n ingress-nginx` +Find the `ports:`-section of the `ingress-nginx-controller` service and *ADD* the definition for port 9000: +``` +[...] +spec: + clusterIP: 10.43.237.255 +>>> CHANGE externalTrafficPolicy from Cluster to Local if original client-IP is desirable + externalTrafficPolicy: Local +<<< CHANGE + ports: + - name: http + nodePort: 30312 + port: 80 + protocol: TCP + targetPort: http + - name: https + nodePort: 30366 + port: 443 + protocol: TCP + targetPort: https +>>> ADD + - name: proxied-tcp-9000 + port: 9000 + protocol: TCP + targetPort: 9000 +<<< ADD +[...] +``` +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 +[...] +``` + +### Deploy my-nginx-service my-nginx-deployment.yml: ``` apiVersion: apps/v1 @@ -127,7 +166,6 @@ Apply with `kubectl apply -f my-nginx-deployment.yml`: ``` deployment.apps/my-nginx created service/my-nginx created -configmap/tcp-services created ``` Test: `kubectl get all`: ``` @@ -137,42 +175,6 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/my-nginx ClusterIP 10.43.118.13 80/TCP 99s [...] ``` -Enable client-IP transparency and expose my-nginx app on nginx-ingress TCP-port 9000: `kubectl edit service -n ingress-nginx` -Find the `ports:`-section of the `ingress-nginx-controller` service and *ADD* the definition for port 9000: -``` -[...] -spec: - clusterIP: 10.43.237.255 ->>> CHANGE externalTrafficPolicy from Cluster to Local if original client-IP is desirable - externalTrafficPolicy: Local -<<< CHANGE - ports: - - name: http - nodePort: 30312 - port: 80 - protocol: TCP - targetPort: http - - name: https - nodePort: 30366 - port: 443 - protocol: TCP - targetPort: https ->>> ADD - - name: proxied-tcp-9000 - port: 9000 - protocol: TCP - targetPort: 9000 -<<< ADD -[...] -``` -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: