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 bootCommands to cloud-init file generation #11271

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
31406da
Add bootCommands cloud-init file generation
davidumea Sep 26, 2024
97311d6
fixup: go lint
davidumea Oct 18, 2024
4367074
fixup: lint: added missing newline
davidumea Oct 18, 2024
0c23af8
fixup: add changes from verify-gen
davidumea Oct 18, 2024
504dfd5
fixup: filter tests
davidumea Oct 18, 2024
19d52df
fixup: clearer documentation for BootCommands, PreKubeadmCommands and…
davidumea Oct 18, 2024
51068a2
fixup: verify: reflect new documentation in the crds
davidumea Oct 18, 2024
8ed0171
fixup: restore v1alpha3,v1alpha4 and add conversions
davidumea Oct 22, 2024
332e78d
fixup: non-nil values for bootcommands in cloudinit tests
davidumea Oct 22, 2024
28edd6c
fixup: lint
davidumea Oct 22, 2024
8918ff3
fixup: verify crds
davidumea Nov 5, 2024
94835dc
fixup: use yaml names in go doc comments
davidumea Nov 25, 2024
84e06c6
fixup: removed extra linebreak
davidumea Nov 25, 2024
bd63a05
fixup: remove bootcommands from testing AdditionalFileEncodings
davidumea Nov 26, 2024
a4f3bdb
fixup: make sure bootcommands show up in generated output
davidumea Nov 26, 2024
4673fb0
fixup: add test for join cp commands
davidumea Nov 26, 2024
c059138
fixup: add test for join node commands
davidumea Nov 26, 2024
6fb468d
fixup: ensure commands show up in the right section
davidumea Dec 3, 2024
810f7d6
fixup: fix webhook
davidumea Jan 10, 2025
03cbf01
fixup: update copyright year
davidumea Jan 10, 2025
b7c575a
fixup: make sure bootCommands is not configured when ignition format …
davidumea Jan 13, 2025
0484cdc
fixup: use constant when checking kubeadmconfig format
davidumea Jan 24, 2025
3db48fa
fixup: add bootcommands check to validateIgnition function
davidumea Jan 24, 2025
23a608c
fixup: remove webhook check
davidumea Jan 24, 2025
ccd5c8b
fixup: remove bootcommand from ignition clc test
davidumea Feb 19, 2025
1874ba8
fixup: clarified bootcommands test in cloudinit test
davidumea Feb 19, 2025
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
Prev Previous commit
Next Next commit
fixup: make sure bootCommands is not configured when ignition format …
…is used
davidumea committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b7c575a63f5f0aafbb6108076859ac36db7d6d8e
6 changes: 6 additions & 0 deletions bootstrap/kubeadm/internal/webhooks/kubeadmconfig.go
Original file line number Diff line number Diff line change
@@ -65,6 +65,9 @@ func (webhook *KubeadmConfig) ValidateCreate(_ context.Context, obj runtime.Obje
if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a KubeadmConfig but got a %T", obj))
}
if c.Spec.BootCommands != nil && c.Spec.Format != "cloud-config" {
davidumea marked this conversation as resolved.
Show resolved Hide resolved
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected config format to be cloud-config when using bootCommands, got %T", c.Spec.Format))
}

return nil, webhook.validate(c.Spec, c.Name)
}
@@ -75,6 +78,9 @@ func (webhook *KubeadmConfig) ValidateUpdate(_ context.Context, _, newObj runtim
if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a KubeadmConfig but got a %T", newObj))
}
if newC.Spec.BootCommands != nil && newC.Spec.Format != "cloud-config" {
davidumea marked this conversation as resolved.
Show resolved Hide resolved
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected config format to be cloud-config when using bootCommands, got %T", newC.Spec.Format))
}

return nil, webhook.validate(newC.Spec, newC.Name)
}
30 changes: 30 additions & 0 deletions bootstrap/kubeadm/internal/webhooks/kubeadmconfig_test.go
Original file line number Diff line number Diff line change
@@ -457,6 +457,36 @@ func TestKubeadmConfigValidate(t *testing.T) {
},
expectErr: true,
},
"bootCommands configured with ignition format": {
enableIgnitionFeature: true,
in: &bootstrapv1.KubeadmConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "baz",
Namespace: metav1.NamespaceDefault,
},
Spec: bootstrapv1.KubeadmConfigSpec{
Format: bootstrapv1.Ignition,
BootCommands: []bootstrapv1.BootCommand{
{"echo", "$(date) hello BootCommands!"},
},
},
},
expectErr: true,
},
"bootCommands configured with cloud-config format": {
in: &bootstrapv1.KubeadmConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "baz",
Namespace: metav1.NamespaceDefault,
},
Spec: bootstrapv1.KubeadmConfigSpec{
Format: "cloud-config",
davidumea marked this conversation as resolved.
Show resolved Hide resolved
BootCommands: []bootstrapv1.BootCommand{
{"echo", "$(date) hello BootCommands!"},
},
},
},
},
}

for name, tt := range cases {