Skip to content

Commit a1e46dd

Browse files
committed
feat: add fields to support workload identity
Signed-off-by: Carlos Salas <[email protected]>
1 parent 3f6ed14 commit a1e46dd

File tree

6 files changed

+122
-0
lines changed

6 files changed

+122
-0
lines changed

cloud/services/container/clusters/reconcile.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,35 @@ func (s *Service) createCluster(ctx context.Context, log *logr.Logger) error {
306306
}
307307
}
308308
}
309+
309310
if !s.scope.IsAutopilotCluster() {
310311
cluster.NodePools = scope.ConvertToSdkNodePools(nodePools, machinePools, isRegional, cluster.GetName())
312+
311313
if s.scope.GCPManagedControlPlane.Spec.LoggingService != nil {
312314
cluster.LoggingService = s.scope.GCPManagedControlPlane.Spec.LoggingService.String()
313315
}
316+
314317
if s.scope.GCPManagedControlPlane.Spec.MonitoringService != nil {
315318
cluster.MonitoringService = s.scope.GCPManagedControlPlane.Spec.MonitoringService.String()
316319
}
317320
}
318321

322+
if s.scope.GCPManagedControlPlane.Spec.ClusterSecurity != nil {
323+
cs := s.scope.GCPManagedControlPlane.Spec.ClusterSecurity
324+
if cs.WorkloadIdentityConfig != nil {
325+
cluster.WorkloadIdentityConfig = &containerpb.WorkloadIdentityConfig{
326+
WorkloadPool: cs.WorkloadIdentityConfig.WorkloadPool,
327+
}
328+
}
329+
330+
if cs.AuthenticatorGroupConfig != nil {
331+
cluster.AuthenticatorGroupsConfig = &containerpb.AuthenticatorGroupsConfig{
332+
Enabled: true,
333+
SecurityGroup: cs.AuthenticatorGroupConfig.SecurityGroups,
334+
}
335+
}
336+
}
337+
319338
createClusterRequest := &containerpb.CreateClusterRequest{
320339
Cluster: cluster,
321340
Parent: s.scope.ClusterLocation(),

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,34 @@ spec:
132132
pod IPs in the cluster.
133133
type: boolean
134134
type: object
135+
clusterSecurity:
136+
description: ClusterSecurity defines the cluster security.
137+
properties:
138+
authenticatorGroupConfig:
139+
description: AuthenticatorGroupConfig is RBAC security group for
140+
use with Google security groups in Kubernetes RBAC.
141+
properties:
142+
securityGroups:
143+
description: SecurityGroups is the name of the security group-of-groups
144+
to be used.
145+
type: string
146+
required:
147+
- securityGroups
148+
type: object
149+
workloadIdentityConfig:
150+
description: |-
151+
WorkloadIdentityConfig allows workloads in your GKE clusters to impersonate Identity and Access Management (IAM)
152+
service accounts to access Google Cloud services
153+
properties:
154+
workloadPool:
155+
description: |-
156+
WorkloadPool is the workload pool to attach all Kubernetes service accounts to Google Cloud services.
157+
Only relevant when enabled is true
158+
type: string
159+
required:
160+
- workloadPool
161+
type: object
162+
type: object
135163
controlPlaneVersion:
136164
description: |-
137165
ControlPlaneVersion represents the control plane version of the GKE cluster.

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanetemplates.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,35 @@ spec:
115115
pod IPs in the cluster.
116116
type: boolean
117117
type: object
118+
clusterSecurity:
119+
description: ClusterSecurity defines the cluster security.
120+
properties:
121+
authenticatorGroupConfig:
122+
description: AuthenticatorGroupConfig is RBAC security
123+
group for use with Google security groups in Kubernetes
124+
RBAC.
125+
properties:
126+
securityGroups:
127+
description: SecurityGroups is the name of the security
128+
group-of-groups to be used.
129+
type: string
130+
required:
131+
- securityGroups
132+
type: object
133+
workloadIdentityConfig:
134+
description: |-
135+
WorkloadIdentityConfig allows workloads in your GKE clusters to impersonate Identity and Access Management (IAM)
136+
service accounts to access Google Cloud services
137+
properties:
138+
workloadPool:
139+
description: |-
140+
WorkloadPool is the workload pool to attach all Kubernetes service accounts to Google Cloud services.
141+
Only relevant when enabled is true
142+
type: string
143+
required:
144+
- workloadPool
145+
type: object
146+
type: object
118147
enableAutopilot:
119148
description: EnableAutopilot indicates whether to enable autopilot
120149
for this GKE cluster.

exp/api/v1beta1/gcpmanagedcontrolplane_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ type AuthenticatorGroupConfig struct {
113113
SecurityGroups string `json:"securityGroups,omitempty"`
114114
}
115115

116+
// ClusterSecurity defines the cluster security options.
117+
type ClusterSecurity struct {
118+
// WorkloadIdentityConfig allows workloads in your GKE clusters to impersonate Identity and Access Management (IAM)
119+
// service accounts to access Google Cloud services
120+
// +optional
121+
WorkloadIdentityConfig *WorkloadIdentityConfig `json:"workloadIdentityConfig,omitempty"`
122+
123+
// AuthenticatorGroupConfig is RBAC security group for use with Google security groups in Kubernetes RBAC.
124+
// +optional
125+
AuthenticatorGroupConfig *AuthenticatorGroupConfig `json:"authenticatorGroupConfig,omitempty"`
126+
}
127+
116128
// GCPManagedControlPlaneSpec defines the desired state of GCPManagedControlPlane.
117129
type GCPManagedControlPlaneSpec struct {
118130
GCPManagedControlPlaneClassSpec `json:",inline"`

exp/api/v1beta1/types_class.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ type GCPManagedControlPlaneClassSpec struct {
3131
// +optional
3232
ClusterNetwork *ClusterNetwork `json:"clusterNetwork,omitempty"`
3333

34+
// ClusterSecurity defines the cluster security.
35+
// +optional
36+
ClusterSecurity *ClusterSecurity `json:"clusterSecurity,omitempty"`
37+
3438
// Project is the name of the project to deploy the cluster to.
3539
Project string `json:"project"`
3640

exp/api/v1beta1/zz_generated.deepcopy.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)