{"id":569,"date":"2018-04-03T07:36:25","date_gmt":"2018-04-03T15:36:25","guid":{"rendered":"http:\/\/andrewwippler.com\/?p=569"},"modified":"2018-04-02T08:16:45","modified_gmt":"2018-04-02T16:16:45","slug":"allowing-outside-access-to-home-kubernetes-cluster","status":"publish","type":"post","link":"https:\/\/andrewwippler.com\/2018\/04\/03\/allowing-outside-access-to-home-kubernetes-cluster\/","title":{"rendered":"Allowing outside access to Home Kubernetes Cluster"},"content":{"rendered":"
After I created a home kubernetes cluster, I immediately wanted to allow external access to pods\/services\/ingresses hosted inside the cluster. One must be aware that in bare metal environments, there is no receiver of an api call to create a load balancer. Since there is not a scriptable environment available to kubernetes, kubernetes cannot request external IP addresses or provision resources that one has come to expect in cloud environments such as AWS. This is a huge bummer – especially since dynamically built environments are fun to have.<\/p>\n
To route traffic to web services inside of kubernetes, you have to options available: The overall view of this traffic is going to be: To create an ingress in kubernetes, you have to make it a ingress<\/code> and
service<\/code>. Services can be exposed via
NodePort<\/code>,
LoadBalancer<\/code>, or
ClusterIP<\/code>. In bare metal,
LoadBalancer<\/code>\u00a0would never work (unless you coded your own API call to configure a load balancer outside of kubernetes).
ClusterIP<\/code>\u00a0might work if you want to manage a routing table somewhere inside your network, and
NodePort<\/code>\u00a0will work if you want to manage a port forwarding table on your router. None of these options are fun for home labs on bare metal. An
Ingress<\/code>\u00a0is like a layer 7 firewall in that it reads the hostname and path of the incoming HTTP request and can route to applicable services. This works great for a dynamic environment where I am going to host multiple http endpoints.<\/p>\n
Internet<\/code>\u00a0>
Router<\/code> >
k8s Ingress<\/code>\u00a0>
k8s Service<\/code>\u00a0>
Pod(s)<\/code>.<\/p>\n
Service<\/code>. In cloud environments, the
Ingress<\/code>\u00a0is created as type
LoadBalancer<\/code>\u00a0in home labs, we create this as type
NodePort<\/code>\u00a0and port forward on the router to any node in the kubernetes cluster.<\/p>\n
$ kubectl get svc -n ingress-nginx\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\ndefault-http-backend ClusterIP 10.102.173.184 80\/TCP 3d\ningress-nginx NodePort 10.110.162.247 80:30746\/TCP,443:32641\/TCP 3d\n<\/code><\/pre>\n