0

This question was previously posted here. As community member suggested, asking here should be more appropriate.

I'm learning metallb loadbalancer objects, I have a basic nginx pod and I want to access it by an ip address. Using k3d I spin a new cluster by executing k3d cluster create ing3 --no-lb. Then I istalled metallb by applying the manifest indicated in installation docs:

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.8/config/manifests/metallb-native.yaml

Then I installed an IPAddressPool and L2Advertisement by applying the following manifest:

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: metallb-pool
  namespace: metallb-system
spec:
  addresses:
    - 172.20.0.140-172.20.0.160
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: l2adv
  namespace: metallb-system
spec:
  ipAddressPools:
    - metallb-pool

I installed the mentioned nginx by applying the following manifest:

apiVersion: v1
kind: Namespace
metadata:
  name: dummy-nginx
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: dummy-nginx
  labels:
    app.kubernetes.io/name: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: nginx
  template:
    metadata:
      labels:
        app.kubernetes.io/name: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:latest
          ports:
            - name: http
              containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: dummy-nginx-srv
  namespace: dummy-nginx
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: nginx
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80

Then added the LoadBalancer object:

apiVersion: v1
kind: Service
metadata:
  name: dummy-lb-test
  labels:
    app.kubernetes.io/name: nginx
spec:
  selector:
    app.kubernetes.io/name: nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 80
  type: LoadBalancer

applying that content to the same namespace as the nginx, dummy-nginx. I saw no error during installation, so I thought everything to be in place, service in dummy-nginx namespace has external ip 172.20.0.141 accordingly to the ip pool, and I could reach nginx while portforwarding. But doing curl 172.20.0.141 I cannot reach the nginx service, what am I missing?

Francesco
  • 101

0 Answers0