How to install Ingress Nginx Controller on K8S

Deploy Ingress Nginx Controller with MetalLB LoadBalancer

Blog Single

Install Nginx Ingress Controller in Kubernetes

  • Download Nginx controller deployment for Baremetal:
    controller_tag=$(curl -s https://api.github.com/repos/kubernetes/ingress-nginx/releases/latest | grep tag_name | cut -d '"' -f 4) wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/${controller_tag}/deploy/static/provider/baremetal/deploy.yaml

  • Rename deployment file:
    mv deploy.yaml nginx-ingress-controller-deploy.yaml

  • Apply Nginx ingress controller manifest deployment file:
    kubectl apply -f nginx-ingress-controller-deploy.yaml

Setting Nginx Ingress to use MetalLB

  • Patch ingress-nginx-controller service by setting service type to LoadBalancer.
    kubectl -n ingress-nginx patch svc ingress-nginx-controller --type='json' -p '[{"op":"replace","path":"/spec/type","value":"LoadBalancer"}]'
  • Edit ingress-nginx-controller service and set externalIPs
    vim external-ips.yaml
      spec:
        externalIPs:
         - Your Node IP

     
  • Now let's apply the patch to the service.
    kubectl -n ingress-nginx patch svc ingress-nginx-controller --patch "$(cat external-ips.yaml)"