-
-
Save kinoute/0b63db4aa6f4353cd23e6bc2ef39b9d2 to your computer and use it in GitHub Desktop.
Terraform populate Docker Credentials in all Namespaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "docker_password" {} | |
data "kubernetes_all_namespaces" "allns" {} | |
resource "kubernetes_secret" "docker_secrets" { | |
for_each = toset(data.kubernetes_all_namespaces.allns.namespaces) | |
metadata { | |
name = "gitlab-cloud" | |
namespace = each.value | |
} | |
data = { | |
".dockerconfigjson" = jsonencode({ | |
"auths" : { | |
"registry.gitlab.com" : { | |
email = "test@yourorg" | |
username = "kubernetes" | |
password = var.docker_password | |
auth = base64encode("kubernetes:${var.docker_password}") | |
} | |
} | |
}) | |
} | |
type = "kubernetes.io/dockerconfigjson" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment