2

I'm getting problem accessing k8s service from outside of cluster

  • K8s version: v1.25
  • MetalLB version: 0.13 (Flannel v0.20)

IP pool

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 151.62.196.222-151.62.196.222

Advertisement

apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: adv
  namespace: metallb-system
spec:
  ipAddressPools:
  - first-pool

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

Service

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

When I check services, I saw the nginx-service has been assigned IP (EXTERNAL-IP: 151.62.196.222)

But when I try to access, it returns me error

curl: (7) Failed to connect to 151.62.196.222 port 80 after 15 ms: Connection refused

Anyone experienced the same problem? Thanks!

I tried to access it from the cluster, and it works, returned me the nginx welcome page

Anh Tran
  • 21
  • 1

0 Answers0