Skip to content

Instantly share code, notes, and snippets.

@kinoute
Forked from phumberdroz/docker.tf
Created November 29, 2023 06:36
Show Gist options
  • Save kinoute/0b63db4aa6f4353cd23e6bc2ef39b9d2 to your computer and use it in GitHub Desktop.
Save kinoute/0b63db4aa6f4353cd23e6bc2ef39b9d2 to your computer and use it in GitHub Desktop.
Terraform populate Docker Credentials in all Namespaces
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