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

Bootc provisioner #1247

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
867846a
chore: Vendoring commit
aerosouund Jul 16, 2024
ac74d17
feat: Create K8sClient
aerosouund Jul 16, 2024
707ffb6
feat: Introduce the CopyRemoteFile method and stdOut supression in th…
aerosouund Jul 16, 2024
8e93348
feat: Introduce the Opts package
aerosouund Jul 16, 2024
c53160b
refactor: Introduce the previously pure bash options to nodeconfig pa…
aerosouund Jul 17, 2024
f0b7cd4
refactor: Leverage Opts package in run.go and move pure bash flags to…
aerosouund Jul 17, 2024
81855b0
refactor: Delete duplicated bash code after moving it to opts
aerosouund Jul 17, 2024
7ba9dce
refactor: Remove bash methods from cluster up that have been moved to…
aerosouund Jul 17, 2024
12ebfef
test: Modify tests for provisionK8sOptions and provisionNode to use o…
aerosouund Jul 17, 2024
5837f51
feat: Provision & provision k8s opts
aerosouund Jul 23, 2024
c3b2011
feat/refactor: Introduce the KubevirtProvider type
aerosouund Jul 23, 2024
9c0afa6
refactor: Rewrite run.go to use the KubevirtProvider
aerosouund Jul 23, 2024
6ef20d4
refactor: Delete the nodesconfig package
aerosouund Jul 23, 2024
d68685c
testing: Move testing logic to the providers package
aerosouund Jul 23, 2024
13e9e94
refactor!: Move provision logic to the KubevirtProvider
aerosouund Jul 23, 2024
1f7cf9d
feat: Introduce retries in ssh connection in the ssh client
aerosouund Jul 23, 2024
9f34183
refactor: Delete provisioning bash code
aerosouund Jul 23, 2024
c69b93f
chore: Vendoring commit
aerosouund Jul 23, 2024
a80fcaa
feat: CRI Library
aerosouund Aug 12, 2024
b7615a7
feat: Bootc package
aerosouund Aug 12, 2024
b80ee38
fix: Use systemctl instead of service in rootkey to avoid cases where…
aerosouund Aug 14, 2024
3e6c67b
refactor: Configure k8s provisioning opt to not install any packages
aerosouund Aug 14, 2024
8804760
refactor!: Rewrite the Provision method of the KV provider to the use…
aerosouund Aug 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions cluster-provision/gocli/bootc/k8s-container/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[[customizations.user]]
name = "vagrant"
password = "vagrant"
key = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ=="
groups = ["wheel"]
32 changes: 32 additions & 0 deletions cluster-provision/gocli/bootc/k8s-container/k8s.Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM LINUX_BASE

ARG VERSION

RUN echo -e "[isv_kubernetes_addons_cri-o_stable_v1.28]\n\
name=CRI-O v1.28 (Stable) (rpm)\n\
type=rpm-md\n\
baseurl=https://storage.googleapis.com/kubevirtci-crio-mirror/isv_kubernetes_addons_cri-o_stable_v1.28\n\
gpgcheck=0\n\
enabled=1" > /etc/yum.repos.d/devel_kubic_libcontainers_stable_cri-o_v1.28.repo

RUN MAJOR_MINOR=$(echo $VERSION | awk -F. '{print $1"."$2}') && \
echo -e "[kubernetes]\n\
name=Kubernetes Release\n\
baseurl=https://pkgs.k8s.io/core:/stable:/v${MAJOR_MINOR}/rpm\n\
enabled=1\n\
gpgcheck=0\n\
repo_gpgcheck=0" > /etc/yum.repos.d/kubernetes.repo

RUN dnf install --nobest --nogpgcheck --disableexcludes=kubernetes -y \
kubectl-${VERSION} \
kubeadm-${VERSION} \
kubelet-${VERSION} \
kubernetes-cni


RUN dnf install -y cri-o patch

RUN mkdir -p /provision/kubeadm-patches

# COPY manifests /opt/
# COPY patches /provision/kubeadm-patches
47 changes: 47 additions & 0 deletions cluster-provision/gocli/bootc/k8s-container/linux.Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM quay.io/centos-bootc/centos-bootc:stream9

ENV KUBEVIRTCI_SHARED_DIR=/var/lib/kubevirtci
ENV ISTIO_VERSION=1.15.0
ENV ISTIO_BIN_DIR=/opt/istio-${ISTIO_VERSION}/bin

RUN dnf update -y

RUN mkdir -p /opt/scripts

COPY provision-system.sh /opt/scripts/provision-system.sh
RUN chmod 755 /opt/scripts/provision-system.sh
COPY provision-system.service /etc/systemd/system/provision-system.service

RUN echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

RUN mkdir -p $KUBEVIRTCI_SHARED_DIR \
&& echo '#!/bin/bash\n' \
'set -ex\n' \
'export KUBELET_CGROUP_ARGS="--cgroup-driver=systemd --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice"\n' \
'export ISTIO_VERSION=${ISTIO_VERSION}\n' \
'export ISTIO_BIN_DIR="/opt/istio-${ISTIO_VERSION}/bin"\n' \
> $KUBEVIRTCI_SHARED_DIR/shared_vars.sh \
&& chmod +x $KUBEVIRTCI_SHARED_DIR/shared_vars.sh

