0
votes

I’ve 3 servers : 1. kubernetes Master 2. kubernetes Minion1 3. kubernetes Minion2

A replication controller (with http service) running on kubernetes master with 4 replicas (pods) with a cluster IP 10.254.x.x

The cluster IP can accessible via busybox pod that is created by kubectl command.

Now I’ve installed docker on kubernetes Master server

Then start a container using docker run command. So Now My Question is: how to communicate between this docker container and kubernetes cluster IP??

The actual goal is: the docker container will act as a reverse proxy for kubernetes cluster IP

Docker container IP : 172.17.x.x
Kubernetes Pods IP : 172.17.x.x
Kubernetes cluster IP : 10.254.x.x 

Thanks.

3
Isn't it better to use an ingress controller?Grimmy
Inisde the cluster, Kubernetes will start the containers for you. You might want to try that since that is what essentially makes Kubernetes do its magic.Norbert van Nobelen

3 Answers

2
votes

As @Grimmy stated, I also think that is accomplished by the use of an ingress resource and an ingress controller.

For example, a pod with nginx and an ingress controller, can be used as a load balancer between the internet and your pods.

0
votes

A lot depends here on how you provisioned your kubernetes cluster.

To access services/pods/containers running in your kube cluster, you need kube-proxy running on your master and your non-kube docker container running within the overlay network that your cluster uses.

Service ClusterIPs are implemented on nodes by kube-proxy setting iptables rules, so, assuming you have a decent overlay configuration you should be able to access them not only from dockers, but the host it self (there might be some routing/nat issues to tackle depending on setup). Another issue is service discovery, which in kube works usualy via DNS, that is not exposed externally, so you'd need to point your external container/process to a different DNS server (or use different means of service discovery, like ie. querying/watching kubernetes api).

You can also use Services to expose your traffic with NodePort, where you can reach your svc on fixed port of every node in kube cluster or Ingress (and IngressController exposed with NodePort/LB).

That said, maybe you can just run this container within kubernetes and force it to schedule on master node (lookup node affinity and tolerations)

0
votes

You can expose pod using service with type NodePort. Then you will be able to access the pod outside of network also. If you have public IP is assigned to node then it will be expose to the public. Using that url you can connect to the container that is outside of k8s cluster.