Reputation: 1878
I am running my kubernetes cluster using kubeadm (local using VMWare VMs). As a part of installation , I have installed Weave Network Adapter to establish relation between master and slave.
I could able to create the pods and services successfully. Even, could able to get the application using the private IP that kubeadm has given.
The problem is , I am not able to access the same application using my system although network is shared with VMs and my local machine. This is what is expected. The main reason being private network.
I want to access the application in my local machine which is outside of the private kubernates networks.
Point to be remembered : I am hosting everything on my local machine using VMWare VMs.
Can anybody help me on this ?
Upvotes: 0
Views: 1282
Reputation: 30801
I think you are looking for this. I had the same issue when I tried everything locally. You'll need to use --type=NodePort
For example I've created a deployment:
./cluster/kubectl.sh run my-jenkins --image=jenkins:1.651.1 --replicas=1 --port=8080 –-namespace=jenkins
I check the pod
kubectl --namespace=jenkins get pods
NAME READY STATUS RESTARTS AGE
my-jenkins-1908062973-7b44z 1/1 Running 0 24s
My deployment created a pod + replicaSet for me in the deploymentconfig. Now I want to create a service above my pod
./cluster/kubectl.sh expose rs my-jenkins-1908062973 --port=80 --target-port=8080 --type=NodePort --name=jenkins-service --namespace=jenkins
Thanks to the --type=NodePort
I'm able to visit my service also locally
If you set the type field to "NodePort", the Kubernetes master will allocate a port from a flag-configured range (default: 30000-32767), and each Node will proxy that port (the same port number on every Node) into your Service. That port will be reported in your Service’s spec.ports[*].nodePort field.
Upvotes: 2