RUN dnf install -y "kernel-modules-5.14.0-480.el9.x86_64" \
&& dnf install -y patch \
&& dnf install -y pciutils \
&& systemctl enable provision-system.service \
&& dnf -y remove firewalld \
&& dnf -y install iscsi-initiator-utils \
&& dnf -y install nftables \
&& dnf -y install lvm2 \
&& echo 'ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="vd[a-z]", ATTR{queue/rotational}="0"' > /etc/udev/rules.d/60-force-ssd-rotational.rules \
&& dnf install -y iproute-tc \
&& mkdir -p "$ISTIO_BIN_DIR" \
&& curl "https://storage.googleapis.com/kubevirtci-istioctl-mirror/istio-${ISTIO_VERSION}/bin/istioctl" -o "$ISTIO_BIN_DIR/istioctl" \
&& chmod +x "$ISTIO_BIN_DIR/istioctl" \
&& dnf install -y container-selinux \
&& dnf install -y libseccomp-devel \
&& dnf install -y centos-release-nfv-openvswitch \
&& dnf install -y openvswitch2.16 \
&& dnf install -y --skip-broken NetworkManager NetworkManager-ovs NetworkManager-config-server \
&& dnf clean all \
&& rm -rf /lib/systemd/system/[email protected]

ENV PATH="$ISTIO_BIN_DIR:$PATH"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec:
template:
spec:
securityContext:
seLinuxOptions:
type: spc_t
4 changes: 4 additions & 0 deletions cluster-provision/gocli/bootc/k8s-container/patches/etcd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spec:
securityContext:
seLinuxOptions:
type: spc_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spec:
securityContext:
seLinuxOptions:
type: spc_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spec:
securityContext:
seLinuxOptions:
type: spc_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spec:
securityContext:
seLinuxOptions:
type: spc_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=KubevirtCI System Setup
After=NetworkManager-wait-online.service
Requires=NetworkManager-wait-online.service

[Service]
ExecStart=/opt/scripts/provision-system.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
nmcli connection add type ethernet ifname enp0s2 con-name enp0s2 ipv4.method auto ipv6.method auto
nmcli connection modify enp0s2 connection.autoconnect yes
nmcli connection up enp0s2
sudo ostree admin unlock --hotfix
sudo mkdir -p /var/opt_writable
sudo cp -r /opt/* /var/opt_writable
sudo mount --bind /var/opt_writable /opt
134 changes: 134 additions & 0 deletions cluster-provision/gocli/bootc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package bootc

import (
"embed"
"strings"

"os"

"kubevirt.io/kubevirtci/cluster-provision/gocli/cri"
)

//go:embed k8s-container/k8s.Containerfile
var k8sContainerfile []byte

//go:embed k8s-container/linux.Containerfile
var linuxContainerfile []byte

//go:embed k8s-container/provision-system.sh
var provisionSystem []byte

//go:embed k8s-container/provision-system.service
var provisionSystemService []byte

//go:embed k8s-container/config.toml
var configToml []byte

//go:embed k8s-container/patches/*
var patches embed.FS

type BootcProvisioner struct {
cri cri.ContainerClient
}

func NewBootcProvisioner(cri cri.ContainerClient) *BootcProvisioner {
return &BootcProvisioner{
cri: cri,
}
}

func (b *BootcProvisioner) BuildLinuxBase(tag string) error {
fileName := "provision-system.sh"
containerFile, err := os.Create(fileName)
if err != nil {
return err
}
_, err = containerFile.Write(provisionSystem)
if err != nil {
return err
}

fileName = "provision-system.service"
containerFile, err = os.Create(fileName)
if err != nil {
return err
}
_, err = containerFile.Write(provisionSystemService)
if err != nil {
return err
}

fileName = "linux.Containerfile"
containerFile, err = os.Create(fileName)
if err != nil {
return err
}
_, err = containerFile.Write(linuxContainerfile)
if err != nil {
return err
}

err = b.cri.Build(tag, fileName, map[string]string{})
if err != nil {
return err
}
return nil
}

func (b *BootcProvisioner) BuildK8sBase(tag, k8sVersion, baseImage string) error {
fileName := "k8s.Containerfile"
fileWithBase := strings.Replace(string(k8sContainerfile), "LINUX_BASE", baseImage, 1)

containerFile, err := os.Create(fileName)
if err != nil {
return err
}
_, err = containerFile.Write([]byte(fileWithBase))
if err != nil {
return err
}
_ = os.Mkdir("patches", 0777)

err = b.cri.Build(tag, fileName, map[string]string{"VERSION": k8sVersion})
if err != nil {
return err
}
return nil
}

func (b *BootcProvisioner) GenerateQcow(image string) error {
_ = os.Mkdir("output", 0777)

configFileName := "config.toml"
conf, err := os.Create(configFileName)
if err != nil {
return err
}
_, err = conf.Write(configToml)
if err != nil {
return err
}

runArgs := []string{"--rm",
"--privileged",
"--security-opt",
"label=type:unconfined_t",
"-v",
"./output:/output",
"-v",
"/var/lib/containers/storage:/var/lib/containers/storage",
"-v",
"./config.toml:/config.toml:ro",
"quay.io/centos-bootc/bootc-image-builder:latest",
"--type",
"qcow2",
"--local",
"localhost/" + image}

err = b.cri.Run(runArgs)
if err != nil {
return err
}

return nil
}
54 changes: 0 additions & 54 deletions cluster-provision/gocli/cmd/nodesconfig/nodeconfig.go

This file was deleted.

Loading