Skip to content

Commit

Permalink
[PLT-806] GKE nodos privados (#15)
Browse files Browse the repository at this point in the history
* Private Cluster

* RemoveDebug

* Update Changelog
  • Loading branch information
iamjanr authored Oct 3, 2024
1 parent 791d8fc commit 282b46b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.6.1-0.2.0 (upcoming)

* Add GKE Private cluster support
* Fix autoscaling issues
* First approach to manage taints addition, update and deletion on GKE
* After creating a GKE cluster, it takes ~20 minutes for its status to be READY
Expand Down
9 changes: 9 additions & 0 deletions cloud/services/container/clusters/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ func (s *Service) createCluster(ctx context.Context, log *logr.Logger) error {
if s.scope.GCPManagedControlPlane.Spec.ControlPlaneVersion != nil {
cluster.InitialClusterVersion = convertToSdkMasterVersion(*s.scope.GCPManagedControlPlane.Spec.ControlPlaneVersion)
}
if s.scope.GCPManagedControlPlane.Spec.ClusterNetwork != nil {
cn := s.scope.GCPManagedControlPlane.Spec.ClusterNetwork
if cn.PrivateCluster != nil {
cluster.PrivateClusterConfig = &containerpb.PrivateClusterConfig{}
cluster.PrivateClusterConfig.EnablePrivateNodes = cn.PrivateCluster.EnablePrivateNodes
cluster.PrivateClusterConfig.MasterIpv4CidrBlock = cn.PrivateCluster.ControlPlaneCidrBlock
}
}
// If the cluster is autopilot, we don't need to specify node pools.
if !s.scope.IsAutopilotCluster() {
cluster.NodePools = scope.ConvertToSdkNodePools(nodePools, machinePools, isRegional, cluster.Name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,26 @@ spec:
If you don't specify a name then a default name will be created
based on the namespace and name of the managed control plane.
type: string
clusterNetwork:
description: ClusterNetwork define the cluster network.
properties:
privateCluster:
description: PrivateCluster defines the private cluster spec.
properties:
controlPlaneCidrBlock:
description: |-
ControlPlaneCidrBlock is the IP range in CIDR notation to use for the hosted master network. This range must not
overlap with any other ranges in use within the cluster's network. Honored when enabled is true.
type: string
enablePrivateNodes:
description: |-
EnablePrivateNodes: Whether nodes have internal IP
addresses only. If enabled, all nodes are given only RFC
1918 private addresses and communicate with the master via
private networking.
type: boolean
type: object
type: object
controlPlaneVersion:
description: |-
ControlPlaneVersion represents the control plane version of the GKE cluster.
Expand Down
23 changes: 23 additions & 0 deletions exp/api/v1beta1/gcpmanagedcontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,36 @@ const (
ManagedControlPlaneFinalizer = "gcpmanagedcontrolplane.infrastructure.cluster.x-k8s.io"
)

type PrivateCluster struct {
// EnablePrivateNodes: Whether nodes have internal IP
// addresses only. If enabled, all nodes are given only RFC
// 1918 private addresses and communicate with the master via
// private networking.
// +optional
EnablePrivateNodes bool `json:"enablePrivateNodes,omitempty"`
// ControlPlaneCidrBlock is the IP range in CIDR notation to use for the hosted master network. This range must not
// overlap with any other ranges in use within the cluster's network. Honored when enabled is true.
// +optional
ControlPlaneCidrBlock string `json:"controlPlaneCidrBlock,omitempty"`
}

// ClusterNetwork define the cluster network.
type ClusterNetwork struct {
// PrivateCluster defines the private cluster spec.
// +optional
PrivateCluster *PrivateCluster `json:"privateCluster,omitempty"`
}

// GCPManagedControlPlaneSpec defines the desired state of GCPManagedControlPlane.
type GCPManagedControlPlaneSpec struct {
// ClusterName allows you to specify the name of the GKE cluster.
// If you don't specify a name then a default name will be created
// based on the namespace and name of the managed control plane.
// +optional
ClusterName string `json:"clusterName,omitempty"`
// ClusterNetwork define the cluster network.
// +optional
ClusterNetwork *ClusterNetwork `json:"clusterNetwork,omitempty"`
// Project is the name of the project to deploy the cluster to.
Project string `json:"project"`
// Location represents the location (region or zone) in which the GKE cluster
Expand Down
40 changes: 40 additions & 0 deletions exp/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 282b46b

Please sign in to comment.