There have been a few questions in the community asking about service load balancer options when using Tanzu Community Edition (TCE). Out of the box, TCE does support NSX Advanced Load Balancer (NSX-ALB), but most folks will probably not have access to NSX-ALB or the resources to set that up. As an alternative, either kube-vip and metallb can be used and they are completely free and easy to setup.
I personally have used metallb before and I definitely recommend it for its ease of use and setup. You can find the instructions below on setting up metallb with TCE along with a sample kubernetes (k8s) application to verify its functionality.
Note: Scott Rosenberg is also doing some interesting stuff with Carvel that would enable easy deployment of kube-vip and metallb in TCE. I am hoping I will get some time to take a look at this setup as I think this would be great user experience for TCE just like you can install other k8s applications.
Step 1 - Install metallb into your TCE Workload Cluster:
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.3/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.10.3/manifests/metallb.yaml
Step 2 - Create the metallb configuration which will define the IP Address range that will be allocated for load balancer requests:
cat > metallb-config.yaml <<EOF apiVersion: v1 kind: ConfigMap metadata: namespace: metallb-system name: config data: config: | address-pools: - name: default protocol: layer2 addresses: - 192.168.30.240-192.168.30.241 EOF
Step 3 - Install the metallb ConfigMap:
kubectl apply -n metallb-system -f metallb-config.yaml
Verify that all metallb Pods are running:
kubectl -n metallb-system get pods
Step 4 - Deploy sample k8s application that uses service type load balancer such as the famous Yelb application:
kubectl create ns yelb
kubectl -n yelb apply -f https://raw.githubusercontent.com/lamw/yelb/master/deployments/platformdeployment/Kubernetes/yaml/yelb-k8s-loadbalancer.yaml
Verify that all Yelb Pods are running:
kubectl -n yelb get pods
Step 5 - Verify Yelb application has allocated an IP Address out of the metallb address range:
kubectl -n yelb get svc
Step 6 - Open a browser to the IP Address shown from the previous step and if everything was configured successfully, you should see the following: