Skip to content

Commit

Permalink
Add feature to specifiy additional host containers in BR
Browse files Browse the repository at this point in the history
Host containers are a feature within BR that allows us to pull images
without the need of having to bootstrap kuberentes. Such containers can
be superpowered and user-data can be attached to each one of them. As
such, this commit creates the `BottlerocketHostContainer` struct to allow
the user to customize the those fields. Users can specify an arbitrary
number of host containers in the `AdditionalHostContainers` field.

This commit also does some refactoring around the templating system BR
has to generate the TOML files. It generifies the host-container
template to be reused as much as a user wants to.

SIM: https://i.amazon.com/P66557529
cr: https://code.amazon.com/reviews/CR-71408825
  • Loading branch information
vpineda1996 authored and Prow Bot committed Jul 26, 2022
1 parent bbc6e6e commit e8c7576
Show file tree
Hide file tree
Showing 17 changed files with 569 additions and 126 deletions.
5 changes: 5 additions & 0 deletions bootstrap/kubeadm/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ func Convert_v1beta1_User_To_v1alpha4_User(in *bootstrapv1.User, out *User, s ap
// User.PasswdFrom does not exist in kubeadm v1alpha4 API.
return autoConvert_v1beta1_User_To_v1alpha4_User(in, out, s)
}

func Convert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in *bootstrapv1.ClusterConfiguration, out *ClusterConfiguration, s apiconversion.Scope) error {
// ClusterConfiguration.BottlerocketCustomHostContainers exists in bootstrapv1.ClusterConfiguration but not in v1alpha4
return autoConvert_v1beta1_ClusterConfiguration_To_v1alpha4_ClusterConfiguration(in, out, s)
}
37 changes: 25 additions & 12 deletions bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go

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

25 changes: 25 additions & 0 deletions bootstrap/kubeadm/api/v1beta1/kubeadm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ type ClusterConfiguration struct {
// The cluster name
// +optional
ClusterName string `json:"clusterName,omitempty"`

// BottlerocketHostContainers contains the information of any additional images
// that we will deploy as host containers in the CPIs
// +optional
BottlerocketHostContainers []BottlerocketHostContainer `json:"bottlerocketCustomHostContainers,omitempty"`
}

// Pause defines the pause image repo and tag that should be run on the bootstrapped nodes.
Expand Down Expand Up @@ -471,6 +476,26 @@ type JoinConfiguration struct {
// "kubeadm join". The minimum kubernetes version needed to support Patches is v1.22
// +optional
Patches *Patches `json:"patches,omitempty"`

// BottlerocketCustomHostContainers contains the information of any additional images
// that we will deploy as host containers in the CPIs
// +optional
BottlerocketCustomHostContainers []BottlerocketHostContainer `json:"bottlerocketCustomHostContainers,omitempty"`
}

// BottlerocketHostContainer describes a host image for Bottlerocket
type BottlerocketHostContainer struct {
// Name is the host container name that will be given to the container in BR's `apiserver`
// +kubebuilder:validation:Required
Name string `json:"name"`
// Superpowered indicates if the container will be superpowered
// +kubebuilder:validation:Required
Superpowered bool `json:"superpowered"`
// ImageMeta is the actual location of the container image
ImageMeta `json:"source"`
// UserData is the userdata that will be attached to the image.
// +optional
UserData string `json:"userData,omitempty"`
}

