Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service account for node pool in GKE cluster #1469

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ The following arguments are supported:
* `preemptible` - (Optional) Enable GKE node config preemptible. Default: `false` (bool)
* `tags` - (Optional/Computed) The GKE node config tags (List)
* `taints` - (Optional) The GKE node config taints (List)
* `service_account` - (Optional) The GKE Service Account to be used by the node VMs (string)

###### `taints`

Expand Down
5 changes: 5 additions & 0 deletions rancher2/schema_cluster_gke_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ func clusterGKEConfigV2NodeConfigFields() map[string]*schema.Schema {
Schema: clusterGKEConfigV2NodeTaintFields(),
},
},
"service_account": {
Type: schema.TypeString,
Optional: true,
Description: "The GKE node config service account",
},
}

return s
Expand Down
6 changes: 6 additions & 0 deletions rancher2/structure_cluster_gke_config_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func flattenClusterGKEConfigV2NodeConfig(in *managementClient.GKENodeConfig) []i
if len(in.Taints) > 0 {
obj["taints"] = flattenClusterGKEConfigV2NodeTaintsConfig(in.Taints)
}
if len(in.ServiceAccount) > 0 {
obj["service_account"] = in.ServiceAccount
}

return []interface{}{obj}
}
Expand Down Expand Up @@ -492,6 +495,9 @@ func expandClusterGKEConfigV2NodeConfig(p []interface{}) *managementClient.GKENo
if v, ok := in["taints"].([]interface{}); ok && len(v) > 0 {
obj.Taints = expandClusterGKEConfigV2NodeTaintsConfig(v)
}
if v, ok := in["service_account"].(string); ok && len(v) > 0 {
obj.ServiceAccount = v
}
return obj
}

Expand Down
14 changes: 8 additions & 6 deletions rancher2/structure_cluster_gke_config_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ func init() {
"label1": "value1",
"label2": "value2",
},
LocalSsdCount: int64(1),
MachineType: "machine_type",
OauthScopes: []string{"oauth1", "oauth1"},
Preemptible: true,
Tags: []string{"tags1", "tags2"},
Taints: testClusterGKEConfigV2NodeTaintsConfigConf,
LocalSsdCount: int64(1),
MachineType: "machine_type",
OauthScopes: []string{"oauth1", "oauth1"},
Preemptible: true,
Tags: []string{"tags1", "tags2"},
Taints: testClusterGKEConfigV2NodeTaintsConfigConf,
ServiceAccount: "[email protected]",
}
testClusterGKEConfigV2NodeConfigInterface = []interface{}{
map[string]interface{}{
Expand All @@ -145,6 +146,7 @@ func init() {
"preemptible": true,
"tags": []interface{}{"tags1", "tags2"},
"taints": testClusterGKEConfigV2NodeTaintsConfigInterface,
"service_account": "[email protected]",
},
}
testClusterGKEConfigV2NodePoolsManagementConf = &managementClient.GKENodePoolManagement{
Expand Down