Kubernetes deployment connection refused
Kubernetes deployment connection refused
I'm trying to deploy a simple python app to Google Container Engine:
I have created a cluster then run kubectl create -f deployment.yaml
It has been created a deployment pod on my cluster. After that i have created a service as: kubectl create -f deployment.yaml
kubectl create -f deployment.yaml
kubectl create -f deployment.yaml
Here's my Yaml configurations:
pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: test-app
spec:
containers:
- name: test-ctr
image: arycloud/flask-svc
ports:
- containerPort: 5000
Here's my Dockerfile:
FROM python:alpine3.7
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
CMD python ./app.py
deployment.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: test-app
name: test-app
spec:
replicas: 1
template:
metadata:
labels:
app: test-app
name: test-app
spec:
containers:
- name: test-app
image: arycloud/flask-svc
resources:
requests:
cpu: "100m"
imagePullPolicy: Always
ports:
- containerPort: 8080
service.yaml:
apiVersion: v1
kind: Service
metadata:
name: test-app
labels:
app: test-app
spec:
type: LoadBalancer
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
nodePort: 32000
selector:
app: test-app
Ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: frontend
servicePort: 80
It creates a LoadBalancer and provides an external IP, when I open the IP it returns Connection Refused error
Connection Refused error
What's going wrong?
Help me, please!
Thank You,
Abdul
Hi @SureshVishnoi, now both ports are same but still returns the same error.
– Abdul Rehman
Jul 2 at 13:58
check security groups for your cluster?
– fiunchinho
Jul 2 at 15:22
I have created an ingress controller also which shows an error as
Some backend services are in UNHEALTHY state
, what did this mean?– Abdul Rehman
Jul 2 at 15:48
Some backend services are in UNHEALTHY state
It means the application pod is not up and running
– Suresh Vishnoi
Jul 2 at 20:03
1 Answer
1
you can first check if the pod is working by curl podip:port
, in your scenario, should be curl podip:8080
; if not work well, you have to check if the precess is bind 8080 port in the image you are using.
curl podip:port
curl podip:8080
if it work, then try with service by curl svcip:svcport
, in your scenario, should be curl svcip:80
; if not work well, will be a kubernetes networking [congiguration] issue.
curl svcip:svcport
curl svcip:80
if still work, then the issue should be happen on ingress layer.
In theory, it should work if all match the k8s rules.
Hi @WeiweiJiang, Now I have created a new cluster and simply deploy a pod( added
pod.yaml
in the question) then try to curl it's IP as: curl http://10.36.2.7:5000/
and also I have added my dockerfile into the question. But now it returns curl: (7) Failed to connect to 10.36.2.7 port 5000: Operation timed out
– Abdul Rehman
Jul 3 at 5:12
pod.yaml
curl http://10.36.2.7:5000/
curl: (7) Failed to connect to 10.36.2.7 port 5000: Operation timed out
Sometimes the backends are unhealthy and the health check is failing because of the firewall rules. The IP address is the pod IP? Did you open a firewall rule manually?
– Milad Tabrizi
Jul 3 at 23:28
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Hi, Check your targetport and containerport. They are supposed to be same
– Suresh Vishnoi
Jul 2 at 13:26