[英]Static outgoing IP in Kubernetes
I run a k8s cluster in google cloud (GKE) and a MySQL server in aws (RDS). 我在google cloud(GKE)中运行k8s群集,在aws(RDS)中运行MySQL服务器。 Pods need to connect to RDS which only allows connections from certain IP.
Pod需要连接到RDS,它只允许来自某些IP的连接。 How can I configure outgoing traffic to have a static IP?
如何配置传出流量以获得静态IP?
I had the same problem to connect to a sftp server from a Pod. 我有一个问题从Pod连接到sftp服务器。 To solve this, first you need to create an external IP address:
要解决此问题,首先需要创建外部IP地址:
gcloud compute addresses create {{ EXT_ADDRESS_NAME }} --region {{ REGION }}
Then, I suppose that your pod is assigned to your default-pool node cluster. 然后,我想您的pod已分配给默认池节点集群。 Extract your default-pool node name:
提取默认池节点名称:
gcloud compute instances list | awk '{ print $1 }' | grep default-pool
Erase default external ip of the vm instance: 擦除vm实例的默认外部ip:
gcloud compute instances delete-access-config {{ VM_DEFAULT-POOL_INSTANCE }} --access-config-name external-nat
Add your external static ip created before: 添加之前创建的外部静态IP:
gcloud compute instances add-access-config {{ VM_DEFAULT-POOL_INSTANCE }} --access-config-name external-nat --address {{ EXT_ADDRESS_IP }}
If your Pod is not attached to the default-pool node, don't forget to select it with a nodeSelector: 如果您的Pod未附加到默认池节点,请不要忘记使用nodeSelector选择它:
nodeSelector:
cloud.google.com/gke-nodepool: {{ NODE_NAME }}
I made some research and I found a couple of things. 我做了一些研究,发现了一些事情。
The thing we are looking for is called "egress IPs" or NAT-as-a-Service and they are both not yet available in GKE. 我们正在寻找的东西称为“出口IP”或NAT-as-a-Service,它们在GKE中都不可用。
In any case we have two different options: 无论如何,我们有两种不同的选择:
Hope it helps! 希望能帮助到你!
您可以使用kubeip,一个pod,每个新节点都会从预定义的池中分配IP地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.