Hi all!
I’ve been trying microk8s and the getting started tutorial on the homepage actually does something I would not expect to work (and it does not, when I repro it)
So on the website: https://microk8s.io/ there is a shell recording of the following commands after having an nginx running:
$ microk8s kubectl expose deployment nginx --port 80 --target-port 80 --selector app=nginx --type ClusterIP --name nginx
$ microk8s kubectl get all ip-172-31-40-63: Mon Sep 28 11:50:20 2020
NAME READY STATUS RESTARTS AGE
pod/nginx-6799fc88d8-9gnkw 1/1 Running 0 53s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 2m44s
service/nginx ClusterIP 10.152.183.7 <none> 80/TCP 12s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 53s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-6799fc88d8 1 1 1 53s
Ok, this bit exposes port 80 to port 80 and then the example does the following on his ubuntu host machine:
ubuntu@ip-172-31-40-63:~$ curl 10.152.183.7
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head> <body> <h1>Welcome to nginx!</h1>
When I try this, I cannot access the IP at all (I know mine has a different assigned ip), but it would also be awful, if I could, wouldn’t it?
Why is the example working at all? The exposed port is of ClusterIP type and not a nodeport.
AFAIK this would be possible at best when the example previously spawned a container like busybox and entered its shell to do curl from inside the cluster. (Which is not visible in the getting started thing).
But for a newbie this curl step is super magic as it skips the “understand the whole k8s thing first” and produces results that me as a beginner won’t get.
I am probably missing some important thing and would love to get a hint about what I am getting wrong.
Thanks!