I have a VM created in Azure, and I'd like to connect to mariadb service (mariadb.mariadb.svc.cluster.local from cluster nodes)
It's possible to do that using the host name or a private IP?
Thanks!
if your service is of type clusterIP
(which is the default) then you can not access this service outside of Kubernetes. You need to change the type of service to NodePort
or clusterIP
I am not sure kube-proxy
can help here or not. this blog well describes all of this
considering you have access to k8s outside, definitely you can access pods outside k8s with help of
kubectl exec
get the shell of the running container in k8skubectl port-forward
maps container port with your local port.It's possible to do that using the host name or a private IP?
Absolutely!
In Kubernetes, the service is used to communicate with pods.
The default service type in Kubernetes is ClusterIP
ClusterIP is an internal IP address reachable from inside of the Kubernetes cluster only. The ClusterIP enables the applications running within the pods to access the service.
To expose the pods outside the kubernetes cluster, you will need k8s service of NodePort
or LoadBalancer
type.
ClusterIP
Service, to which the NodePort
Service routes, is automatically created. You’ll be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>
.Please note that it is needed to have external IP address assigned to one of the nodes in cluster and a Firewall rule that allows ingress traffic to that port. As a result kubeproxy on Kubernetes node (the external IP address is attached to) will proxy that port to the pods selected by the service.
NodePort
and ClusterIP
Services, to which the external load balancer routes, are automatically created.Alternatively, if you need to access HTTP/S (that is not the case here, but still worth mentioning) it is possible to use Ingress
There is a very good article on acessing Kubernetes Pods from Outside of cluster .
Hope that helps.