Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLT-1330] CMEK, SA & CIDRs #642

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

## 0.17.0-0.6.1 (upcoming)

* [PLT-1330] CMEK - Service accounts & Secondary CIDR ranges adaption to R4.7
* [Core] Fix [PLT-964]

## 0.17.0-0.6.0 (2024-11-11)
Expand Down
12 changes: 12 additions & 0 deletions pkg/cluster/internal/validate/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ func validateGCP(spec commons.KeosSpec, providerSecrets map[string]string) error
}
}
}
// Validate encryptionKey for managed clusters root volume
isKeyValid := regexp.MustCompile(`^projects/[a-zA-Z0-9-]+/locations/[a-zA-Z0-9-]+/keyRings/[a-zA-Z0-9-]+/cryptoKeys/[a-zA-Z0-9-]+$`).MatchString
for _, wn := range spec.WorkerNodes {
if wn.RootVolume.Encrypted {
if wn.RootVolume.EncryptionKey == "" {
return errors.New("spec.control_plane.root_volume: \"encryption_key\": is required when \"encrypted\" is set to true")
}
if !isKeyValid(wn.RootVolume.EncryptionKey) {
return errors.New("spec.control_plane.root_volume: \"encryption_key\": it must have the format projects/[PROJECT_ID]/locations/[REGION]/keyRings/[RING_NAME]/cryptoKeys/[KEY_NAME]")
}
}
}
}

for _, wn := range spec.WorkerNodes {
Expand Down
14 changes: 14 additions & 0 deletions pkg/commons/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ type GCPCP struct {
MasterAuthorizedNetworksConfig *MasterAuthorizedNetworksConfig `yaml:"master_authorized_networks_config,omitempty"`
MonitoringConfig *MonitoringConfig `yaml:"monitoring_config,omitempty"`
LoggingConfig *LoggingConfig `yaml:"logging_config,omitempty"`
ClusterIpv4Cidr string `yaml:"cluster_ipv4_cidr,omitempty"`
IPAllocationPolicy IPAllocationPolicy `yaml:"ip_allocation_policy,omitempty"`
}

type ClusterNetwork struct {
Expand Down Expand Up @@ -218,6 +220,15 @@ type LoggingConfig struct {
Workloads *bool `yaml:"workloads,omitempty"`
}

type IPAllocationPolicy struct {
// +kubebuilder:default=true
UseIPAliases bool `yaml:"use_ip_aliases,omitempty"`
ClusterSecondaryRangeName string `yaml:"cluster_secondary_range_name,omitempty"`
ServicesSecondaryRangeName string `yaml:"services_secondary_range_name,omitempty"`
ClusterIpv4CidrBlock string `yaml:"cluster_ipv4_cidr_block,omitempty"`
ServicesIpv4CidrBlock string `yaml:"services_ipv4_cidr_block,omitempty"`
}

type Keos struct {
Flavour string `yaml:"flavour,omitempty"`
}
Expand Down Expand Up @@ -259,6 +270,9 @@ type Security struct {
AWS struct {
CreateIAM bool `yaml:"create_iam" validate:"boolean"`
} `yaml:"aws,omitempty"`
GCP struct {
Scopes []string `yaml:"scopes,omitempty"`
} `yaml:"gcp,omitempty"`
}

type WorkerNodes []struct {
Expand Down