Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a service using a LoadBalancer in microk8s

When exposing a service in minikube it is possible to see its url via the following:

minikube service [-n NAMESPACE] [--url] NAME

How do you achieve the same in microk8s?

Thank you

like image 811
user2324712 Avatar asked Jan 05 '19 12:01

user2324712


People also ask

How LoadBalancer service works in Kubernetes?

The Kubernetes load balancer sends connections to the first server in the pool until it is at capacity, and then sends new connections to the next available server. This algorithm is ideal where virtual machines incur a cost, such as in hosted environments.

How do you expose a service in Kubernetes?

From the Service type drop-down list, select Node port. Click Expose. When your Service is ready, the Service details page opens, and you can see details about your Service. Under Ports, make a note of the Node Port that Kubernetes assigned to your Service.

How do I access Clusterber services in Kubernetes from outside?

To reach the ClusterIp from an external computer, you can open a Kubernetes proxy between the external computer and the cluster. You can use kubectl to create such a proxy. When the proxy is up, you're directly connected to the cluster, and you can use the internal IP (ClusterIp) for that Service .

What is the main use of a service of type LoadBalancer?

A service of type LoadBalancer is the simplest and the fastest way to expose a service inside a Kubernetes cluster to the external world. You only need to specify the service type as type=LoadBalancer in the service definition. Services of type LoadBalancer are natively supported in Kubernetes deployments.


1 Answers

Realizing this is an older post, but since I just recently implemented a dev install of MicroK8s, I though perhaps I could provide some of my findings.

Wanting a load balancer, I installed MetalLB, https://metallb.universe.tf/, which provides a baremetal LB for a cluster. While MicroK8s does offer an addon for this, I did a manual installation to help myself gain a better understanding.

I used the Layer 2 Configuration option, https://metallb.universe.tf/configuration/#layer-2-configuration which provided a very simple way to expose my services via a load balancer.

To use the config, I then added an annotation to the services that utilize it, indicating which address pool, which for my deployment, I simply call microk8s_pool.

metallb.universe.tf/address-pool: microk8s_pool
like image 76
8675309 Avatar answered Oct 16 '22 02:10

8675309