I tried to read the docs as much as I can but I think because I’m new to k8s, I cannot understand some words or phrases so I have some questions and there are some how tos. I’m sorry if these amateur questions bother you:(
Does k8s automatically manages load balancing? I mean suppose I have one master and two worker nodes. If I write a simple docker-compose.yml with below contents and I use kompose convert, then the average load of master is 8, first worker is 9 and the second worker is 3.
So if I run kubectl apply -k ., does this only runs on master? Or if would run on the node having the most free resources?
Now suppose I have two master and two worker nodes. Then does the answer changes?
If you use LoadBalancer as the service type, I think that is managed by the Cloud Controller Manager (CCM) that was created by the Cloud Platform you’re on. They typically spin up a cloud load balancer.
As you said I think that is managed by the Cloud Controller Manager (CCM) that was created by the Cloud Platform you’re on, I’m not on any cloud platform. I’m currently on virtualbox on my laptop but I’ll be soon on bare metal servers.
So since I’m on my own server, does your answer change? Or in this case the Cloud Platform mean my server itself?
You can roll your own solution; perhaps following something like an operator pattern and watch for new load balancer type services; there is further documentation with boiler plate here.
OR you can just completely ignore using load balancer type services and use an ingress controller like nginx or traefik. If you go the traefik path, it gives you an entirely additional custom resource to configure named virtual hosts and just path routing in general.
Got it, you’re trying to figure out where the test pod ends up being scheduled. Just a side note, if you need to control what node a pod runs on, check out this doc.
Regarding the scheduling, I can’t find an answer on how to directly determine where a pod will end up, but I found this explanation.
If you’re just consuming a cluster, it seems knowing how to control node selection and just trusting that the Kubernetes schedule is making good choices.
You can determine the distribution from the list of pods with kubectl get pods -A -o wide though. So if something looks fishy about the scheduling, it’s at least observable.
Notes From Using kompose
These are just notes I took to show what the k8s YAML ends up being.
Well you should likely consider looking at the ingress controller for load balancing within the cluster, but you can use Netris to automatically create load balancers external to the pod and distribute traffic across multiple ingresses, or multiple pods.