英文:
Not able to access keycloak on kubernetes
问题
I am facing a weird issue, my keycloak is running successfully in minikube but at the same time I am not able to access by port forwarding to 8080. I wanted my own SPI to be deployed, so I created a new Docker image file as shown below.
FROM jboss/keycloak:latest
ADD common-keycloak-spi-0.1.jar /opt/jboss/keycloak/standalone/deployments/
ENTRYPOINT ["/usr/bin/env"]
CMD ["sh","/opt/jboss/tools/docker-entrypoint.sh"]
Now this runs fine in a Docker container, but when I am trying to deploy it on Kubernetes, I am unable to access the service by using port forwarding.
vipul@vipul-Latitude-5530:~/Downloads$ kubectl port-forward springdoc-64f8dbf547-xrqcl 8080:8080
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
Handling connection for 8080
Handling connection for 8080
E0216 15:24:29.872454 24829 portforward.go:407] an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod 5ad97759ea56d8d9acbeecc9dc3cda33bdb0ff138b5c126de37cb7bad985b74f, uid : exit status 1: 2023/02/16 09:54:29 socat[93218] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused
E0216 15:24:29.873263 24829 portforward.go:233] lost connection to pod
Handling connection for 8080
E0216 15:24:29.874222 24829 portforward.go:345] error creating error stream for port 8080 -> 8080: EOF
vipul@vipul-Latitude-5530:~/Downloads$ kubectl exec springdoc-64f8dbf547-xrqcl -- /bin/bash
And also getting "NONE" for any port and host port in kubectl describe <POD>
.
Thanks
英文:
I am facing a weird issue, my keycloak is running successfully in minikube but at the same time I am not able to access by port forwarding to 8080. I wanted my own spi to be deployed so created a new docker image file as shown below.
FROM jboss/keycloak:latest
ADD common-keycloak-spi-0.1.jar /opt/jboss/keycloak/standalone/deployments/
ENTRYPOINT ["/usr/bin/env"]
CMD ["sh","/opt/jboss/tools/docker-entrypoint.sh"]
Now this runs fine in docker container but when I am trying to depoloy it on kubernetes I am unable to access the service by using port forwading.
vipul@vipul-Latitude-5530:~/Downloads$ kubectl port-forward springdoc-64f8dbf547-xrqcl 8080:8080
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080
Handling connection for 8080
Handling connection for 8080
E0216 15:24:29.872454 24829 portforward.go:407] an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod 5ad97759ea56d8d9acbeecc9dc3cda33bdb0ff138b5c126de37cb7bad985b74f, uid : exit status 1: 2023/02/16 09:54:29 socat[93218] E connect(5, AF=2 127.0.0.1:8080, 16): Connection refused
E0216 15:24:29.873263 24829 portforward.go:233] lost connection to pod
Handling connection for 8080
E0216 15:24:29.874222 24829 portforward.go:345] error creating error stream for port 8080 -> 8080: EOF
vipul@vipul-Latitude-5530:~/Downloads$ kubectl exec springdoc-64f8dbf547-xrqcl -- /bin/bash
And also getting NONE for any port and host port in kubectl describe <POD>.
Thanks
答案1
得分: 0
-
检查防火墙是否阻止了该端口。
“netstat -anp | grep 8080”
-
检查 Pod 是否在配置的 YAML 文件中正确配置了端口和主机端口。可使用此链接作为参考。
-
如果在 Docker 容器和 kubectl 中使用相同的端口配置,可能无法访问相同的端口,因此请检查端口号。
此外,您可以查看Ales Nosek的博客文章,了解有关主机端口的信息。
英文:
You can check the following step to troubleshoot the issue:
-
Check whether the firewall is blocking the port.
“netstat -anp | grep 8080”
-
Check the pod is configured correctly with port and host port in the config yaml file. Use thislink as a reference.
-
If you are using the same port configuration in Docker container and in the kubectl will not access the same port so try to check the port number.
Also you can check the blog by Ales Nosek for hostport.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论