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: clearer documentation for BootCommands, PreKubeadmCommands and…
… PostKubeadmCommands
davidumea committed Nov 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 19d52df391254a04058dbead92751bc95f1ee794
11 changes: 8 additions & 3 deletions bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go
Original file line number Diff line number Diff line change
@@ -75,15 +75,20 @@ type KubeadmConfigSpec struct {
// +optional
Mounts []MountPoints `json:"mounts,omitempty"`

// BootCommands specifies extra commands to run very early in the boot process
// BootCommands specifies extra commands to run very early in the boot process via the cloud-init bootcmd
davidumea marked this conversation as resolved.
Show resolved Hide resolved
// module. This is typically run in the cloud-init.service systemd unit. This has no effect in Ignition.
davidumea marked this conversation as resolved.
Show resolved Hide resolved
// +optional
BootCommands []BootCommand `json:"bootCommands,omitempty"`

// PreKubeadmCommands specifies extra commands to run before kubeadm runs
// PreKubeadmCommands specifies extra commands to run before kubeadm runs.
// With cloud-init, this is prepended to the runcmd module configuration, and is typically executed in
// the cloud-final.service systemd unit. In Ignition, this is prepended to /etc/kubeadm.sh.
// +optional
PreKubeadmCommands []string `json:"preKubeadmCommands,omitempty"`

// postKubeadmCommands specifies extra commands to run after kubeadm runs
// PostKubeadmCommands specifies extra commands to run after kubeadm runs.
// With cloud-init, this is appended to the runcmd module configuration, and is typically executed in
// the cloud-final.service systemd unit. In Ignition, this is appended to /etc/kubeadm.sh.
// +optional
PostKubeadmCommands []string `json:"postKubeadmCommands,omitempty"`

11 changes: 8 additions & 3 deletions internal/apis/bootstrap/kubeadm/v1alpha3/kubeadmconfig_types.go
Original file line number Diff line number Diff line change
@@ -59,15 +59,20 @@ type KubeadmConfigSpec struct {
// +optional
Mounts []MountPoints `json:"mounts,omitempty"`

// BootCommands specifies extra commands to run very early in the boot process
// BootCommands specifies extra commands to run very early in the boot process via the cloud-init bootcmd
// module. This is typically run in the cloud-init.service systemd unit. This has no effect in Ignition.
// +optional
BootCommands []BootCommand `json:"bootCommands,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be added only to v1beta1 which is the actively maintained API version?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove this and run make verify, it removes bootCommands from the CRDs.

Might be an issue in the verify logic, what do you think?

diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml
index 79c3b19e0..4e1852f77 100644
--- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml
+++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml
@@ -47,17 +47,6 @@ spec:
               KubeadmConfigSpec defines the desired state of KubeadmConfig.
               Either ClusterConfiguration and InitConfiguration should be defined or the JoinConfiguration should be defined.
             properties:
-              bootCommands:
-                description: |-
-                  BootCommands specifies extra commands to run very early in the boot process via the cloud-init bootcmd
-                  module. This is typically run in the cloud-init.service systemd unit. This has no effect in Ignition.
-                items:
-                  description: BootCommand defines input for each bootcmd command
-                    in cloud-init.
-                  items:
-                    type: string
-                  type: array
-                type: array
               clusterConfiguration:
                 description: ClusterConfiguration along with InitConfiguration are
                   the configurations necessary for the init command

etc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New fields should not be added to older API versions.
Conversions should be implemented instead.
See eg

dst.Files = restored.Files
dst.Users = restored.Users
if restored.Users != nil {
for i := range restored.Users {
if restored.Users[i].PasswdFrom != nil {
dst.Users[i].PasswdFrom = restored.Users[i].PasswdFrom
}
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted my changes to the v1alpha3 and v1alpha4 versions and added conversions instead a9c426a

Copy link
Author

@davidumea davidumea Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove this and run make verify, it removes bootCommands from the CRDs.

Disregard this, I didn't realize that all versions of the crds were in the same manifest.


// PreKubeadmCommands specifies extra commands to run before kubeadm runs
// PreKubeadmCommands specifies extra commands to run before kubeadm runs.
// With cloud-init, this is prepended to the runcmd module configuration, and is typically executed in
// the cloud-final.service systemd unit. In Ignition, this is prepended to /etc/kubeadm.sh.
// +optional
PreKubeadmCommands []string `json:"preKubeadmCommands,omitempty"`

// postKubeadmCommands specifies extra commands to run after kubeadm runs
// PostKubeadmCommands specifies extra commands to run after kubeadm runs.
// With cloud-init, this is appended to the runcmd module configuration, and is typically executed in
// the cloud-final.service systemd unit. In Ignition, this is appended to /etc/kubeadm.sh.
// +optional
PostKubeadmCommands []string `json:"postKubeadmCommands,omitempty"`