Skip to content

Commit 8d5c9a4

Browse files
authoredFeb 13, 2025··
feat: workload_identity - add image pull secrets (#2276)
1 parent 5026db1 commit 8d5c9a4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed
 

‎modules/workload-identity/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Error: Get "http://localhost/api/v1/namespaces/default/serviceaccounts/your-serv
152152
| gcp\_sa\_description | The Service Google service account desciption; if null, will be left out | `string` | `null` | no |
153153
| gcp\_sa\_display\_name | The Google service account display name; if null, a default string will be used | `string` | `null` | no |
154154
| gcp\_sa\_name | Name for the Google service account; overrides `var.name`. | `string` | `null` | no |
155+
| image\_pull\_secrets | A list of references to secrets in the same namespace to use for pulling any images in pods that reference this Service Account | `list(string)` | `[]` | no |
155156
| impersonate\_service\_account | An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials. | `string` | `""` | no |
156157
| k8s\_sa\_name | Name for the Kubernetes service account; overrides `var.name`. `cluster_name` and `location` must be set when this input is specified. | `string` | `null` | no |
157158
| k8s\_sa\_project\_id | GCP project ID of the k8s service account; overrides `var.project_id`. | `string` | `null` | no |

‎modules/workload-identity/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ resource "kubernetes_service_account" "main" {
5353
count = var.use_existing_k8s_sa ? 0 : 1
5454

5555
automount_service_account_token = var.automount_service_account_token
56+
57+
dynamic "image_pull_secret" {
58+
for_each = var.image_pull_secrets
59+
60+
content {
61+
name = image_pull_secret.value
62+
}
63+
}
64+
5665
metadata {
5766
name = local.k8s_given_name
5867
namespace = var.namespace

‎modules/workload-identity/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ variable "automount_service_account_token" {
8484
default = false
8585
}
8686

87+
variable "image_pull_secrets" {
88+
description = "A list of references to secrets in the same namespace to use for pulling any images in pods that reference this Service Account"
89+
type = list(string)
90+
default = []
91+
}
92+
8793
variable "roles" {
8894
description = "A list of roles to be added to the created service account"
8995
type = list(string)

0 commit comments

Comments
 (0)
Please sign in to comment.