@@ -267,15 +267,20 @@ func (s *Service) createCluster(ctx context.Context, log *logr.Logger) error {
267267 ReleaseChannel : & containerpb.ReleaseChannel {
268268 Channel : convertToSdkReleaseChannel (s .scope .GCPManagedControlPlane .Spec .ReleaseChannel ),
269269 },
270+ BinaryAuthorization : & containerpb.BinaryAuthorization {
271+ EvaluationMode : convertToSdkBinaryAuthorizationEvaluationMode (s .scope .GCPManagedControlPlane .Spec .BinaryAuthorization ),
272+ },
270273 ControlPlaneEndpointsConfig : & containerpb.ControlPlaneEndpointsConfig {
271274 IpEndpointsConfig : & containerpb.ControlPlaneEndpointsConfig_IPEndpointsConfig {
272275 AuthorizedNetworksConfig : convertToSdkMasterAuthorizedNetworksConfig (s .scope .GCPManagedControlPlane .Spec .MasterAuthorizedNetworksConfig ),
273276 },
274277 },
275278 }
279+
276280 if initialClusterVersionFromSpec := s .scope .GetControlPlaneVersion (); initialClusterVersionFromSpec != nil {
277281 cluster .InitialClusterVersion = convertToSdkMasterVersion (* initialClusterVersionFromSpec )
278282 }
283+
279284 if s .scope .GCPManagedControlPlane .Spec .ClusterNetwork != nil {
280285 cn := s .scope .GCPManagedControlPlane .Spec .ClusterNetwork
281286 if cn .UseIPAliases {
@@ -284,16 +289,19 @@ func (s *Service) createCluster(ctx context.Context, log *logr.Logger) error {
284289 cluster .IpAllocationPolicy .ClusterIpv4CidrBlock = cn .Pod .CidrBlock
285290 cluster .IpAllocationPolicy .ServicesIpv4CidrBlock = cn .Service .CidrBlock
286291 }
292+
287293 if cn .PrivateCluster != nil {
288294 cluster .PrivateClusterConfig = & containerpb.PrivateClusterConfig {}
289295
290296 enablePublicEndpoint := ! cn .PrivateCluster .EnablePrivateEndpoint
291297 cluster .ControlPlaneEndpointsConfig .IpEndpointsConfig .EnablePublicEndpoint = & enablePublicEndpoint
298+
292299 if cn .PrivateCluster .EnablePrivateEndpoint {
293300 cluster .ControlPlaneEndpointsConfig .IpEndpointsConfig .AuthorizedNetworksConfig = & containerpb.MasterAuthorizedNetworksConfig {
294301 Enabled : true ,
295302 }
296303 }
304+
297305 cluster .NetworkConfig .DefaultEnablePrivateNodes = & cn .PrivateCluster .EnablePrivateNodes
298306
299307 cluster .PrivateClusterConfig .MasterIpv4CidrBlock = cn .PrivateCluster .ControlPlaneCidrBlock
@@ -306,16 +314,35 @@ func (s *Service) createCluster(ctx context.Context, log *logr.Logger) error {
306314 }
307315 }
308316 }
317+
309318 if ! s .scope .IsAutopilotCluster () {
310319 cluster .NodePools = scope .ConvertToSdkNodePools (nodePools , machinePools , isRegional , cluster .GetName ())
320+
311321 if s .scope .GCPManagedControlPlane .Spec .LoggingService != nil {
312322 cluster .LoggingService = s .scope .GCPManagedControlPlane .Spec .LoggingService .String ()
313323 }
324+
314325 if s .scope .GCPManagedControlPlane .Spec .MonitoringService != nil {
315326 cluster .MonitoringService = s .scope .GCPManagedControlPlane .Spec .MonitoringService .String ()
316327 }
317328 }
318329
330+ if s .scope .GCPManagedControlPlane .Spec .ClusterSecurity != nil {
331+ cs := s .scope .GCPManagedControlPlane .Spec .ClusterSecurity
332+ if cs .WorkloadIdentityConfig != nil {
333+ cluster .WorkloadIdentityConfig = & containerpb.WorkloadIdentityConfig {
334+ WorkloadPool : cs .WorkloadIdentityConfig .WorkloadPool ,
335+ }
336+ }
337+
338+ if cs .AuthenticatorGroupConfig != nil {
339+ cluster .AuthenticatorGroupsConfig = & containerpb.AuthenticatorGroupsConfig {
340+ Enabled : true ,
341+ SecurityGroup : cs .AuthenticatorGroupConfig .SecurityGroups ,
342+ }
343+ }
344+ }
345+
319346 createClusterRequest := & containerpb.CreateClusterRequest {
320347 Cluster : cluster ,
321348 Parent : s .scope .ClusterLocation (),
@@ -425,6 +452,22 @@ func convertToSdkMasterAuthorizedNetworksConfig(config *infrav1exp.MasterAuthori
425452 }
426453}
427454
455+ // convertToSdkBinaryAuthorizationEvaluationMode converts the BinaryAuthorization string to the SDK int32 value.
456+ func convertToSdkBinaryAuthorizationEvaluationMode (mode * infrav1exp.BinaryAuthorization ) containerpb.BinaryAuthorization_EvaluationMode {
457+ if mode == nil {
458+ return containerpb .BinaryAuthorization_EVALUATION_MODE_UNSPECIFIED
459+ }
460+
461+ switch * mode {
462+ case infrav1exp .EvaluationModeDisabled :
463+ return containerpb .BinaryAuthorization_DISABLED
464+ case infrav1exp .EvaluationModeProjectSingletonPolicyEnforce :
465+ return containerpb .BinaryAuthorization_PROJECT_SINGLETON_POLICY_ENFORCE
466+ default :
467+ return containerpb .BinaryAuthorization_EVALUATION_MODE_UNSPECIFIED
468+ }
469+ }
470+
428471func (s * Service ) checkDiffAndPrepareUpdate (existingCluster * containerpb.Cluster , log * logr.Logger ) (bool , * containerpb.UpdateClusterRequest ) {
429472 log .V (4 ).Info ("Checking diff and preparing update." )
430473
0 commit comments