cloud-native-singapore / csj-cloud-architecture-2019

Google Cloud Study Jam 2019
2 stars 0 forks source link

Kubernetes - Connection refused #2

Open so0k opened 5 years ago

so0k commented 5 years ago

For the nodePort 31000 service... The Lab mentions connection times out, but the error message is refused

this is confusing, but do not worry - refused is the expected behaviour at that stage in the lab

$ IP=$(gcloud compute instances list --format="json" | jq -r ".[] | .networkInterfaces[].accessConfigs[].natIP" | head -n1)
$ curl -k https://$IP:31000
curl: (7) Failed to connect to 35.193.238.32 port 31000: Connection refused

Follow the instructions and the problem will be resolved

so0k commented 5 years ago

for frontEnd svc use the -w flag to wait for externalIP, then fetch with

IP=$(kubectl get services frontend -o json | jq -r .status.loadBalancer.ingress[].ip)

If you get

curl -k https://$IP
curl: (7) Failed to connect to 35.192.222.87 port 443: Connection refused

Check endpoints of the svc...

alias k=kubectl
k describe svc frontend
Name:                     frontend
Namespace:                default
...
Selector:                 app=frontend
...
Endpoints:                <none>

No endpoints, check the label query

 k get po -l app=frontend
NAME                       READY     STATUS    RESTARTS   AGE
frontend-f685c7476-v2lgc   0/1       Pending   0          4m

turns out the pod is pending, we can see why through describe

k describe po frontend-....
...
Events:
  Type     Reason            Age              From                                        Message
  ----     ------            ----             ----                                        -------
  Warning  FailedScheduling  7m (x5 over 8m)  default-scheduler                           0/3 nodes are available: 3 Insufficient cpu.
  Normal   Scheduled         3m               default-scheduler                           Successfully assigned 
...

delete some of the other pods to make space:

$ k delete po -l app=monolith
pod "monolith" deleted
pod "secure-monolith" deleted

and soon enough, the frontend pod should start running and you can complete the lab

so0k commented 5 years ago

refer also to https://cloud.google.com/blog/products/gcp/filtering-and-formatting-fun-with