Fedora39でminikube - IngressをDeployする(1)

[Fedora39でminikube - LoadBalancerをDeployする(1)](https://qiita.com/intrajp/items/b0234e7a1c040e8bca55)からの続きです。

ingressアドオンを minikube において有効にします。

```BASH
@fedora:~$ minikube addons enable ingress
💡  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
    ▪ registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20231011-8b53cabe0 イメージを使用しています
    ▪ registry.k8s.io/ingress-nginx/controller:v1.9.4 イメージを使用しています
    ▪ registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20231011-8b53cabe0 イメージを使用しています
🔎  ingress アドオンを検証しています...
🌟  'ingress' アドオンが有効です
```

ingress-example.yaml を作成します。

```YAML
kind: Pod
apiVersion: v1
metadata:
  name: foo-app
  labels:
    app: foo
spec:
  containers:
    - name: foo-app
      image: 'kicbase/echo-server:1.0'
---
kind: Service
apiVersion: v1
metadata:
  name: foo-service
spec:
  selector:
    app: foo
  ports:
    - port: 8080
---
kind: Pod
apiVersion: v1
metadata:
  name: bar-app
  labels:
    app: bar
spec:
  containers:
    - name: bar-app
      image: 'kicbase/echo-server:1.0'
---
kind: Service
apiVersion: v1
metadata:
  name: bar-service
spec:
  selector:
    app: bar
  ports:
    - port: 8080
---
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: 8080
          - pathType: Prefix
            path: /bar
            backend:
              service:
                name: bar-service
                port:
                  number: 8080
---
```

上記 yaml ファイルを適用します。

```BASH
@fedora:~$ kubectl_m apply -f ingress-example.yaml 
pod/foo-app created
service/foo-service created
pod/bar-app created
service/bar-service created
ingress.networking.k8s.io/example-ingress created
```

ingress アドレスを取得します。

```BASH
@fedora:~$ kubectl get ingress
NAME              CLASS   HOSTS   ADDRESS          PORTS   AGE
example-ingress   nginx   *       192.168.59.100   80      4m2s
```

```BASH
@fedora:~$ minikube tunnel

💡  TUNNEL_ALREADY_RUNNING が原因で終了します: 別のトンネル プロセスが既に実行中です。既存のインスタンスを終了して新しいインスタンスを開始してください
```

現在立ち上がっているプロセスを、CTL+C で止めてから、再度実行します。

```BASH
@fedora:~$ minikube tunnel

Status:	
	machine: minikube
	pid: 21062
	route: 10.96.0.0/12 -> 192.168.59.100
	minikube: Running
	services: [balanced]
    errors: 
		minikube: no errors
		router: no errors
		loadbalancer emulator: no errors
  ```

192.168.59.100/foo　にアクセスします。

```
Request served by foo-app

HTTP/1.1 GET /foo

Host: 192.168.59.100
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0
X-Forwarded-For: 192.168.59.1
X-Forwarded-Host: 192.168.59.100
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Scheme: http
X-Real-Ip: 192.168.59.1
X-Request-Id: 3fe91d9c272478c6ef409ac58731b85e
X-Scheme: http
```

192.168.59.100/bar にアクセスします。

```
Request served by bar-app

HTTP/1.1 GET /bar

Host: 192.168.59.100
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0
X-Forwarded-For: 192.168.59.1
X-Forwarded-Host: 192.168.59.100
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Scheme: http
X-Real-Ip: 192.168.59.1
X-Request-Id: 0563ab65bbd95ec230674e07b0842bce
X-Scheme: http
```

(参考)[minikube start](https://minikube.sigs.k8s.io/docs/start/)

[Fedora40でminikube - minikube をアップグレードする(1)](https://qiita.com/intrajp/items/9dbadca77d738c5bb819)につづく。