<p>I have installed a kubernetes cluster using this <a href="https://www.edureka.co/blog/install-kubernetes-on-ubuntu" rel="nofollow noreferrer">tutorial.</a> 
When I've set it up on VM Virtual Box - my host can connect with NodePort normally. When I've tried it on Compute Engine Virtual Machine instance, the Kubernetes cluster can't connect host with NodePort?</p>

<p>I have attached two pictures.
Thank you for your support.</p>

<p><a href="https://i.stack.imgur.com/jE2G5.png" rel="nofollow noreferrer">Kubernetes cluster (bare metal) on Local VM Virtual Box</a>
<a href="https://i.stack.imgur.com/Pv5s3.png" rel="nofollow noreferrer">Kubernetes cluster (bare metal) on Google cloud Platform VM Instances </a></p>

<p>This took me a while to test but I finally have a result. So it turns out the reason of your issue is Calico and GCP firewall. To be more specific you have to add firewall rules before you can be successful with the connectivity. 
Following this <a href="https://docs.projectcalico.org/v2.0/getting-started/kubernetes/installation/gce" rel="nofollow noreferrer">document</a> on installing Calico for GCE:</p>

<blockquote>
  <p>GCE blocks traffic between hosts by default; run the following command
  to allow Calico traffic to flow between containers on different hosts
  (where the source-ranges parameter assumes you have created your
  project with the default GCE network parameters - modify the address
  range if yours is different):</p>
</blockquote>

<p>So you need to allow the traffic to flow between containers:</p>

<p><code>gcloud compute firewall-rules create calico-ipip --allow 4 --network "default" --source-ranges "10.128.0.0/9"</code></p>

<p>Note that this IP should be changed. You can use for test purposes <code>10.0.0.0/8</code> but this is way to wide range so <strong>please narrow it down to your needs.</strong> </p>

<p>Then proceed with setting up instances for master and nodes.
You can actually skip most of the steps from the tutorial you posted, as connectivity is resolved by cloud provider. Here is a really simple script I use for Kubeadm on VM's. You can also perform this step by step.  </p>

<pre><code>#!/bin/bash
swapoff -a
echo net/bridge/bridge-nf-call-ip6tables = 1 &gt;&gt; /etc/ufw/sysctl.conf
echo net/bridge/bridge-nf-call-iptables = 1 &gt;&gt; /etc/ufw/sysctl.conf
echo net/bridge/bridge-nf-call-arptables = 1 &gt;&gt; /etc/ufw/sysctl.conf
apt-get install -y ebtables ethtool
apt-get update
apt-get install -y docker.io
apt-get install -y apt-transport-https
apt-get install -y curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat &lt;&lt;EOF &gt;/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
kubeadm init --pod-network-cidr=192.168.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.2/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml
kubectl taint nodes --all node-role.kubernetes.io/master-
</code></pre>

<p>In my case I used simple Redis application from Kubernetes <a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook/#start-up-the-redis-master" rel="nofollow noreferrer">documentation</a></p>

<pre><code>root@calico-master:/home/xxx# kubectl get svc
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kubernetes     ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP    29m
redis-master   ClusterIP   10.107.41.117   &lt;none&gt;        6379/TCP   26m

root@calico-master:/home/xxx# kubectl get pods -o wide
NAME                            READY   STATUS    RESTARTS   AGE   IP            NODE     NOMINATED NODE
redis-master-57fc67768d-5lx92   1/1     Running   0          27m   192.168.1.4   calico   &lt;none&gt;

root@calico-master:/home/xxx# ping 192.168.1.4
PING 192.168.1.4 (192.168.1.4) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=63 time=1.48 ms
</code></pre>

<p>Before the firewall rules and regular Calico installation I was not able to ping, nor <code>wget</code>from the service  after that there is no problem with pinging the IP or hostname and also wget works:</p>

<pre><code>&gt; root@calico-master:/home/xxx# wget http://10.107.41.117:6379
&gt; --2018-10-24 13:24:43--  http://10.107.41.117:6379/ Connecting to 10.107.41.117:6379... connected. HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9 Length: unspecified
&gt; Saving to: ‘index.html.2’
</code></pre>

<p>Steps above were also tested for <code>type: NodePort</code> and it works as well. </p>

<p>Another way is to use <a href="https://github.com/coreos/flannel" rel="nofollow noreferrer">Flannel</a> which I also tested and it worked out of the box for the needs of testing your issue. Be sure to read more about CNI’s so you can choose one that will suit your needs.
Hope this solves your problem. </p>
