0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Last updated at Posted at 2024-04-21

Fedora39でminikube - LoadBalancerをDeployする(1)からの続きです。

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

@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 を作成します。

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 ファイルを適用します。

@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 アドレスを取得します。

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

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

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

@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

Fedora40でminikube - minikube をアップグレードする(1)につづく。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?