Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[terraform-google][helm] Set SSL policy to enforce secure TLS connections #997

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ resource "local_file" "helm_chart_values" {
]

dssGateway = {
ip = var.ip_gateway
subnet = var.workload_subnet
certName = var.gateway_cert_name
ip = var.ip_gateway
subnet = var.workload_subnet
certName = var.gateway_cert_name
sslPolicy = var.ssl_policy
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ variable "workload_subnet" {
type = string
description = "Only required for AWS cloud provider. Subnet where the kubernetes worker nodes is deployed. For AWS, provide the name or the id of the workload_subnet"
default = ""
}
}

variable "ssl_policy" {
type = string
description = "Only required for Google cloud provider. Name of the SSL policy created for the DSS Gateway Ingress."
default = ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ resource "google_container_cluster" "kubernetes_cluster" {
}

min_master_version = var.kubernetes_version

}

resource "google_container_node_pool" "dss_pool" {
Expand Down Expand Up @@ -58,3 +59,9 @@ resource "google_compute_address" "ip_crdb" {
locals {
kubectl_cluster_context_name = format("gke_%s_%s_%s", google_container_cluster.kubernetes_cluster.project, google_container_cluster.kubernetes_cluster.location, google_container_cluster.kubernetes_cluster.name)
}

resource "google_compute_ssl_policy" "secure" {
name = format("%s-secure-ssl-policy", var.cluster_name)
profile = "RESTRICTED"
min_tls_version = "TLS_1_2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ output "ip_gateway" {
value = google_compute_global_address.ip_gateway.name
}

output "ssl_policy" {
value = google_compute_ssl_policy.secure.name
}

output "crdb_nodes" {
value = [
for i in google_compute_address.ip_crdb : {
ip = i.address
dns = i.description
}
]
}
}
1 change: 1 addition & 0 deletions deploy/infrastructure/modules/terraform-google-dss/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module "terraform-commons-dss" {
kubernetes_api_endpoint = module.terraform-google-kubernetes.kubernetes_api_endpoint
crdb_internal_nodes = module.terraform-google-kubernetes.crdb_nodes
ip_gateway = module.terraform-google-kubernetes.ip_gateway
ssl_policy = module.terraform-google-kubernetes.ssl_policy
kubernetes_cloud_provider_name = module.terraform-google-kubernetes.kubernetes_cloud_provider_name
kubernetes_context_name = module.terraform-google-kubernetes.kubernetes_context_name
kubernetes_get_credentials_cmd = module.terraform-google-kubernetes.kubernetes_get_credentials_cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ loadBalancerIP: {{.ip}}
kubernetes.io/ingress.allow-http: "false"
kubernetes.io/ingress.global-static-ip-name: {{.ip}}
networking.gke.io/managed-certificates: {{.certName}}
networking.gke.io/v1beta1.FrontendConfig: {{.sslPolicy}}
{{- end -}}

{{- define "google-ingress-spec" -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ metadata:
(dict
"certName" (printf "%s-core-service-https-certificate" $.Release.Name)
"ip" .ip
"sslPolicy" "ssl-frontend-config"
) | nindent 4
}}
labels:
Expand Down Expand Up @@ -55,6 +56,12 @@ metadata:
spec:
domains:
- {{$dssHostname}}

---
apiVersion: networking.gke.io/v1beta1
kind: FrontendConfig
metadata:
name: ssl-frontend-config
spec:
sslPolicy: {{.sslPolicy}}
barroco marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- end }}
6 changes: 5 additions & 1 deletion deploy/services/helm-charts/dss/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
"certName": {
"description": "Optional: ARN of the certificate for AWS only",
"type": "string"
},
"sslPolicy": {
"description": "Optional: SSL Policy name for Google only",
barroco marked this conversation as resolved.
Show resolved Hide resolved
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -181,4 +185,4 @@
],
"title": "Values",
"type": "object"
}
}
Loading