After much muttering and searching and and then some help from the lovely people on the rands slack, I ended up with a snippet for authenticating my kubernetes cluster to the Github Container Registry using terraform configuration.
tl;dr: create a dockerconfigjson-type secret and use it in the image_pull_secrets field
Create a secret with the authentication details:
resource "kubernetes_secret" "ghcr_auth" {
metadata {
name = "ghcr-auth"
}
type = "kubernetes.io/dockerconfigjson"
data = {
".dockerconfigjson" = jsonencode({
"auths" = {
"https://ghcr.io" = {
"auth" : base64encode("${var.github_username}:${var.github_pat}")
}
}
})
}
}
The github_pat variable has a Personal Access Token with access to read:packages. It’s not actually a variable in my config, because I’m way more secure than that, but… it’s an example.
[Read More]