diff --git a/README.md b/README.md index 72f9dbea1..8cf711e0d 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ No modules. | [flux2](#input\_flux2) | Customize Flux chart, see `flux2.tf` for supported values | `any` | `{}` | no | | [helm\_defaults](#input\_helm\_defaults) | Customize default Helm behavior | `any` | `{}` | no | | [ingress-nginx](#input\_ingress-nginx) | Customize ingress-nginx chart, see `nginx-ingress.tf` for supported values | `any` | `{}` | no | +| [ip-masq-agent](#input\_ip-masq-agent) | Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP. | `any` | `{}` | no | | [k8gb](#input\_k8gb) | Customize k8gb chart, see `k8gb.tf` for supported values | `any` | `{}` | no | | [karma](#input\_karma) | Customize karma chart, see `karma.tf` for supported values | `any` | `{}` | no | | [keda](#input\_keda) | Customize keda chart, see `keda.tf` for supported values | `any` | `{}` | no | diff --git a/modules/aws/README.md b/modules/aws/README.md index 614fa57cf..cd391e654 100644 --- a/modules/aws/README.md +++ b/modules/aws/README.md @@ -373,6 +373,7 @@ This module can uses [IRSA](https://aws.amazon.com/blogs/opensource/introducing- | [flux2](#input\_flux2) | Customize Flux chart, see `flux2.tf` for supported values | `any` | `{}` | no | | [helm\_defaults](#input\_helm\_defaults) | Customize default Helm behavior | `any` | `{}` | no | | [ingress-nginx](#input\_ingress-nginx) | Customize ingress-nginx chart, see `nginx-ingress.tf` for supported values | `any` | `{}` | no | +| [ip-masq-agent](#input\_ip-masq-agent) | Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP. | `any` | `{}` | no | | [k8gb](#input\_k8gb) | Customize k8gb chart, see `k8gb.tf` for supported values | `any` | `{}` | no | | [karma](#input\_karma) | Customize karma chart, see `karma.tf` for supported values | `any` | `{}` | no | | [karpenter](#input\_karpenter) | Customize karpenter chart, see `karpenter.tf` for supported values | `any` | `{}` | no | diff --git a/modules/azure/README.md b/modules/azure/README.md index a38fb442f..48685c803 100644 --- a/modules/azure/README.md +++ b/modules/azure/README.md @@ -191,6 +191,7 @@ No modules. | [flux2](#input\_flux2) | Customize Flux chart, see `flux2.tf` for supported values | `any` | `{}` | no | | [helm\_defaults](#input\_helm\_defaults) | Customize default Helm behavior | `any` | `{}` | no | | [ingress-nginx](#input\_ingress-nginx) | Customize ingress-nginx chart, see `nginx-ingress.tf` for supported values | `any` | `{}` | no | +| [ip-masq-agent](#input\_ip-masq-agent) | Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP. | `any` | `{}` | no | | [k8gb](#input\_k8gb) | Customize k8gb chart, see `k8gb.tf` for supported values | `any` | `{}` | no | | [karma](#input\_karma) | Customize karma chart, see `karma.tf` for supported values | `any` | `{}` | no | | [keda](#input\_keda) | Customize keda chart, see `keda.tf` for supported values | `any` | `{}` | no | diff --git a/modules/google/README.md b/modules/google/README.md index ffd98fc50..24f6e674d 100644 --- a/modules/google/README.md +++ b/modules/google/README.md @@ -53,6 +53,7 @@ User guides, feature documentation and examples are available [here](https://git | [helm_release.cert-manager](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [helm_release.external-dns](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [kubectl_manifest.cert-manager_cluster_issuers](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource | +| [kubectl_manifest.ip_masq_agent](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource | | [kubernetes_namespace.cert-manager](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource | | [kubernetes_namespace.external-dns](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource | | [kubernetes_network_policy.cert-manager_allow_control_plane](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/network_policy) | resource | @@ -67,6 +68,7 @@ User guides, feature documentation and examples are available [here](https://git | [time_sleep.cert-manager_sleep](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | | [jinja_template.cert-manager_cluster_issuers](https://registry.terraform.io/providers/NikolaLohinski/jinja/latest/docs/data-sources/template) | data source | | [kubectl_file_documents.cert-manager_cluster_issuers](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/data-sources/file_documents) | data source | +| [kubectl_filename_list.ip_masq_agent_manifests](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/data-sources/filename_list) | data source | ## Inputs @@ -82,6 +84,7 @@ User guides, feature documentation and examples are available [here](https://git | [flux2](#input\_flux2) | Customize Flux chart, see `flux2.tf` for supported values | `any` | `{}` | no | | [helm\_defaults](#input\_helm\_defaults) | Customize default Helm behavior | `any` | `{}` | no | | [ingress-nginx](#input\_ingress-nginx) | Customize ingress-nginx chart, see `nginx-ingress.tf` for supported values | `any` | `{}` | no | +| [ip-masq-agent](#input\_ip-masq-agent) | Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP. | `any` | `{}` | no | | [k8gb](#input\_k8gb) | Customize k8gb chart, see `k8gb.tf` for supported values | `any` | `{}` | no | | [karma](#input\_karma) | Customize karma chart, see `karma.tf` for supported values | `any` | `{}` | no | | [keda](#input\_keda) | Customize keda chart, see `keda.tf` for supported values | `any` | `{}` | no | diff --git a/modules/google/ip-masq-agent.tf b/modules/google/ip-masq-agent.tf new file mode 100644 index 000000000..7593a3f0f --- /dev/null +++ b/modules/google/ip-masq-agent.tf @@ -0,0 +1,17 @@ +locals { + ip-masq-agent = merge( + { + enabled = false + }, + var.ip-masq-agent + ) +} + +data "kubectl_filename_list" "ip_masq_agent_manifests" { + pattern = "./manifests/gke-ip-masq/*.yaml" +} + +resource "kubectl_manifest" "ip_masq_agent" { + count = local.ip-masq-agent.enabled ? length(data.kubectl_filename_list.ip_masq_agent_manifests.matches) : 0 + yaml_body = file(element(data.kubectl_filename_list.ip_masq_agent_manifests.matches, count.index)) +} diff --git a/modules/google/manifests/gke-ip-masq/ip-masq-agent-configmap.yaml b/modules/google/manifests/gke-ip-masq/ip-masq-agent-configmap.yaml new file mode 100644 index 000000000..faf39e636 --- /dev/null +++ b/modules/google/manifests/gke-ip-masq/ip-masq-agent-configmap.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: ip-masq-agent + namespace: kube-system +data: + config: | + nonMasqueradeCIDRs: + - 10.0.0.0/8 + - 172.16.0.0/12 + - 192.168.0.0/16 + resyncInterval: 60s + masqLinkLocal: false diff --git a/modules/google/manifests/gke-ip-masq/ip-masq-agent-daemonset.yaml b/modules/google/manifests/gke-ip-masq/ip-masq-agent-daemonset.yaml new file mode 100644 index 000000000..519e28487 --- /dev/null +++ b/modules/google/manifests/gke-ip-masq/ip-masq-agent-daemonset.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: ip-masq-agent + namespace: kube-system +spec: + selector: + matchLabels: + k8s-app: ip-masq-agent + template: + metadata: + labels: + k8s-app: ip-masq-agent + spec: + hostNetwork: true + containers: + - name: ip-masq-agent + image: gke.gcr.io/ip-masq-agent:v2.9.3-v0.2.4-gke.5 + args: + # The masq-chain must be IP-MASQ + - --masq-chain=IP-MASQ + # To non-masquerade reserved IP ranges by default, + # uncomment the following line. + # - --nomasq-all-reserved-ranges + securityContext: + privileged: true + volumeMounts: + - name: config-volume + mountPath: /etc/config + volumes: + - name: config-volume + configMap: + name: ip-masq-agent + optional: true + items: + - key: config + path: ip-masq-agent + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists + - key: "CriticalAddonsOnly" + operator: "Exists" diff --git a/modules/scaleway/README.md b/modules/scaleway/README.md index e93d06c8b..cb8097d30 100644 --- a/modules/scaleway/README.md +++ b/modules/scaleway/README.md @@ -222,6 +222,7 @@ No modules. | [flux2](#input\_flux2) | Customize Flux chart, see `flux2.tf` for supported values | `any` | `{}` | no | | [helm\_defaults](#input\_helm\_defaults) | Customize default Helm behavior | `any` | `{}` | no | | [ingress-nginx](#input\_ingress-nginx) | Customize ingress-nginx chart, see `nginx-ingress.tf` for supported values | `any` | `{}` | no | +| [ip-masq-agent](#input\_ip-masq-agent) | Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP. | `any` | `{}` | no | | [k8gb](#input\_k8gb) | Customize k8gb chart, see `k8gb.tf` for supported values | `any` | `{}` | no | | [kapsule](#input\_kapsule) | Kapsule cluster inputs | `any` | `{}` | no | | [karma](#input\_karma) | Customize karma chart, see `karma.tf` for supported values | `any` | `{}` | no | diff --git a/variables.tf b/variables.tf index d19cdee61..780d64c81 100644 --- a/variables.tf +++ b/variables.tf @@ -219,3 +219,9 @@ variable "victoria-metrics-k8s-stack" { type = any default = {} } + +variable "ip-masq-agent" { + description = "Configure ip masq agent chart, see `ip-masq-agent.tf` for supported values. This addon works only on GCP." + type = any + default = {} +}