Skip to content

Commit

Permalink
Support for specifying the CNI plugin version (#13)
Browse files Browse the repository at this point in the history
Required to build newer versions of Kubernetes whose packages have a
dependency on a newer version of the CNI plugins package.
  • Loading branch information
yankcrime committed Jan 24, 2023
1 parent 26f500f commit 219118a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Baskio - Build And Scan Kubernetes Images Openstack
# Baskio - Build And Scan Kubernetes Images OpenStack

A binary for building and scanning (with [Trivy](https://github.com/aquasecurity/trivy)) a Kubernetes image using
the [eschercloud-image-builder](https://github.com/eschercloudai/image-builder) repo.
Expand Down Expand Up @@ -33,7 +33,7 @@ openstack security group rule create "${OS_SG}" --egress --ethertype IPv4 --prot
# Usage
Simply run the binary with the following flags (minimum required). See the example below.
You will also require a source image to reference for the build to succeed.
You must supply a clouds.yaml file for Openstack connectivity.
You must supply a clouds.yaml file for OpenStack connectivity.

```yaml
clouds-file: "~/.config/openstack/clouds.yaml"
Expand All @@ -49,6 +49,7 @@ build:
floating-ip-network-name: "Internet"
image-visibility: "private"
crictl-version: "1.25.0"
cni-version: "1.1.1"
kubernetes-version: "1.25.3"
extra-debs: "nfs-common"
enable-nvidia-support: false
Expand Down
2 changes: 2 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ To use baskio to build an image, an Openstack cluster is required.`,
cmd.Flags().BoolVar(&userFloatingIPFlag, "use-floating-ip", true, "Whether to use a floating IP for the instance")
cmd.Flags().StringVar(&floatingIPNetworkNameFlag, "floating-ip-network-name", "Internet", "The Name of the network in which to create the floating ip")
cmd.Flags().StringVar(&imageVisibilityFlag, "image-visibility", "private", "Change the image visibility in Openstack - you need to ensure the use you're authenticating with has permissions to do so or this will fail")
cmd.Flags().StringVar(&cniVersionFlag, "cni-version", "1.1.1", "The CNI plugins version to include to the built image")
cmd.Flags().StringVar(&crictlVersionFlag, "crictl-version", "1.25.0", "The crictl-tools version to add to the built image")
cmd.Flags().StringVar(&kubeVersionFlag, "kubernetes-version", "1.25.3", "The Kubernetes version to add to the built image")
cmd.Flags().StringVar(&extraDebsFlag, "extra-debs", "", "A space-seperated list of any extra (Debian / Ubuntu) packages that should be installed")
Expand All @@ -112,6 +113,7 @@ To use baskio to build an image, an Openstack cluster is required.`,
bindViper(cmd, "build.use-floating-ip", "use-floating-ip")
bindViper(cmd, "build.floating-ip-network-name", "floating-ip-network-name")
bindViper(cmd, "build.image-visibility", "image-visibility")
bindViper(cmd, "build.cni-version", "cni-version")
bindViper(cmd, "build.crictl-version", "crictl-version")
bindViper(cmd, "build.kubernetes-version", "kubernetes-version")
bindViper(cmd, "build.extra-debs", "extra-debs")
Expand Down
1 change: 1 addition & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
floatingIPNetworkNameFlag string
attachConfigDriveFlag bool
imageVisibilityFlag string
cniVersionFlag string
crictlVersionFlag string
kubeVersionFlag string
extraDebsFlag string
Expand Down
4 changes: 4 additions & 0 deletions pkg/openstack/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type PackerBuildConfig struct {
AttachConfigDrive string `json:"attach_config_drive,omitempty"`
UseFloatingIp string `json:"use_floating_ip,omitempty"`
FloatingIpNetwork string `json:"floating_ip_network,omitempty"`
CniVersion string `json:"kubernetes_cni_semver,omitempty"`
CniDebVersion string `json:"kubernetes_cni_deb_version,omitempty"`
CrictlVersion string `json:"crictl_version,omitempty"`
ImageVisibility string `json:"image_visibility,omitempty"`
KubernetesSemver string `json:"kubernetes_semver,omitempty"`
Expand Down Expand Up @@ -129,6 +131,8 @@ func buildConfigFromInputs() *PackerBuildConfig {
AttachConfigDrive: strconv.FormatBool(viper.GetBool("build.attach-config-drive")),
UseFloatingIp: strconv.FormatBool(viper.GetBool("build.use-floating-ip")),
FloatingIpNetwork: viper.GetString("build.floating-ip-network-name"),
CniVersion: "v" + viper.GetString("build.cni-version"),
CniDebVersion: viper.GetString("build.cni-version") + "-00",
CrictlVersion: viper.GetString("build.crictl-version"),
ImageVisibility: viper.GetString("build.image-visibility"),
KubernetesSemver: "v" + viper.GetString("build.kubernetes-version"),
Expand Down

0 comments on commit 219118a

Please sign in to comment.