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

fix Blocking SSH access for all provisioned and upgraded Kyma runtimes #3457

Merged
merged 2 commits into from
Jul 3, 2024
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
19 changes: 18 additions & 1 deletion components/provisioner/internal/model/gardener_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package model
import (
"encoding/json"
"fmt"

"github.com/hashicorp/go-version"

gardener_types "github.com/gardener/gardener/pkg/apis/core/v1beta1"
Expand Down Expand Up @@ -365,6 +364,9 @@ func (c GCPGardenerConfig) ExtendShootConfig(gardenerConfig GardenerConfig, shoo
ControlPlaneConfig: &apimachineryRuntime.RawExtension{Raw: jsonCPData},
InfrastructureConfig: &apimachineryRuntime.RawExtension{Raw: jsonData},
Workers: workers,
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
}

return nil
Expand Down Expand Up @@ -519,6 +521,9 @@ func (c AzureGardenerConfig) ExtendShootConfig(gardenerConfig GardenerConfig, sh
ControlPlaneConfig: &apimachineryRuntime.RawExtension{Raw: jsonCPData},
InfrastructureConfig: &apimachineryRuntime.RawExtension{Raw: jsonData},
Workers: workers,
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
}

return nil
Expand Down Expand Up @@ -662,6 +667,9 @@ func (c AWSGardenerConfig) ExtendShootConfig(gardenerConfig GardenerConfig, shoo
ControlPlaneConfig: &apimachineryRuntime.RawExtension{Raw: jsonCPData},
InfrastructureConfig: &apimachineryRuntime.RawExtension{Raw: jsonData},
Workers: workers,
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
}

return nil
Expand Down Expand Up @@ -728,6 +736,9 @@ func (c OpenStackGardenerConfig) ExtendShootConfig(gardenerConfig GardenerConfig
ControlPlaneConfig: &apimachineryRuntime.RawExtension{Raw: jsonCPData},
InfrastructureConfig: &apimachineryRuntime.RawExtension{Raw: jsonData},
Workers: workers,
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
}

return nil
Expand Down Expand Up @@ -794,6 +805,12 @@ func updateShootConfig(upgradeConfig GardenerConfig, shoot *gardener_types.Shoot
if util.NotNilOrEmpty(upgradeConfig.MachineImageVersion) {
shoot.Spec.Provider.Workers[0].Machine.Image.Version = upgradeConfig.MachineImageVersion
}

// block SSHAccess for all upgraded clusters
shoot.Spec.Provider.WorkersSettings = &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
}

if upgradeConfig.OIDCConfig != nil {
if shoot.Spec.Kubernetes.KubeAPIServer == nil {
shoot.Spec.Kubernetes.KubeAPIServer = &gardener_types.KubeAPIServerConfig{}
Expand Down
15 changes: 15 additions & 0 deletions components/provisioner/internal/model/gardener_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ func TestGardenerConfig_ToShootTemplate(t *testing.T) {
Workers: []gardener_types.Worker{
fixWorker([]string{"fix-zone-1", "fix-zone-2"}, nil),
},
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
},
Purpose: &purpose,
ExposureClassName: util.PtrTo("internet"),
Expand Down Expand Up @@ -288,6 +291,9 @@ func TestGardenerConfig_ToShootTemplate(t *testing.T) {
Workers: []gardener_types.Worker{
fixWorker([]string{"fix-zone-1", "fix-zone-2"}, nil),
},
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
},
Purpose: &purpose,
ExposureClassName: util.PtrTo("internet"),
Expand Down Expand Up @@ -370,6 +376,9 @@ func TestGardenerConfig_ToShootTemplate(t *testing.T) {
Workers: []gardener_types.Worker{
fixWorker(nil, nil),
},
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
},
Purpose: &purpose,
ExposureClassName: util.PtrTo("internet"),
Expand Down Expand Up @@ -452,6 +461,9 @@ func TestGardenerConfig_ToShootTemplate(t *testing.T) {
Workers: []gardener_types.Worker{
fixWorker([]string{"1", "2"}, nil),
},
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
},
Purpose: &purpose,
ExposureClassName: util.PtrTo("internet"),
Expand Down Expand Up @@ -536,6 +548,9 @@ func TestGardenerConfig_ToShootTemplate(t *testing.T) {
Raw: []byte(`{"kind":"WorkerConfig","apiVersion":"aws.provider.extensions.gardener.cloud/v1alpha1","instanceMetadataOptions":{"httpTokens":"required","httpPutResponseHopLimit":2}}`),
}),
},
WorkersSettings: &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
},
},
Purpose: &purpose,
ExposureClassName: util.PtrTo("internet"),
Expand Down
3 changes: 3 additions & 0 deletions components/provisioner/internal/util/testkit/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func (ts *TestShoot) WithExposureClassName(exposureClassName string) *TestShoot
// See also testkit.TestWorker
func (ts *TestShoot) WithWorkers(workers ...v1beta1.Worker) *TestShoot {
ts.shoot.Spec.Provider.Workers = append(ts.shoot.Spec.Provider.Workers, workers...)
ts.shoot.Spec.Provider.WorkersSettings = &gardener_types.WorkersSettings{
SSHAccess: &gardener_types.SSHAccess{Enabled: false},
}
return ts
}

Expand Down
Loading