When curl is made inside pod on port 80, response is fine. Calling curl outside container via Kubernetes service on machines IP and port 30803, sporadically "Connection refused" appears.
nginx app config:
server {
listen 80;
server_name 127.0.0.1;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /usr/share/nginx/html;
index index.html;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Kubernetes deployments and service manifest which is used:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
namespace: dev
labels:
environment: dev
spec:
selector:
matchLabels:
environment: dev
replicas: 1
template:
metadata:
labels:
environment: dev
spec:
containers:
- name: web-app
imagePullPolicy: Never
image: web-app:$BUILD_ID
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: web-app-dev-svc
namespace: dev
labels:
environment: dev
spec:
selector:
environment: dev
type: NodePort
ports:
- name: http
nodePort: 30803
port: 80
protocol: TCP
targetPort: 80
kubectl get pods
to ensure the pod is not restarting and is in a ready state. You can also do akubectl get services
to also ensure that only one service is using that nodeport. This is kind of the first step for debugging. You can also later on look at the logs in your k8s node. You will probably find something about network issue in there. – Rattlerenvironment: dev
. Is there anything else deployed in the dev namespace with the same label that could be selected by the service?kubectl get po --show-labels
– Mccaskill