有没有办法从 terraform 创建的静态 IP 资源(GCP)将 loadBalancerIP 注入到 kubernetes 入口?

发布于 2025-01-11 12:54:20 字数 483 浏览 0 评论 0原文

我们使用 Terraform 创建所有基础设施资源,然后使用 Helm 在集群中部署应用程序。

我们正在寻找一种方法来简化基础设施和应用程序的创建,因此目前我们正在做的事情是:

  • Terraform 创建 kubernetes 集群、VPC 网络等以及一些静态公共 IP 地址
  • 我们必须等待这些的动态创建由 Terraform 完成静态 IP
  • 我们找出已创建的公共 IP,并将其手动添加到入口控制器 helm 图表上的 loadBalancerIP: 规范中

如果可能的话,我想店铺通过 terraform 生成的公共 IP(配置映射会很好),然后在入口服务 loadBalancerIP: 规范中引用它,以便对端到端流程进行排序。

我知道 configmaps 用于 pod,但我不认为它们可以用于 kubernetes 服务对象 - 有人对我如何实现这一目标有任何想法/想法吗?

We use Terraform to create all of our infrastructure resources then we use Helm to deploy apps in our cluster.

We're looking for a way to streamline the creation of infra and apps, so currently this is what we do:

  • Terraform creates kubernetes cluster, VPC network etc and a couple of static public IP addresses
  • We have to wait for the dynamic creation of these static IPs by Terraform to complete
  • We find out what the public IP is that's been created, and manually add that to our loadBalancerIP: spec on our ingress controller helm chart

If at all possible, I'd like to store the generated public IP somewhere via terraform (config map would be nice), and then reference that in the ingress service loadBalancerIP: spec, so the end to end process is sorted.

I know configmaps are for pods and I don't think they can be used for kubernetes service objects - does anyone have any thoughts/ideas on how I could achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在梵高的星空下 2025-01-18 12:54:20

我建议使用 terraform 在 GCP 中创建一个静态公共 IP,方法是指定您想要的名称,如下所示:

module "address" {
  source       = "terraform-google-modules/address/google"
  version      = "3.0.0"
  project_id   = "your-project-id"
  region       = "your-region"
  address_type = "EXTERNAL"
  names = [ "the-name-you-want" ]
  global = true
}

然后,您可以通过指定注释 kubernetes 在 Kubernetes 入口资源中引用此静态公共 IP name .io/ingress.global-static-ip-name: "the-name-you-want" 像这样:

resource "kubernetes_ingress_v1" "example" {
  wait_for_load_balancer = true
  metadata {
    name = "example"
    namespace = "default"
    annotations = {
      "kubernetes.io/ingress.global-static-ip-name" = "the-name-you-want"
    }
  }
  spec {
....

这将在 GKE 中创建入口资源“example”并附加名为的静态公共 IP '你想要的名字'。

I suggest creating a static public IP in GCP using terraform by specifying the name you want like this:

module "address" {
  source       = "terraform-google-modules/address/google"
  version      = "3.0.0"
  project_id   = "your-project-id"
  region       = "your-region"
  address_type = "EXTERNAL"
  names = [ "the-name-you-want" ]
  global = true
}

You can then refer to this static public IP name in the Kubernetes ingress resource by specifying the annotations kubernetes.io/ingress.global-static-ip-name: "the-name-you-want" like this:

resource "kubernetes_ingress_v1" "example" {
  wait_for_load_balancer = true
  metadata {
    name = "example"
    namespace = "default"
    annotations = {
      "kubernetes.io/ingress.global-static-ip-name" = "the-name-you-want"
    }
  }
  spec {
....

This will create ingress resource 'example' in GKE and attach static public IP named 'the-name-you-want' to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文