简体   繁体   English

Helm、Kube.netes、如何配置Pod访问集群外的服务?

[英]Helm, Kubernetes, how to configure Pod to access a service outside the cluster?

There is a lot of sources that clarify how to connect into the cluster.有很多资源阐明了如何连接到集群。 But when searching for information about how to connect from inside the cluster to outside the search results are polluted with the opposite information.但是当搜索有关如何从集群内部连接到外部的信息时,搜索结果会被相反的信息污染。

I want to connect my custom service that is running inside the cluster to my keycloack that is outside of the cluster on my local machine.我想将在集群内运行的自定义服务连接到本地计算机上集群外的 keycloack。 There is no option of running keycloak inside the cluster.没有在集群内运行 keycloak 的选项。 I am using Docker desktop for Mac to run kube.netes.我正在使用 Docker Mac 桌面来运行 kube.netes。

There is no option of running keycloak inside the cluster.没有在集群内运行 keycloak 的选项。

Not sure may you have checked or not, you can run the keycloak on the Kube.netes.不确定你是否检查过,你可以在Kube.netes上运行 keycloak。

You can refer my Github repo to get YAML files and deployment keycloak on Kube.netes: https://github.com/harsh4870/Keycloack-postgres-kube.netes-deployment你可以参考我的 Github repo 在 Kube.netes 上获取 YAML 文件和部署密钥斗篷: https://github.com/harsh4870/Keycloack-postgres-kube.netes-deployment

Generally, you can use the external service, if you are diverting the traffic out of the cluster.通常,如果要将流量转移出集群,则可以使用外部服务。

If you are running on a Public K8s cluster on any cloud provider service will be directly able to access the external service over IP without external service creation.如果您在任何云提供商的公共 K8s 集群上运行,服务将能够直接通过 IP 访问外部服务,而无需创建外部服务。

Example例子

apiVersion: v1
kind: Service
metadata:
  name: local-host
spec:
    type: ExternalName
    externalName: 192.168.0.1

If you don't want to pass the IP in external service you can give any domain name map details in /etc/hosts files too.如果您不想在外部服务中传递 IP,您也可以在/etc/hosts文件中提供任何域名 map 的详细信息。 ref doc 参考文档

Now if you Keycloak is running on Host machine (localhost) you can use the IP directly.现在,如果您的 Keycloak 在主机(本地主机)上运行,您可以直接使用 IP。

If you are using the minikube you can use the host.minikube.internal as host.如果您使用的是minikube ,则可以使用host.minikube.internal作为主机。 ref doc参考文档

host.minikube.internal:<Port of keycloak>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Kubernetes中的群集外部访问Pod? 我将其作为节点端口服务公开,但是无法通过该节点端口访问它 - How to access pod from outside of my cluster in kubernetes? I exposed it as node port service but can't access it with that node port 如何在集群外访问/公开 kubernetes-dashboard 服务? - How to access/expose kubernetes-dashboard service outside of a cluster? 无法访问 Kubernetes 集群外的 NodePort 服务 - Cannot access NodePort service outside Kubernetes cluster 如何从 kubernetes 集群内提供的服务访问安装在 kubernetes 集群外的 kafka - How to access kafka installed outside kubernetes cluster from a service provisioned inside a kubernetes cluster 如何访问本地集群中的Kubernetes Pod? - How to access Kubernetes pod in local cluster? 从 pod 到 Kubernetes 集群外的服务时,源 IP(记录在服务端,集群外)? - Source IP(recorded at service end, outside cluster) when talking from pod to a service outside Kubernetes cluster? 如何从Kubernetes Pod访问外界 - How to access outside world from Kubernetes pod Kubernetes:如何从集群外部连接到服务? - Kubernetes: how to connect to service from outside the cluster? 如何从集群外访问 Kubernetes 中的 MongoDB - How access MongoDB in Kubernetes from outside the cluster 如何在我的kubernetes集群之外访问mysql? - How to access mysql outside my kubernetes cluster?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM