Skip to content

Instantly share code, notes, and snippets.

@phumberdroz
Created August 19, 2020 09:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save phumberdroz/81885c01c2207d578c17635afce1b033 to your computer and use it in GitHub Desktop.
Save phumberdroz/81885c01c2207d578c17635afce1b033 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