I follow below steps to deploy my custom jar
1)- I created on docker image through the below docker file
FROM openjdk:8-jre-alpine3.9
LABEL MAINTAINER DINESH
LABEL version="1.0"
LABEL description="First image with Dockerfile & DINESH."
RUN mkdir /app
COPY LoginService-0.0.1-SNAPSHOT.jar /app
WORKDIR /app
CMD ["java", "-jar", "LoginService-0.0.1-SNAPSHOT.jar"]
2)- Deploy on kubernetes with the below deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
name: hello-world
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: load-balancer-example
template:
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
spec:
containers:
- image: localhost:5000/my-image:latest
name: hello-world
ports:
- containerPort: 8000
3)- Exposed as service with the below command
minikube tunnel
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service --port=8000 --target-port=8000
4)- Output of the kubectl describe svc my-service
<strong>
Name: my-service<br>
Namespace: default<br>
Labels: app.kubernetes.io/name=load-balancer-example<br>
Annotations: <none><br>
Selector: app.kubernetes.io/name=load-balancer-example<br>
Type: LoadBalancer<br>
IP: 10.96.142.93<br>
LoadBalancer Ingress: 10.96.142.93<br>
Port: <unset> 8000/TCP<br>
TargetPort: 8000/TCP<br>
NodePort: <unset> 31284/TCP<br>
Endpoints: 172.18.0.7:8000,172.18.0.8:8000<br>
Session Affinity: None<br>
External Traffic Policy: Cluster<br>
Events: <none><br> </strong>
POD is in running state
I m trying to access the pod using "10.96.142.93" as given in the http://10.96.142.93:8090 my loginservice is started on 8090 PORT, BUT i am unable to access pod plz help
Try to access on nodeport localhost:31284
and please use service type as NodePort
instead of LoadBalancer
because loadbalancer service type mostly used on cloud level.
and Use Target-Port as same port you configured on pod definition yaml file.
so your url should be http://10.96.142.93:8000
or another way you can be by using port-forward
kubectl port-forward pod_name 80:8000
this will map pod port to localhost port
Then access it on http://localhost:80