I'm running a kubernetes cluster with minikube on ubuntu server 20.04.1 LTS. When I launch the deployments I can access the Tomcat server from the cluster, but I can't open my application, I got the error message :
HTTP Status 404 – Not Found
Here is my docker-compose file :
version: "3"
#NETWORK
networks:
network1:
driver: bridge
volumes:
dir-site:
driver_opts:
device: /smartclass_docker/site/
type: bind
o: bind
# Declare services
services:
# service name
server:
container_name: server
# Container image name
image: repo/myimage
## Image used to build Dockerfile
build:
#dockerfile: Dockerfile
context: ./smart/
# Container ports and host matching
ports:
- "3306:3306"
- "8080:8080"
## Startup Policy
restart driver: bridge
volumes:
dir-site:
driver_opts:
device: /smart/site/
type: bind
o: bind
# Declaration of services
services:
# service name
server:
container_name: server
# name of the image
image: repo/myimage
## Use IMAGE BUILD DOCKERFILE
build:
#dockerfile: Dockerfile
context: ./smart/
# CONTAINER ports
ports:
- "3306:3306"
- "8080:8080"
## Startup policy
restart: always
# connect to network1
networks:
- network1
volumes:
- /data/dockerStore/data/db_server_1:/var/lib/mysql/
restart: always
# connect to network1
networks:
- network1
volumes:
- /data/dockerStore/data/db_server_1:/var/lib/mysql/
Here is my kubernetes deployment file :
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
# type: LoadBalancer
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: jksun12/vdsaipro
command: ["/run.sh"]
ports:
- containerPort: 80
- containerPort: 3306
- containerPort: 9001
- containerPort: 9002
# volumeMounts:
# - name: myapp-pv-claim
# mountPath: /var/lib/mysql
# volumes:
# - name: myapp-pv-claim
# persistentVolumeClaim:
# claimName: myapp-pv-claim
---
apiVersion: apps/v1
kind: PersistentVolumeClaim
metadata:
name: myapp-pv-claim
labels:
app: myapp
spec:
accesModes:
- ReadWriteMany
resources:
requests:
storage: 4Gi
My application files are in the /smart directory, which is a subdirectory of the directory where I actually run docker-compose and build my main Dockerfile. How can I solve it ? Thanks
I checked the logs inside the containers, and I found that the errors come from the extraction of the .war file inside the container. There was also an error in the version of the tomcat server used for the application. So I changed the version of tomcat to another version.
It's solved now. Thanks