Skip to content

Commit

Permalink
Replace target group binding chart with manifest
Browse files Browse the repository at this point in the history
Newer versions of the Kubernetes provider support creating instances of
CRDs using the kubernetes_manifest resource, which removes the need for
the inline Helm chart.
  • Loading branch information
jferris committed Mar 27, 2023
1 parent 8d37163 commit 139c284
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 52 deletions.
4 changes: 3 additions & 1 deletion aws/platform/modules/load-balancer-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ target group bound to the Istio ingress gateway service.
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.8 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | ~> 2.4 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | ~> 2.6 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.4 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | ~> 2.6 |

## Modules

Expand All @@ -33,8 +35,8 @@ target group bound to the Istio ingress gateway service.
|------|------|
| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [helm_release.ingress_config](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.this](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_manifest.target_group_binding](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
| [aws_lb_target_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb_target_group) | data source |

## Inputs
Expand Down
26 changes: 15 additions & 11 deletions aws/platform/modules/load-balancer-controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ resource "helm_release" "this" {
depends_on = [aws_iam_role_policy_attachment.this]
}

resource "helm_release" "ingress_config" {
chart = "${path.module}/target-group-binding"
name = "target-group-binding"
namespace = var.k8s_namespace
resource "kubernetes_manifest" "target_group_binding" {
manifest = {
apiVersion = "elbv2.k8s.aws/v1beta1"
kind = "TargetGroupBinding"

values = [
yamlencode({
name = "istio-ingress"
metadata = {
name = "target-group-binding"
namespace = var.k8s_namespace
}

spec = {
targetGroupARN = data.aws_lb_target_group.this.arn
targetType = "ip"

networking = {
ingress = [
Expand All @@ -44,11 +49,10 @@ resource "helm_release" "ingress_config" {
name = "flightdeck-ingressgateway"
port = 443
}
}
}

targetGroupARN = data.aws_lb_target_group.this.arn
})
]

# Wait for the CRD to be defined before creating
depends_on = [helm_release.this]
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions aws/platform/modules/load-balancer-controller/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ terraform {
source = "hashicorp/helm"
version = "~> 2.4"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.6"
}
}
}

0 comments on commit 139c284

Please sign in to comment.