I'm trying to deploy my app to Digital Ocean using Kubernetes and I went through their tutorial but it is not working. This is my manifest:
---
kind: Service
apiVersion: v1
metadata:
name: my-app-load-balancer
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 80
selector:
app: my-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: addamsson/my-app:v6
ports:
- containerPort: 80
What happens is that instead of routing to the 80
port of the droplet it forwards to a random port:
my-app-load-balancer LoadBalancer 10.245.109.64 206.189.247.38 80:32225/TCP 4m1s
What am I doing wrong?
I tried my app locally with Docker and it works and if I check the logs of my pod it also looks good:
2020-02-25 14:15:30.105 [main] INFO Application - Responding at http://127.0.0.1:80
Edit:
I tried it with an image I know should work: springio/gs-spring-boot-docker
and it works. But I don't understand why it is not working with my image. If I check the logs it looks good. Do I have a problem in my Dockerfile
?
FROM openjdk:8-jre-alpine
RUN mkdir /app
COPY ./build/libs/my-app.jar /app/my-app.jar
WORKDIR /app
ENTRYPOINT ["java", "-jar", "my-app.jar"]
If I run the .jar
file on my computer it is also fine.