I'm following a course on PluralSight where the course author puts a docker image onto kubernetes and then access it via his browser. I'm trying to replicate what he does but I cannot manage to reach the website. I believe I might be connecting to the wrong IP.
I have a ReplicationController
that's running 10 pods
:
rc.yml
apiVersion: v1
kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 10
selector:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080
I then tried to expose the rc:
kubectl expose rc hello-rc --name=hello-svc --target-port=8080 --type=NodePort
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-svc 10.27.254.160 <nodes> 8080:30488/TCP 30s
kubernetes 10.27.240.1 <none> 443/TCP 1h
My google container endpoint is : 35.xxx.xx.xxx
and when running kubectl describe svc hello-svc
the NodePort is 30488
Thus I try to access the app at 35.xxx.xx.xxx:30488
but the site can’t be reached.
If you want to access your service via the NodePort port, you need to open your firewall for that port (and that instance).
A better way is to create a service of type LoadBalancer (--type=LoadBalancer
) and access it on the IP Google will give you.
Do not forget to delete the load balancer when you are done.