In kubernetes services, not able to use ports 6000 and 8081

2/5/2020

I have a Kubernetes service (a Python Flask application) exposed publicly on port 6000 using the LoadBalancer type.

When I am using kubectl to send the YAML file to Kubernetes by running the following command: kubectl apply -f deployment.yaml I got the status of the service as running.

When I am navigating to http://localhost:6000, I am not able to see the “Hello from Python!”

I tried using port 8081, and that is also not working. But when I am using port 8088, it's working.

deployment.yaml file which I am using:

apiVersion: v1
kind: Service
metadata:
  name: hello-python-service
spec:
  selector:
    app: hello-python
  ports:
  - protocol: "TCP"
    port: 6000
    targetPort: 5000
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-python
spec:
  selector:
    matchLabels:
      app: hello-python
  replicas: 4
  template:
    metadata:
      labels:
        app: hello-python
    spec:
      containers:
      - name: hello-python
        image: hello-python:latest
        imagePullPolicy: Never
        ports:
        - containerPort: 5000

I am using the following example: Kubernetes Using Python

Why some ports like 6000 or 8081 are not working and why some ports like 8088 or 9000 are working?

-- Monika Kumari
kubernetes
port

0 Answers