As various google articles(Example : this blog) states that this(connecting Kube cluster through proxy and clusterIP) method isn’t suitable for a production environment, but it’s useful for development.
My question is why it is not suitable for production ? Why connecting through nodeport service is better than proxy and clusterIP ?
Lets distinguish between three scenarios where connecting to the cluster is required
Connecting to Kubernetes API Server Connecting to the API server is required for administrative purposes. The users of your application have no business with it. The following options are available
kubectl proxy
to to make the Kubernetes API available on your localhost.Connecting external traffic to your applications running in the Kubernetes Cluster. Here you want to expose your applications to your users. You'll need to configure a Service and they can be of the following types
Ingress: This isn't a type of service, it is another type of Kubernetes resource. By configuring NGINX Ingress for example, you can handle traffic to multiple ClusterIP services with only on external LoadBalancer.
kubectl port-forward
: Port forwarding example Requires kubectl
to be configured on the system hence it cannot be used for all users of the applicationAs you can see from the above explanation, the proxy and port-forwarding option aren't viable options for connecting external traffic to the applications running because it requires your kubectl
installed and configured with a valid kubeconfig
which grants access into your cluster.