From 4ec8b1d5ba196f349be841ee27e353870327e8bf Mon Sep 17 00:00:00 2001 From: Amit Watve Date: Tue, 10 Dec 2019 22:30:14 -0800 Subject: [PATCH 1/5] Add user guide for ingress nginx. --- site/content/docs/user/ingress-nginx.md | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 site/content/docs/user/ingress-nginx.md diff --git a/site/content/docs/user/ingress-nginx.md b/site/content/docs/user/ingress-nginx.md new file mode 100644 index 0000000000..00b00580a4 --- /dev/null +++ b/site/content/docs/user/ingress-nginx.md @@ -0,0 +1,56 @@ +# Ingress Nginx + +Ingress Nginx in kind works by exposing ports `80(http)` and `443(https)` +from the host to the nginx controller using hostPorts. + +## Create A Cluster with Ingress Nginx + +The following shell script will create a kind cluster deploy +the standard ingress-nginx components and apply the necessary patches. + +```bash +#!/bin/sh +set -o errexit + +# Create cluster with hostPorts opened for http and https +cat < Date: Tue, 10 Dec 2019 23:34:56 -0800 Subject: [PATCH 2/5] Minor fixes and add a basic example. --- site/content/docs/user/ingress-nginx.md | 56 --------- site/content/docs/user/ingress.md | 157 ++++++++++++++++++++++++ 2 files changed, 157 insertions(+), 56 deletions(-) delete mode 100644 site/content/docs/user/ingress-nginx.md create mode 100644 site/content/docs/user/ingress.md diff --git a/site/content/docs/user/ingress-nginx.md b/site/content/docs/user/ingress-nginx.md deleted file mode 100644 index 00b00580a4..0000000000 --- a/site/content/docs/user/ingress-nginx.md +++ /dev/null @@ -1,56 +0,0 @@ -# Ingress Nginx - -Ingress Nginx in kind works by exposing ports `80(http)` and `443(https)` -from the host to the nginx controller using hostPorts. - -## Create A Cluster with Ingress Nginx - -The following shell script will create a kind cluster deploy -the standard ingress-nginx components and apply the necessary patches. - -```bash -#!/bin/sh -set -o errexit - -# Create cluster with hostPorts opened for http and https -cat < Date: Wed, 11 Dec 2019 00:31:49 -0800 Subject: [PATCH 3/5] Use custom node label instead of the control plane label. --- site/content/docs/user/ingress.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/site/content/docs/user/ingress.md b/site/content/docs/user/ingress.md index e5907c5b32..72463e268d 100644 --- a/site/content/docs/user/ingress.md +++ b/site/content/docs/user/ingress.md @@ -10,7 +10,9 @@ menu: ## Setting Up An Ingress Controller We can leverage KIND's `extraPortMapping` config option when creating a cluster to -forward ports from the host to an ingress controller running on a node. +forward ports from the host to an ingress controller running on a node. We can also specify +custom node label by using `node-labels` in the kubeadm `InitConfiguration`, to be used +by the ingress controller `nodeSelector`. The following ingress controllers are known to work: - [Ingress NGINX](#ingress-nginx) @@ -20,9 +22,6 @@ The following ingress controllers are known to work: The following shell script will create a kind cluster, deploy the standard ingress-nginx components, and apply the necessary patches. -**Note:** This setup is independent of the number of worker nodes -and only works on a single control-plane cluster. - ```bash #!/bin/sh set -o errexit @@ -33,6 +32,14 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane + kubeadmConfigPatches: + - | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + authorization-mode: "AlwaysAllow" extraPortMappings: - containerPort: 80 hostPort: 80 @@ -60,7 +67,7 @@ spec: hostPort: 443 nodeSelector: # schedule it on the control-plane node - node-role.kubernetes.io/master: '' + ingress-ready: 'true' tolerations: # tolerate the the control-plane taints - key: node-role.kubernetes.io/master From dd1832f2733576eae386582cfd230407853721dd Mon Sep 17 00:00:00 2001 From: Amit Watve Date: Wed, 11 Dec 2019 00:51:23 -0800 Subject: [PATCH 4/5] move out example to a file. --- .../docs/user/ingress-nginx-example.yaml | 65 +++++++++++++++++++ site/content/docs/user/ingress.md | 10 ++- site/content/docs/user/known-issues.md | 2 +- 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 site/content/docs/user/ingress-nginx-example.yaml diff --git a/site/content/docs/user/ingress-nginx-example.yaml b/site/content/docs/user/ingress-nginx-example.yaml new file mode 100644 index 0000000000..c5e116fdd5 --- /dev/null +++ b/site/content/docs/user/ingress-nginx-example.yaml @@ -0,0 +1,65 @@ +kind: Pod +apiVersion: v1 +metadata: + name: foo-app + labels: + app: foo +spec: + containers: + - name: foo-app + image: hashicorp/http-echo + args: + - "-text=foo" +--- +kind: Service +apiVersion: v1 +metadata: + name: foo-service +spec: + selector: + app: foo + ports: + - port: 5678 # Default port used by the image +--- +kind: Pod +apiVersion: v1 +metadata: + name: bar-app + labels: + app: bar +spec: + containers: + - name: bar-app + image: hashicorp/http-echo + args: + - "-text=bar" +--- +kind: Service +apiVersion: v1 +metadata: + name: bar-service +spec: + selector: + app: bar + ports: + - port: 5678 # Default port used by the image +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: example-ingress + annotations: + ingress.kubernetes.io/rewrite-target: / +spec: + rules: + - http: + paths: + - path: /foo + backend: + serviceName: foo-service + servicePort: 5678 + - path: /bar + backend: + serviceName: bar-service + servicePort: 5678 +--- diff --git a/site/content/docs/user/ingress.md b/site/content/docs/user/ingress.md index 72463e268d..396157398b 100644 --- a/site/content/docs/user/ingress.md +++ b/site/content/docs/user/ingress.md @@ -86,8 +86,7 @@ Now you will want to checkout [Using Ingress](#using-ingress) The following example creates simple http-echo services and an Ingress object to route to these services. -```bash -cat < Date: Wed, 11 Dec 2019 14:11:42 -0800 Subject: [PATCH 5/5] Move configurations to static files. --- site/content/docs/user/ingress.md | 31 +++++++++---------- .../manifests/ingress/nginx/example.yaml} | 0 .../static/manifests/ingress/nginx/patch.yaml | 20 ++++++++++++ 3 files changed, 35 insertions(+), 16 deletions(-) rename site/{content/docs/user/ingress-nginx-example.yaml => static/manifests/ingress/nginx/example.yaml} (100%) create mode 100644 site/static/manifests/ingress/nginx/patch.yaml diff --git a/site/content/docs/user/ingress.md b/site/content/docs/user/ingress.md index 396157398b..88c093abff 100644 --- a/site/content/docs/user/ingress.md +++ b/site/content/docs/user/ingress.md @@ -19,14 +19,9 @@ The following ingress controllers are known to work: ### Ingress NGINX -The following shell script will create a kind cluster, deploy -the standard ingress-nginx components, and apply the necessary patches. +Create a kind cluster with `extraPortMappings` and `node-labels`. -```bash -#!/bin/sh -set -o errexit - -# Create cluster with hostPorts opened for http and https +```shell script cat <