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

🌱 Add registryMirrorConfigurations to allowedList in KubeadmControlPlane webhook #23

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
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, kubeadmConfigSpec, clusterConfiguration, controllerManager, "*"},
{spec, kubeadmConfigSpec, clusterConfiguration, scheduler},
{spec, kubeadmConfigSpec, clusterConfiguration, scheduler, "*"},
{spec, kubeadmConfigSpec, clusterConfiguration, "registryMirror", "*"},
{spec, kubeadmConfigSpec, initConfiguration, nodeRegistration},
{spec, kubeadmConfigSpec, initConfiguration, nodeRegistration, "*"},
{spec, kubeadmConfigSpec, initConfiguration, patches, directory},
Expand All @@ -174,6 +175,7 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
{spec, kubeadmConfigSpec, joinConfiguration, "bottlerocketControl", "*"},
{spec, kubeadmConfigSpec, joinConfiguration, "bottlerocketCustomBootstrapContainers"},
{spec, kubeadmConfigSpec, joinConfiguration, "bottlerocketSettings", "*"},
{spec, kubeadmConfigSpec, joinConfiguration, "registryMirror", "*"},
{spec, kubeadmConfigSpec, preKubeadmCommands},
{spec, kubeadmConfigSpec, postKubeadmCommands},
{spec, kubeadmConfigSpec, files},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
ImageTag: "1.6.5",
},
},
RegistryMirror: bootstrapv1.RegistryMirrorConfiguration{
Endpoint: "https://1.1.1.1:1111",
CACert: "test-cert",
},
},
JoinConfiguration: &bootstrapv1.JoinConfiguration{
Discovery: bootstrapv1.Discovery{
Expand All @@ -312,6 +316,10 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
NodeRegistration: bootstrapv1.NodeRegistrationOptions{
Name: "test",
},
RegistryMirror: bootstrapv1.RegistryMirrorConfiguration{
Endpoint: "https://1.1.1.1:1111",
CACert: "test-cert",
},
},
PreKubeadmCommands: []string{
"test", "foo",
Expand Down Expand Up @@ -699,6 +707,18 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
{"/var/lib/testdir", "/var/lib/etcd/data"},
}

validUpdateClusterConfigRegistryMirrorCACert := before.DeepCopy()
validUpdateClusterConfigRegistryMirrorCACert.Spec.KubeadmConfigSpec.ClusterConfiguration.RegistryMirror.CACert = "foo:bar"

validUpdateJoinConfigRegistryMirrorCACert := before.DeepCopy()
validUpdateJoinConfigRegistryMirrorCACert.Spec.KubeadmConfigSpec.JoinConfiguration.RegistryMirror.CACert = "foo:bar"

validUpdateClusterConfigRegistryMirrorEndpoint := before.DeepCopy()
validUpdateClusterConfigRegistryMirrorEndpoint.Spec.KubeadmConfigSpec.ClusterConfiguration.RegistryMirror.Endpoint = "https://0.0.0.0:6443"

validUpdateJoinConfigRegistryMirrorEndpoint := before.DeepCopy()
validUpdateJoinConfigRegistryMirrorEndpoint.Spec.KubeadmConfigSpec.JoinConfiguration.RegistryMirror.Endpoint = "https://0.0.0.0:6443"

tests := []struct {
name string
enableIgnitionFeature bool
Expand Down Expand Up @@ -1104,6 +1124,31 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: before,
kcp: validUpdateJoinConfBRCustomBootstrapContainers,
},
{
name: "should allow changes to join configuration registry mirror caCert",
expectErr: false,
before: before,
kcp: validUpdateJoinConfigRegistryMirrorCACert,
},
{
name: "should allow changes to join configuration registry mirror endpoint",
expectErr: false,
before: before,
kcp: validUpdateJoinConfigRegistryMirrorEndpoint,
},
{
name: "should allow changes to cluster configuration registry mirror caCert",
expectErr: false,
before: before,
kcp: validUpdateClusterConfigRegistryMirrorCACert,
},

{
name: "should allow changes to cluster configuration registry mirror endpoint",
expectErr: false,
before: before,
kcp: validUpdateClusterConfigRegistryMirrorEndpoint,
},
}

for _, tt := range tests {
Expand Down
Loading