// JoinControlPlane contains elements describing an additional control plane instance to be deployed on the joining node.
Expand Down
26 changes: 26 additions & 0 deletions bootstrap/kubeadm/api/v1beta1/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 @@ -2394,6 +2394,48 @@ spec:
the version of the above components during upgrades.
type: string
type: object
bottlerocketCustomHostContainers:
description: BottlerocketHostContainers contains the information
of any additional images that we will deploy as host containers
in the CPIs
items:
description: BottlerocketHostContainer describes a host image
for Bottlerocket
properties:
name:
description: Name is the host container name that will be
given to the container in BR's `apiserver`
type: string
source:
description: ImageMeta is the actual location of the container
image
properties:
imageRepository:
description: ImageRepository sets the container registry
to pull images from. if not set, the ImageRepository
defined in ClusterConfiguration will be used instead.
type: string
imageTag:
description: ImageTag allows to specify a tag for the
image. In case this value is set, kubeadm does not
change automatically the version of the above components
during upgrades.
type: string
type: object
superpowered:
description: Superpowered indicates if the container will
be superpowered
type: boolean
userData:
description: UserData is the userdata that will be attached
to the image.
type: string
required:
- name
- source
- superpowered
type: object
type: array
certificatesDir:
description: 'CertificatesDir specifies where to store or look
for all required certificates. NB: if not provided, this will
Expand Down Expand Up @@ -3070,6 +3112,48 @@ spec:
the version of the above components during upgrades.
type: string
type: object
bottlerocketCustomHostContainers:
description: BottlerocketCustomHostContainers contains the information
of any additional images that we will deploy as host containers
in the CPIs
items:
description: BottlerocketHostContainer describes a host image
for Bottlerocket
properties:
name:
description: Name is the host container name that will be
given to the container in BR's `apiserver`
type: string
source:
description: ImageMeta is the actual location of the container
image
properties:
imageRepository:
description: ImageRepository sets the container registry
to pull images from. if not set, the ImageRepository
defined in ClusterConfiguration will be used instead.
type: string
imageTag:
description: ImageTag allows to specify a tag for the
image. In case this value is set, kubeadm does not
change automatically the version of the above components
during upgrades.
type: string
type: object
superpowered:
description: Superpowered indicates if the container will
be superpowered
type: boolean
userData:
description: UserData is the userdata that will be attached
to the image.
type: string
required:
- name
- source
- superpowered
type: object
type: array
caCertPath:
description: 'CACertPath is the path to the SSL certificate authority
used to secure comunications between node and control-plane.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,49 @@ spec:
components during upgrades.
type: string
type: object
bottlerocketCustomHostContainers:
description: BottlerocketHostContainers contains the information
of any additional images that we will deploy as host
containers in the CPIs
items:
description: BottlerocketHostContainer describes a host
image for Bottlerocket
properties:
name:
description: Name is the host container name that
will be given to the container in BR's `apiserver`
type: string
source:
description: ImageMeta is the actual location of
the container image
properties:
imageRepository:
description: ImageRepository sets the container
registry to pull images from. if not set,
the ImageRepository defined in ClusterConfiguration
will be used instead.
type: string
imageTag:
description: ImageTag allows to specify a tag
for the image. In case this value is set,
kubeadm does not change automatically the
version of the above components during upgrades.
type: string
type: object
superpowered:
description: Superpowered indicates if the container
will be superpowered
type: boolean
userData:
description: UserData is the userdata that will
be attached to the image.
type: string
required:
- name
- source
- superpowered
type: object
type: array
certificatesDir:
description: 'CertificatesDir specifies where to store
or look for all required certificates. NB: if not provided,
Expand Down Expand Up @@ -3129,6 +3172,49 @@ spec:
components during upgrades.
type: string
type: object
bottlerocketCustomHostContainers:
description: BottlerocketCustomHostContainers contains
the information of any additional images that we will
deploy as host containers in the CPIs
items:
description: BottlerocketHostContainer describes a host
image for Bottlerocket
properties:
name:
description: Name is the host container name that
will be given to the container in BR's `apiserver`
type: string
source:
description: ImageMeta is the actual location of
the container image
properties:
imageRepository:
description: ImageRepository sets the container
registry to pull images from. if not set,
the ImageRepository defined in ClusterConfiguration
will be used instead.
type: string
imageTag:
description: ImageTag allows to specify a tag
for the image. In case this value is set,
kubeadm does not change automatically the
version of the above components during upgrades.
type: string
type: object
superpowered:
description: Superpowered indicates if the container
will be superpowered
type: boolean
userData:
description: UserData is the userdata that will
be attached to the image.
type: string
required:
- name
- source
- superpowered
type: object
type: array
caCertPath:
description: 'CACertPath is the path to the SSL certificate
authority used to secure comunications between node
Expand Down
Loading

0 comments on commit e8c7576

Please sign in to comment.