Skip to content

Commit 8b705e7

Browse files
authored
Merge pull request #4043 from rayowang/updateIngress
update ingress docs
2 parents abc2da5 + 0088b04 commit 8b705e7

File tree

1 file changed

+20
-91
lines changed

1 file changed

+20
-91
lines changed

site/content/docs/user/ingress.md

Lines changed: 20 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -8,133 +8,62 @@ menu:
88
description: |-
99
This guide covers setting up [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) on a kind cluster.
1010
---
11-
## Setting Up An Ingress Controller
11+
## Compatibility:
12+
This guide applies to [cloud-provider-kind](https://github.com/kubernetes-sigs/cloud-provider-kind) v0.9.0+. For older versions, refer to historical docs.
1213

13-
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
14+
## Setting Up Ingress
1415

15-
1. [Create a cluster](#create-cluster): There are two primary methods to direct external traffic to Services inside the cluster:
16-
1. using a [LoadBalancer].
17-
2. leverage KIND's `extraPortMapping` config option when creating a cluster to forward ports from the host.
16+
Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
1817

19-
2. Deploy an Ingress controller, we document [Ingress NGINX](#ingress-nginx) here but other ingresses may work including [Contour](https://projectcontour.io/docs/main/guides/kind/) and Kong, you should follow their docs if you choose to use them.
18+
Since cloud-provider-kind v0.9.0, it natively supports Ingress. No third-party ingress controllers are required by default.
2019

21-
> **NOTE**: You may also want to consider using [Gateway API](https://gateway-api.sigs.k8s.io/) instead of Ingress.
22-
> Gateway API has an [Ingress migration guide](https://gateway-api.sigs.k8s.io/guides/migrating-from-ingress/).
20+
For third-party ingress solutions (e.g., Ingress NGINX, Contour), please follow their official documentation.
2321

24-
### Create Cluster
22+
> **NOTE**: Gateway API is also natively supported (along with Ingress). See the official [Ingress migration guide](https://gateway-api.sigs.k8s.io/guides/migrating-from-ingress/) for details.
2523
26-
#### Option 1: LoadBalancer
24+
## Create Cluster
2725

28-
Create a kind cluster and run [Cloud Provider KIND]
29-
to enable the loadbalancer controller which ingress-nginx will use through the loadbalancer API.
26+
Create a kind cluster and run [Cloud Provider KIND] that automatically enables LoadBalancer support for Ingress. Create a cluster as follows.
3027

3128
{{< codeFromInline lang="bash" >}}
3229
kind create cluster
3330
{{< /codeFromInline >}}
3431

35-
#### Option 2: extraPortMapping
36-
37-
Create a single node kind cluster with `extraPortMappings` to allow the local host to make requests to the Ingress controller over ports 80/443.
38-
39-
{{< codeFromInline lang="bash" >}}
40-
cat <<EOF | kind create cluster --config=-
41-
kind: Cluster
42-
apiVersion: kind.x-k8s.io/v1alpha4
43-
nodes:
44-
- role: control-plane
45-
extraPortMappings:
46-
- containerPort: 80
47-
hostPort: 80
48-
protocol: TCP
49-
- containerPort: 443
50-
hostPort: 443
51-
protocol: TCP
52-
EOF
53-
{{< /codeFromInline >}}
54-
55-
If you want to run with multiple nodes you must ensure that your ingress-controller is deployed on the same node where you have configured the PortMapping, in this example you can use a [nodeSelector](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/) to specify the control-plane node name.
56-
57-
{{< codeFromInline lang="yaml" >}}
58-
nodeSelector:
59-
kubernetes.io/hostname: "kind-control-plane"
60-
{{< /codeFromInline >}}
61-
62-
### Ingress NGINX
63-
64-
{{< codeFromInline lang="bash" >}}
65-
kubectl apply -f {{< absURL "examples/ingress/deploy-ingress-nginx.yaml" >}}
66-
{{< /codeFromInline >}}
67-
68-
Now the Ingress is all setup. Wait until is ready to process requests running:
69-
70-
{{< codeFromInline lang="bash" >}}
71-
kubectl wait --namespace ingress-nginx \
72-
--for=condition=ready pod \
73-
--selector=app.kubernetes.io/component=controller \
74-
--timeout=90s
75-
{{< /codeFromInline >}}
76-
77-
Refer [Using Ingress](#using-ingress) for a basic example usage.
78-
7932
## Using Ingress
8033

81-
The following example creates simple http-echo services
82-
and an Ingress object to route to these services.
34+
The following example creates simple http-echo services and an Ingress object to route to these services.
8335

8436
```yaml
8537
{{% readFile "static/examples/ingress/usage.yaml" %}}
8638
```
8739

88-
Apply the contents
40+
Apply the configuration:
8941

9042
{{< codeFromInline lang="bash" >}}
9143
kubectl apply -f {{< absURL "examples/ingress/usage.yaml" >}}
9244
{{< /codeFromInline >}}
9345

94-
Now verify that the ingress works
46+
### Verify Ingress Works
9547

96-
#### Option 1: LoadBalancer
97-
98-
Check the External IP assigned to the Ingress controller by the LoadBalancer
48+
Check the External IP assigned to the Ingress by the built-in LoadBalancer.
9949

10050
{{< codeFromInline lang="bash" >}}
101-
kubectl -n ingress-nginx get services
102-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
103-
ingress-nginx-controller LoadBalancer 10.96.33.233 192.168.8.5 80:31753/TCP,443:30288/TCP 27d
104-
ingress-nginx-controller-admission ClusterIP 10.96.80.178 <none> 443/TCP 27d
51+
kubectl get ingress
52+
NAME CLASS HOSTS ADDRESS PORTS AGE
53+
example-ingress <none> example.com 172.18.0.5 80 10m
10554
{{< /codeFromInline >}}
10655

10756
{{< codeFromInline lang="bash" >}}
57+
# get the Ingress IP
10858

109-
# get the loadalancer IP
110-
111-
LOADBALANCER_IP=$(kubectl get services \
112-
--namespace ingress-nginx \
113-
ingress-nginx-controller \
114-
--output jsonpath='{.status.loadBalancer.ingress[0].ip}')
115-
116-
# should output "foo-app"
117-
118-
curl ${LOADBALANCER_IP}/foo
119-
120-
# should output "bar-app"
121-
122-
curl ${LOADBALANCER_IP}/bar
123-
{{< /codeFromInline >}}
124-
125-
#### Option 2: extraPortMapping
126-
127-
The Ingress controller ports will be exposed in your `localhost` address
128-
129-
{{< codeFromInline lang="bash" >}}
59+
INGRESS_IP=$(kubectl get ingress example-ingress -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
13060

13161
# should output "foo-app"
13262

133-
curl localhost/foo
63+
curl ${INGRESS_IP}/foo
13464

13565
# should output "bar-app"
136-
137-
curl localhost/bar
66+
curl ${INGRESS_IP}/bar
13867
{{< /codeFromInline >}}
13968

14069
[LoadBalancer]: /docs/user/loadbalancer/

0 commit comments

Comments
 (0)