I've been looking for a similar question for a while but I haven't found one. I have a remote Kubernetes cluster with the architecture of one master and two workers. The versions installed are as following: Kubernetes: 1.15.1-0 Docker: 18.09.1-3.el7 I'm trying to deploy & expose a JAR file of Spring project that has one REST endpoint.
Deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: microservices-deployment
labels:
app: microservices-deployment
spec:
replicas: 3
template:
metadata:
name: microservices-deployment
labels:
app: microservices-deployment
spec:
containers:
- name: microservices-deployment
image: **my_repo**/*repo_name*:latest
imagePullPolicy: Always
ports:
- containerPort: 8085
restartPolicy: Always
selector:
matchLabels:
app: microservices-deployment
service.yaml:
apiVersion: v1
kind: Service
metadata:
name: microservices-service
spec:
selector:
app: microservices-deployment
ports:
- port: 8085
targetPort: 8085
type: NodePort
my application.properties:
server.port=8085
Dockerfile:
FROM openjdk:8
ADD target/microservices.jar microservices.jar
EXPOSE 8085
ENTRYPOINT ["java", "-jar", "microservices.jar"]
It looks like my pods are ready and everything looks good, but I can't access the service I exposed even from the master's terminal. Does anyone have any idea? Thanks in advance.
UPDATE
I'm able to telnet from my master to port 30000 on my nodes (after I specified 30000 as my NodePort), as well as telnet to my pods on port 8085. When I'm trying to telnet from the master to any other port in the nodes\pods I get refuse, so I think that's a good start. Still, I'm unable to access the rest endpoint I specified although it is working on Docker locally: docker run -p 8085:8085 IMAGE_NAME
The problem was a network problem. Accessing the endpoint from one of the workers did the trick. Thanks for all.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加