无法访问 Kubernetes 上的 Keycloak。

huangapple go评论64阅读模式
英文:

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>.

无法访问 Kubernetes 上的 Keycloak。

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 [&quot;/usr/bin/env&quot;]
CMD [&quot;sh&quot;,&quot;/opt/jboss/tools/docker-entrypoint.sh&quot;]

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 -&gt; 8080
Forwarding from [::1]:8080 -&gt; 8080
Handling connection for 8080
Handling connection for 8080
E0216 15:24:29.872454   24829 portforward.go:407] an error occurred forwarding 8080 -&gt; 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 -&gt; 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>.

无法访问 Kubernetes 上的 Keycloak。

Thanks

答案1

得分: 0

  1. 检查防火墙是否阻止了该端口。 “netstat -anp | grep 8080”

  2. 检查 Pod 是否在配置的 YAML 文件中正确配置了端口和主机端口。可使用此链接作为参考。

  3. 如果在 Docker 容器和 kubectl 中使用相同的端口配置,可能无法访问相同的端口,因此请检查端口号。

此外,您可以查看Ales Nosek的博客文章,了解有关主机端口的信息。

英文:

You can check the following step to troubleshoot the issue:

  1. Check whether the firewall is blocking the port. “netstat -anp | grep 8080”

  2. Check the pod is configured correctly with port and host port in the config yaml file. Use thislink as a reference.

  3. 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.

huangapple
  • 本文由 发表于 2023年2月16日 18:14:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75470753.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定