Skip to content

Commit

Permalink
Add service account for node pool in GKE cluster (#1469) (#1477)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Jura <[email protected]>
  • Loading branch information
matttrach and mjura authored Feb 6, 2025
1 parent cf175a4 commit 11ab6af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
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

0 comments on commit 11ab6af

Please sign in to comment.