Merge pull request #15364 from spowelljr/ingressDoc

site: Add ingress example to getting started
pull/15370/head
Medya Ghazizadeh 2022-11-15 13:46:48 -08:00 committed by GitHub
commit f922ae914e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 95 additions and 0 deletions

View File

@ -587,6 +587,101 @@ kubectl get services balanced
Your deployment is now available at <EXTERNAL-IP>:80
{{% /tab %}}
{{% tab Ingress %}}
Enable ingress addon:
```shell
minikube addons enable ingress
```
The following example creates simple echo-server services and an Ingress object to route to these services.
```shell
kind: Pod
apiVersion: v1
metadata:
name: foo-app
labels:
app: foo
spec:
containers:
- name: foo-app
image: docker.io/ealen/echo-server:0.7.0
---
kind: Service
apiVersion: v1
metadata:
name: foo-service
spec:
selector:
app: foo
ports:
# Default port used by the image
- port: 80
---
kind: Pod
apiVersion: v1
metadata:
name: bar-app
labels:
app: bar
spec:
containers:
- name: bar-app
image: docker.io/ealen/echo-server:0.7.0
---
kind: Service
apiVersion: v1
metadata:
name: bar-service
spec:
selector:
app: bar
ports:
# Default port used by the image
- port: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- http:
paths:
- pathType: Prefix
path: "/foo"
backend:
service:
name: foo-service
port:
number: 80
- pathType: Prefix
path: "/bar"
backend:
service:
name: bar-service
port:
number: 80
---
```
Apply the contents
```shell
kubectl apply -f https://storage.googleapis.com/minikube-site-examples/ingress-example.yaml
```
Wait for ingress address
```shell
kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress nginx * <your_ip_here> 80 5m45s
```
Now verify that the ingress works
```shell
curl <ip_from_above>/foo
curl <ip_from_above>/bar
```
{{% /tab %}}
{{% /tabs %}}
<h2 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">5</strong></span>Manage your cluster</h2>