Reputation: 234
i am trying deploy a simple python flask application in digital ocean Kubernetes cluster using below deployment and service configuration. flask app is using 8080 port while running the code and same is used to expose through load balancer.
flask app
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=8080)
deployment
ubuntu@ubuntu-22lts:~$ cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: unit7-app-deploy
spec:
replicas: 2
selector:
matchLabels:
app: unit-app
template:
metadata:
labels:
app: unit-app
spec:
containers:
- name: unit-app
image: <username>/flask-app:latest
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8080
and service for load balance creation
apiVersion: v1
kind: Service
metadata:
name: unit7-app-service
spec:
selector:
app: unit7-app-deploy
ports:
- port: 8080
targetPort: 8080
protocol: TCP
type: LoadBalancer
Now I am trying to access my app through Kubernetes external IP and 8080 port which is not working. pods logs are showing that my flaks is running.
ubuntu@ubuntu-22lts:~$ kubectl --kubeconfig=k8s-1-27-2-do-0-blr1-cluster1-kubeconfig.yaml logs -f unit7-app-deploy-6568dss8-ddsds
* Serving Flask app 'run'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:8080
* Running on http://10.244.0.214:8080
where am I wrong. Kindly help me.
Upvotes: 0
Views: 104