These are my yaml files referenced by here (kubernetes.io/docs)
And I use command kubectl apply -f backend-deployment.yaml -f frontend-configmap.yaml -f frontend-deployment.yaml
Backend were launched successfully, but Frontend occured error.
[emerg] 1#1: host not found in upstream "backend-service" in /etc/nginx/conf.d/nginx.conf:2
#nginx: [emerg] host not found in upstream "backend-service" in /etc/nginx/conf.d/nginx.conf:2
Even if ‘backend-service’ is declared, nginx couldn’t recognize it.
Command nslookup backend-service
result is:
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find backend-service: SERVFAIL
What am I missing?
3
Answers
backend-deployment image : bateaux/test-nginx
frontend-deployment image : bateaux/test-node-server
When deploy backend-deployment, remove [livenessProbe, readinessProbe].
Because node.js express server use @cloudnative/health-connect To readinessProbe, so call PingCheck(worker node ip).
I have gotten closer to the issue/solution.
First of all, you if the images in your supplied answer are correct, you are running nginx in your backend deployment and node-js server on your frontend deployment. This is a mistake.
after changing the images frontend is running (as expected) but backend pod is crashing.
However, the backend pod is successfully resolving the mysql-service to its internal clusterIp and I appear to have wrong authentication setup.
if you look at the log. it says it tries to connect to 10.100.77.32:3306 and the output of kubectl get svc is the following
mysql-service ClusterIP 10.100.77.32 <none> 3306/TCP 17m
with the matching ip of my service.
kubectl get endpoints shows that the mysql-service has indeed found an endpoint:
and here is additional log information showing that the authentication mechanism of your nodejs application appearently is not working for the mysql pod.
However, with the changes suggest at the beginning of the answer the issues around resolving the service name and communicating inside of kubernetes should be resolved.
Wow….I found solution for
getaddrinfo EAI_AGAIN mysql-service
.I think if network can’t find service, there is error in dns.
kubectl logs --namespace=kube-system -l k8s-app=kube-dns
Result of command is gist.
So…I finally found this link about kubernetes coredns.
By belphegor’s answer, it works restart coredns.
Although, there is new error
Client does not support authentication protocol requested by server; consider upgrading MySQL client
, but i think to solve it is easier than dns error. hhhhhhhhhhhhhhhh