How to fix empty external IP from nginx ingress on k3s?

4k Views Asked by At

I want use metallb and nginx ingress for my k3s cluster.

Currently the external IP is <none>

  kubectl -n ingress-nginx get svc
NAME                                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller-admission   ClusterIP   10.43.182.71   <none>        443/TCP                      14m
ingress-nginx-controller             NodePort    10.43.221.32   <none>        80:31121/TCP,443:31807/TCP   14m

I expect it to be 192.168.178.240

I installed k3s with

export K3S_KUBECONFIG_MODE="644"
export INSTALL_K3S_EXEC=" --disable servicelb --disable traefik"
export KUBECONFIG="~/.kube/config:/etc/rancher/k3s/k3s.yaml"

curl -sfL https://get.k3s.io | sh -

then I installed metallb with

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

with the config kubectl apply -f config.yaml

config.yaml 
---
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.178.240-192.168.178.250

then I installed nginx ingress baremetal

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/baremetal/deploy.yaml

All pods are running

  % k3s kubectl get pods --all-namespaces -o wide
NAMESPACE        NAME                                        READY   STATUS      RESTARTS   AGE   IP                NODE         NOMINATED NODE   READINESS GATES
kube-system      metrics-server-86cbb8457f-xmp4w             1/1     Running     0          42m   10.42.0.3         master-pi4   <none>           <none>
kube-system      coredns-854c77959c-vlpxf                    1/1     Running     0          42m   10.42.0.2         master-pi4   <none>           <none>
kube-system      local-path-provisioner-5ff76fc89d-l6nmk     1/1     Running     0          42m   10.42.0.4         master-pi4   <none>           <none>
metallb-system   speaker-zghmh                               1/1     Running     0          40m   192.168.178.37    master-pi4   <none>           <none>
metallb-system   controller-64f86798cc-bgcvw                 1/1     Running     0          40m   10.42.1.2         node1-pi4    <none>           <none>
metallb-system   speaker-cjjl4                               1/1     Running     0          40m   192.168.178.240   node1-pi4    <none>           <none>
metallb-system   speaker-pnmzm                               1/1     Running     0          40m   192.168.178.35    node2-pi3    <none>           <none>
ingress-nginx    ingress-nginx-admission-patch-kmt2s         0/1     Completed   1          19m   10.42.0.5         master-pi4   <none>           <none>
ingress-nginx    ingress-nginx-admission-create-7j98l        0/1     Completed   0          19m   10.42.0.6         master-pi4   <none>           <none>
ingress-nginx    ingress-nginx-controller-7b78df5bb4-6t2jz   1/1     Running     0          19m   10.42.1.3         node1-pi4    <none>           <none>

Why is the ingress controller not assigned an external IP?

1

There are 1 best solutions below

0
On

In side the deploy.yml the Service is defined as NodePort it has to be changed to LoadBalancer. Then the nginx ingress will run as load balancer.