I have 1 Master and 2 worker nodes. I dont want to use a hosted Kubernetes solution. The servers live in separate hosting providers (not sure if this is important). I want to be able to access my web application. Im not sure if this means I need to connect to the Pod directly or use some type of load balancing. I figured that right now, the app is running on one Node, but I might want to scale up it so then I would need a solution for a more "dynamic lookup". I have not tried Ingress yet, not sure if that would help. I tried using NodePort ( since im only running one replica right now) and that doesn't work, and also, from what I've read about NodePort this could be a slight security risk. So then I tried MetalLB, since Im not using a cloud-load balancer, and although <External - IP> is allocated (a private IP allocated from the range of IPs for both worker nodes), I thought I could connect to the application with one (or both) of the Nodes that exist within the cluster, ie. Worker1 -> Worker2 but I still can't connect to the application. If I can use MetalLB Id like to use it, but if NodePort is the only option I can revert to that and try to make it work. I know Im missing something, whether IP tables configuration (I didn't adjust it, I was confused about what chain to update) or just not using the correct Service. Im using Flannel CNI as well. Just to add I have installed tcdump
and arping
. arping works on the Node that has the load balancer but that's all, any other node doesn't work. If not obvious by now I am a beginner in Kubernetes, so I probably got something screwed up somewhere. I feel like in both instances (NodePort/LB) I am close. Below is the configuration for Metallb.
End Goal:
from ANY location
curl http://<some-ip>:80000
I've followed:
the section on metal https://www.datapacket.com/blog/build-kubernetes-cluster but changed to the updated CRD of IPAddressPool
For NodePort:
https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
https://github.com/nigelpoulton/TheK8sBook and the supplemental reading
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: dispatch
namespace: metallb-system
spec:
ipAddressPools:
- config
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
namespace: metallb-system
name: config
spec:
addresses:
- <worker1 range of IPs> # based of worker 1 IP
- <worker2 range of IPs> # based of worker 2 IP
apiVersion: v1
kind: Service
metadata:
name: app-balancer
spec:
type: LoadBalancer
ports:
- name: app
port: 8000
protocol: TCP
targetPort: 8000
selector:
app: my-app