Installation nginx-ingress for Kubernetes Cluster On Premise with CentOS7

2/20/2020

I don't sure which installation section is relevant for Cluster On-Premise with CentOS7 in below link https://kubernetes.github.io/ingress-nginx/deploy/

I tried to install via helm chart, but the service created with type=LoadBalance although the cluster is not on cloud

my questions is:

Helm is the only option to install Nginx not for could (or maybe bare-metal is correct in my case)?

In case of the helm which parameters should be overridden when the helm is installed (service.type etc ...)?

thanks

-- Mortova
kubernetes
kubernetes-ingress
nginx-ingress

4 Answers

2/20/2020

If you want to use Type=LoadBalancer then I recommend installing METALLB.

MetalLB is a load-balancer implementation for bare metal Kubernetes clusters, using standard routing protocols.

Why?

Kubernetes does not offer an implementation of network load-balancers (Services of type LoadBalancer) for bare metal clusters. The implementations of Network LB that Kubernetes does ship with are all glue code that calls out to various IaaS platforms (GCP, AWS, Azure…). If you’re not running on a supported IaaS platform (GCP, AWS, Azure…), LoadBalancers will remain in the “pending” state indefinitely when created.

Bare metal cluster operators are left with two lesser tools to bring user traffic into their clusters, “NodePort” and “externalIPs” services. Both of these options have significant downsides for production use, which makes bare metal clusters second class citizens in the Kubernetes ecosystem.

MetalLB aims to redress this imbalance by offering a Network LB implementation that integrates with standard network equipment, so that external services on bare metal clusters also “just work” as much as possible.

Instalation guide is here

-- Spook
Source: StackOverflow

3/9/2020

I found the way to install nginx for bare-metal by helm chart:

helm install idit-nginx stable/nginx-ingress --namespace kube-system --set controller.service.type=NodePort
--set controller.image.pullPolicy=IfNotPresent --version 1.33.1

-- Mortova
Source: StackOverflow

2/20/2020

Using helm you can set controller.service.type to NodePort. That way for nginx ingress controller a NodePort service will be created and you can use NodeIP and NodePort to access backend kubernetes services by creating ingress resource.

Having said that there is no default configuration provided in helm chart for it to work on bare metal. So you need to try it few times. Otherwise you can use the standard yaml provided for bare metal which uses NodePort.

-- Arghya Sadhu
Source: StackOverflow

2/20/2020

In bare metal installations is not possible to use Ingress by default, you need to use MetalLB.

The Nginx docs shows how to setup MetalLB to allow your bare metal cluster the usage of LoadBalancer Services.

MetalLB provides a network load-balancer implementation for Kubernetes clusters that do not run on a supported cloud provider, effectively allowing the usage of LoadBalancer Services within any cluster.

Basically, the setup is easy:

kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.3/manifests/metallb.yaml

And then create a ConfigMap to configure: - Edit the ip range according yout network

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.1.240-192.168.1.250 <= EDIT IP RANGE

Check the installation typing kubectl get pods -n metallb-system, this is an expected output:

$ kubectl get pods -n metallb-system
NAME                          READY   STATUS    RESTARTS   AGE
controller-65895b47d4-6wzfr   1/1     Running   0          9d
speaker-v52xj                 1/1     Running   0          9d

After MetalLB installed and configured can install Nginx Ingress following the nginx docs:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.29.0/deploy/static/mandatory.yaml

And then:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.29.0/deploy/static/provider/baremetal/service-nodeport.yaml

If you prefer, you could use Helm:

helm install my-nginx stable/nginx-ingress

If the kubernetes cluster has RBAC enabled, then run:

helm install my-nginx stable/nginx-ingress --set rbac.create=true

If you are using Helm 2 then specify release name using --name flag

helm install stable/nginx-ingress --name my-nginx

or

helm install stable/nginx-ingress --name my-nginx --set rbac.create=true

Detect installed version:

POD_NAME=$(kubectl get pods -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}') kubectl exec -it $POD_NAME -- /nginx-ingress-controller --version

References:

https://kubernetes.github.io/ingress-nginx/deploy/

https://metallb.universe.tf/

-- KoopaKiller
Source: StackOverflow