Skip to content

Commit

Permalink
Merge pull request #56 from cmurphy/private-cluster-config
Browse files Browse the repository at this point in the history
Only send PrivateClusterConfig for private clusters
  • Loading branch information
cmurphy authored Jun 25, 2021
2 parents acf99be + de5bd34 commit 32889b9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/gke/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func newClusterCreateRequest(config *gkev1.GKEClusterConfig) *gkeapi.CreateClust
}
}

if config.Spec.PrivateClusterConfig != nil {
if config.Spec.PrivateClusterConfig != nil && config.Spec.PrivateClusterConfig.EnablePrivateNodes {
request.Cluster.PrivateClusterConfig = &gkeapi.PrivateClusterConfig{
EnablePrivateEndpoint: config.Spec.PrivateClusterConfig.EnablePrivateEndpoint,
EnablePrivateNodes: config.Spec.PrivateClusterConfig.EnablePrivateNodes,
Expand Down Expand Up @@ -232,6 +232,9 @@ func validateCreateRequest(ctx context.Context, client *gkeapi.Service, config *
if config.Spec.PrivateClusterConfig == nil {
return fmt.Errorf(cannotBeNilError, "privateClusterConfig", config.Name)
}
if config.Spec.PrivateClusterConfig.EnablePrivateEndpoint && !config.Spec.PrivateClusterConfig.EnablePrivateNodes {
return fmt.Errorf("private endpoint requires private nodes for cluster [%s]", config.Name)
}
if config.Spec.MasterAuthorizedNetworksConfig == nil {
return fmt.Errorf(cannotBeNilError, "masterAuthorizedNetworksConfig", config.Name)
}
Expand Down

0 comments on commit 32889b9

Please sign in to comment.