Hello I am trying to deploy a simple tomcat service. Below are the details:
1.minikube version: v1.8.1
2.OS: mac
3.The deployment.yaml file (I am in the directory of the yaml file)
apiVersion: apps/v1
kind: Deployment
metadata:
name: tomcat-deployment
spec:
selector:
matchLabels:
app: tomcat
replicas: 1
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat:9.0
ports:
- containerPort: 8080
4.Commands used to deploy and expose the service
kubectl apply -f deployment.yaml
kubectl expose deployment tomcat-deployment --type=NodePort
minikube service tomcat-deployment --url
curl [URL]
I get a 404 when I curl the URL. I am unsure if there's an issue with the deployment.yaml file or some minikube settings.
You should set target-Port
which in your case would be 8080
.
All of this is nicely explained on Set up Ingress on Minikube with the NGINX Ingress Controller
- Create a Deployment using the following command:
kubectl run web --image=gcr.io/google-samples/hello-app:1.0 --port=8080
- Output:
deployment.apps/web created
- Expose the Deployment:
kubectl expose deployment web --target-port=8080 --type=NodePort
- Output:
service/web exposed
- Verify the Service is created and is available on a node port:
kubectl get service web
- Output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE web NodePort 10.104.133.249 <none> 8080:31637/TCP 12m
- Visit the service via NodePort:
minikube service web --url
- Output:
http://172.17.0.15:31637
If that does not help check the logs of the tomcat
pod to see it started on port 8080
Look for a line
09-Mar-2020 13:36:00.157 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
You can also check docker logs by first locating the docker container docker ps
and fetching the logs from it with docker logs <container-name>