Skip to content

Commit

Permalink
Merge pull request #3066 from CecileRobertMichon/etcd-mount
Browse files Browse the repository at this point in the history
✨ CABPK: Support disk_setup and mounts in cloud-init
  • Loading branch information
k8s-ci-robot committed Jun 1, 2020
2 parents cadd99c + d910413 commit 2afc70d
Show file tree
Hide file tree
Showing 17 changed files with 673 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bootstrap/kubeadm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,6 @@ The `KubeadmConfig` object supports customizing the content of the config-data:
- `KubeadmConfig.PostKubeadmCommands` same as above, but after `kubeadm init/join`
- `KubeadmConfig.Users` specifies a list of users to be created on the machine
- `KubeadmConfig.NTP` specifies NTP settings for the machine
- `KubeadmConfig.DiskSetup` specifies options for the creation of partition tables and file systems on devices.
- `KubeadmConfig.Mounts` specifies a list of mount points to be setup.
- `KubeadmConfig.Verbosity` specifies the `kubeadm` log level verbosity
2 changes: 2 additions & 0 deletions bootstrap/kubeadm/api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error {
dst.Status.ObservedGeneration = restored.Status.ObservedGeneration
dst.Spec.Verbosity = restored.Spec.Verbosity
dst.Spec.UseExperimentalRetryJoin = restored.Spec.UseExperimentalRetryJoin
dst.Spec.DiskSetup = restored.Spec.DiskSetup
dst.Spec.Mounts = restored.Spec.Mounts
dst.Spec.Files = restored.Spec.Files

// Track files successfully up-converted. We need this to dedupe
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/kubeadm/api/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/kubeadmbootstrapconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ type KubeadmConfigSpec struct {
// +optional
Files []File `json:"files,omitempty"`

// DiskSetup specifies options for the creation of partition tables and file systems on devices.
// +optional
DiskSetup *DiskSetup `json:"diskSetup,omitempty"`

// Mounts specifies a list of mount points to be setup.
// +optional
Mounts []MountPoints `json:"mounts,omitempty"`

// PreKubeadmCommands specifies extra commands to run before kubeadm runs
// +optional
PreKubeadmCommands []string `json:"preKubeadmCommands,omitempty"`
Expand Down Expand Up @@ -260,3 +268,57 @@ type NTP struct {
// +optional
Enabled *bool `json:"enabled,omitempty"`
}

// DiskSetup defines input for generated disk_setup and fs_setup in cloud-init.
type DiskSetup struct {
// Partitions specifies the list of the partitions to setup.
Partitions []Partition `json:"partitions,omitempty"`
// Filesystems specifies the list of file systems to setup.
Filesystems []Filesystem `json:"filesystems,omitempty"`
}

// Partition defines how to create and layout a partition.
type Partition struct {
// Device is the name of the device.
Device string `json:"device"`
// Layout specifies the device layout.
// If it is true, a single partition will be created for the entire device.
// When layout is false, it means don't partition or ignore existing partitioning.
Layout bool `json:"layout"`
// Overwrite describes whether to skip checks and create the partition if a partition or filesystem is found on the device.
// Use with caution. Default is 'false'.
// +optional
Overwrite *bool `json:"overwrite,omitempty"`
// TableType specifies the tupe of partition table. The following are supported:
// 'mbr': default and setups a MS-DOS partition table
// 'gpt': setups a GPT partition table
// +optional
TableType *string `json:"tableType,omitempty"`
}

// Filesystem defines the file systems to be created.
type Filesystem struct {
// Device specifies the device name
Device string `json:"device"`
// Filesystem specifies the file system type.
Filesystem string `json:"filesystem"`
// Label specifies the file system label to be used. If set to None, no label is used.
Label string `json:"label"`
// Partition specifies the partition to use. The valid options are: "auto|any", "auto", "any", "none", and <NUM>, where NUM is the actual partition number.
// +optional
Partition *string `json:"partition,omitempty"`
// Overwrite defines whether or not to overwrite any existing filesystem.
// If true, any pre-existing file system will be destroyed. Use with Caution.
// +optional
Overwrite *bool `json:"overwrite,omitempty"`
// ReplaceFS is a special directive, used for Microsoft Azure that instructs cloud-init to replace a file system of <FS_TYPE>.
// NOTE: unless you define a label, this requires the use of the 'any' partition directive.
// +optional
ReplaceFS *string `json:"replaceFS,omitempty"`
// ExtraOpts defined extra options to add to the command for creating the file system.
// +optional
ExtraOpts []string `json:"extraOpts,omitempty"`
}

// MountPoints defines input for generated mounts in cloud-init.
type MountPoints []string
124 changes: 124 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,86 @@ spec:
images
type: boolean
type: object
diskSetup:
description: DiskSetup specifies options for the creation of partition
tables and file systems on devices.
properties:
filesystems:
description: Filesystems specifies the list of file systems to
setup.
items:
description: Filesystem defines the file systems to be created.
properties:
device:
description: Device specifies the device name
type: string
extraOpts:
description: ExtraOpts defined extra options to add to the
command for creating the file system.
items:
type: string
type: array
filesystem:
description: Filesystem specifies the file system type.
type: string
label:
description: Label specifies the file system label to be
used. If set to None, no label is used.
type: string
overwrite:
description: Overwrite defines whether or not to overwrite
any existing filesystem. If true, any pre-existing file
system will be destroyed. Use with Caution.
type: boolean
partition:
description: 'Partition specifies the partition to use.
The valid options are: "auto|any", "auto", "any", "none",
and <NUM>, where NUM is the actual partition number.'
type: string
replaceFS:
description: 'ReplaceFS is a special directive, used for
Microsoft Azure that instructs cloud-init to replace a
file system of <FS_TYPE>. NOTE: unless you define a label,
this requires the use of the ''any'' partition directive.'
type: string
required:
- device
- filesystem
- label
type: object
type: array
partitions:
description: Partitions specifies the list of the partitions to
setup.
items:
description: Partition defines how to create and layout a partition.
properties:
device:
description: Device is the name of the device.
type: string
layout:
description: Layout specifies the device layout. If it is
true, a single partition will be created for the entire
device. When layout is false, it means don't partition
or ignore existing partitioning.
type: boolean
overwrite:
description: Overwrite describes whether to skip checks
and create the partition if a partition or filesystem
is found on the device. Use with caution. Default is 'false'.
type: boolean
tableType:
description: 'TableType specifies the tupe of partition
table. The following are supported: ''mbr'': default and
setups a MS-DOS partition table ''gpt'': setups a GPT
partition table'
type: string
required:
- device
- layout
type: object
type: array
type: object
files:
description: Files specifies extra files to be passed to user_data
upon creation.
Expand Down Expand Up @@ -1552,6 +1632,14 @@ spec:
type: array
type: object
type: object
mounts:
description: Mounts specifies a list of mount points to be setup.
items:
description: MountPoints defines input for generated mounts in cloud-init.
items:
type: string
type: array
type: array
ntp:
description: NTP specifies NTP configuration
properties:
Expand Down
Loading

0 comments on commit 2afc70d

Please sign in to comment.