![](/img/trans.png)
[英]How can a Kubernetes pod connect to database which is running in the same local network (outside the cluster) as the host?
[英]Kubernetes pod is unable to connect or ping the host ip it's running on. Works fine when pinging other machines on the same network as the host
我無法從與 Jenkins 主實例在同一台機器上運行的 pod 連接到我的 Jenkins 主實例(在集群外運行)。
當 pod 從另一台主機運行時,ping/連接工作正常。
我用的是法蘭絨。 我唯一能看到的是這個主機 IP 地址在 OutBoundNAT 端點策略的例外列表中配置的 cni.conf 文件中。
如果無法從運行它的 pod 連接主機的 IP,如何在與 Jenkins 主服務器相同的主機上運行 Jenkins 代理 pod?
謝謝,
您需要將 pod 分配給該特定節點。
有很多方法可以做到這一點,但您可以使用 NodeSelector 進行測試。
例子:
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
key1: value1
key2: value2
您的節點應該在標簽中具有相似的鍵和值。
要檢查節點標簽,您可以使用:
kubectl get nodes --show-labels
為節點添加標簽:
kubectl label nodes <your-node-name> <label>
例子:
kubectl label nodes worker-2.example.com color=blue
有關完整和不同的示例,您可以查看此鏈接。
https://gist.github.com/devops-school/3da18faede22b18ac7013c404bc10740
祝你好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.