# Installation Guide - Nginx ingress-controller, MetalLB loadbalancer
###### tags: `Kubernetes`
## Install MetalLB loadbalacer
> Creste namespace
> You will see the metallb-system in namespace
```
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/namespace.yaml
```
> Create deployment
> You will see the two pods
> * controller
> * speaker
```
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/metallb.yaml
```
> Create sercet
```
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
```
> Create ConfigMap (metallb_configmap.yml)
```
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: my-ip-space
protocol: layer2
addresses:
- 192.168.100.240-192.168.100.249
```
> Note: The IP addresses range need to be aviliable.
> Then create the configmap.
```
kubectl apply -f metallb_configmap.yml
```
> After above steps, we finish to install the metallb.
## Install the Ingress-controller
> Create an namespace.yml
```
# namespace controller
apiVersion: v1
kind: Namespace
metadata:
name: controller
```
> Create namespace
```
kubectl apply -f namespace.yml
```
> Use the Helm to install controller
```
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm install my-release ingress-nginx/ingress-nginx -n controller
```
> p.s. you can use below cmd to install Helm
```
snap install helm --classic
```
## Reference
> http://brobridge.com/bdsres/2019/10/31/%E5%A6%82%E4%BD%95%E8%87%AA%E5%B7%B1%E5%BB%BA%E6%A7%8B-k8s-loadbalancer/
>
> https://metallb.universe.tf/installation/
>
> https://kubernetes.github.io/ingress-nginx/deploy/
>
> https://helm.sh/