CI: Use Kubevirt VM to run Molecule and Vagrant jobs
Cherry-picked-by: Max Gautier <mg@max.gautier.name>pull/11516/head
parent
51db5924b1
commit
72a926a38b
|
@ -61,7 +61,7 @@ before_script:
|
||||||
script:
|
script:
|
||||||
- ./tests/scripts/testcases_run.sh
|
- ./tests/scripts/testcases_run.sh
|
||||||
after_script:
|
after_script:
|
||||||
- chronic ./tests/scripts/testcases_cleanup.sh
|
- ./tests/scripts/testcases_cleanup.sh
|
||||||
|
|
||||||
# For failfast, at least 1 job must be defined in .gitlab-ci.yml
|
# For failfast, at least 1 job must be defined in .gitlab-ci.yml
|
||||||
# Premoderated with manual actions
|
# Premoderated with manual actions
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
.molecule:
|
.molecule:
|
||||||
tags: [c3.small.x86]
|
tags: [ffci-vm-med]
|
||||||
only: [/^pr-.*$/]
|
only: [/^pr-.*$/]
|
||||||
except: ['triggers']
|
except: ['triggers']
|
||||||
image: $PIPELINE_IMAGE
|
image: quay.io/kubespray/vm-kubespray-ci:v6
|
||||||
services: []
|
services: []
|
||||||
stage: deploy-part1
|
stage: deploy-part1
|
||||||
|
variables:
|
||||||
|
VAGRANT_DEFAULT_PROVIDER: "libvirt"
|
||||||
before_script:
|
before_script:
|
||||||
- tests/scripts/rebase.sh
|
- groups
|
||||||
|
- python3 -m venv citest
|
||||||
|
- source citest/bin/activate
|
||||||
|
- vagrant plugin expunge --reinstall --force --no-tty
|
||||||
|
- vagrant plugin install vagrant-libvirt
|
||||||
|
- pip install --no-compile --no-cache-dir pip -U
|
||||||
|
- pip install --no-compile --no-cache-dir -r $CI_PROJECT_DIR/requirements.txt
|
||||||
|
- pip install --no-compile --no-cache-dir -r $CI_PROJECT_DIR/tests/requirements.txt
|
||||||
|
- ./tests/scripts/rebase.sh
|
||||||
- ./tests/scripts/vagrant_clean.sh
|
- ./tests/scripts/vagrant_clean.sh
|
||||||
script:
|
script:
|
||||||
- ./tests/scripts/molecule_run.sh
|
- ./tests/scripts/molecule_run.sh
|
||||||
after_script:
|
after_script:
|
||||||
- chronic ./tests/scripts/molecule_logs.sh
|
- ./tests/scripts/molecule_logs.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
when: always
|
when: always
|
||||||
paths:
|
paths:
|
||||||
|
@ -21,6 +30,7 @@
|
||||||
|
|
||||||
# CI template for periodic CI jobs
|
# CI template for periodic CI jobs
|
||||||
# Enabled when PERIODIC_CI_ENABLED var is set
|
# Enabled when PERIODIC_CI_ENABLED var is set
|
||||||
|
|
||||||
.molecule_periodic:
|
.molecule_periodic:
|
||||||
only:
|
only:
|
||||||
variables:
|
variables:
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
- tests/scripts/testcases_run.sh
|
- tests/scripts/testcases_run.sh
|
||||||
after_script:
|
after_script:
|
||||||
# Cleanup regardless of exit code
|
# Cleanup regardless of exit code
|
||||||
- chronic ./tests/scripts/testcases_cleanup.sh
|
- ./tests/scripts/testcases_cleanup.sh
|
||||||
|
|
||||||
tf-validate-openstack:
|
tf-validate-openstack:
|
||||||
extends: .terraform_validate
|
extends: .terraform_validate
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
.vagrant:
|
.vagrant:
|
||||||
extends: .testcases
|
extends: .testcases
|
||||||
variables:
|
variables:
|
||||||
|
@ -7,18 +6,25 @@
|
||||||
SSH_USER: "vagrant"
|
SSH_USER: "vagrant"
|
||||||
VAGRANT_DEFAULT_PROVIDER: "libvirt"
|
VAGRANT_DEFAULT_PROVIDER: "libvirt"
|
||||||
KUBESPRAY_VAGRANT_CONFIG: tests/files/${CI_JOB_NAME}.rb
|
KUBESPRAY_VAGRANT_CONFIG: tests/files/${CI_JOB_NAME}.rb
|
||||||
tags: [c3.small.x86]
|
DOCKER_NAME: vagrant
|
||||||
only: [/^pr-.*$/]
|
VAGRANT_ANSIBLE_TAGS: facts
|
||||||
except: ['triggers']
|
tags: [ffci-vm-large]
|
||||||
image: $PIPELINE_IMAGE
|
# only: [/^pr-.*$/]
|
||||||
|
# except: ['triggers']
|
||||||
|
image: quay.io/kubespray/vm-kubespray-ci:v6
|
||||||
services: []
|
services: []
|
||||||
before_script:
|
before_script:
|
||||||
|
- echo $USER
|
||||||
|
- python3 -m venv citest
|
||||||
|
- source citest/bin/activate
|
||||||
|
- vagrant plugin expunge --reinstall --force --no-tty
|
||||||
|
- vagrant plugin install vagrant-libvirt
|
||||||
|
- pip install --no-compile --no-cache-dir pip -U
|
||||||
|
- pip install --no-compile --no-cache-dir -r $CI_PROJECT_DIR/requirements.txt
|
||||||
|
- pip install --no-compile --no-cache-dir -r $CI_PROJECT_DIR/tests/requirements.txt
|
||||||
- ./tests/scripts/vagrant_clean.sh
|
- ./tests/scripts/vagrant_clean.sh
|
||||||
script:
|
script:
|
||||||
- ./tests/scripts/testcases_run.sh
|
- ./tests/scripts/testcases_run.sh
|
||||||
after_script:
|
|
||||||
- chronic ./tests/scripts/testcases_cleanup.sh
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
vagrant_ubuntu20-calico-dual-stack:
|
vagrant_ubuntu20-calico-dual-stack:
|
||||||
stage: deploy-part2
|
stage: deploy-part2
|
||||||
|
|
|
@ -255,7 +255,9 @@ Vagrant.configure("2") do |config|
|
||||||
"kubectl_localhost": "True",
|
"kubectl_localhost": "True",
|
||||||
"local_path_provisioner_enabled": "#{$local_path_provisioner_enabled}",
|
"local_path_provisioner_enabled": "#{$local_path_provisioner_enabled}",
|
||||||
"local_path_provisioner_claim_root": "#{$local_path_provisioner_claim_root}",
|
"local_path_provisioner_claim_root": "#{$local_path_provisioner_claim_root}",
|
||||||
"ansible_ssh_user": SUPPORTED_OS[$os][:user]
|
"ansible_ssh_user": SUPPORTED_OS[$os][:user],
|
||||||
|
"ansible_ssh_private_key_file": File.join(Dir.home, ".vagrant.d", "insecure_private_key"),
|
||||||
|
"unsafe_show_logs": "True"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Only execute the Ansible provisioner once, when all the machines are up and ready.
|
# Only execute the Ansible provisioner once, when all the machines are up and ready.
|
||||||
|
|
|
@ -4,7 +4,7 @@ FROM ubuntu:jammy-20230308
|
||||||
# Pip needs this as well at the moment to install ansible
|
# Pip needs this as well at the moment to install ansible
|
||||||
# (and potentially other packages)
|
# (and potentially other packages)
|
||||||
# See: https://github.com/pypa/pip/issues/10219
|
# See: https://github.com/pypa/pip/issues/10219
|
||||||
ENV VAGRANT_VERSION=2.3.7 \
|
ENV VAGRANT_VERSION=2.4.1 \
|
||||||
VAGRANT_DEFAULT_PROVIDER=libvirt \
|
VAGRANT_DEFAULT_PROVIDER=libvirt \
|
||||||
VAGRANT_ANSIBLE_TAGS=facts \
|
VAGRANT_ANSIBLE_TAGS=facts \
|
||||||
LANG=C.UTF-8 \
|
LANG=C.UTF-8 \
|
||||||
|
@ -31,6 +31,8 @@ RUN apt update -q \
|
||||||
unzip \
|
unzip \
|
||||||
libvirt-clients \
|
libvirt-clients \
|
||||||
qemu-utils \
|
qemu-utils \
|
||||||
|
qemu-kvm \
|
||||||
|
dnsmasq \
|
||||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
||||||
&& add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
&& add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||||
&& apt update -q \
|
&& apt update -q \
|
||||||
|
@ -45,6 +47,7 @@ RUN --mount=type=bind,target=./requirements.txt,src=./requirements.txt \
|
||||||
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
|
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
|
||||||
&& pip install --no-compile --no-cache-dir pip -U \
|
&& pip install --no-compile --no-cache-dir pip -U \
|
||||||
&& pip install --no-compile --no-cache-dir -r tests/requirements.txt \
|
&& pip install --no-compile --no-cache-dir -r tests/requirements.txt \
|
||||||
|
&& pip install --no-compile --no-cache-dir -r requirements.txt \
|
||||||
&& KUBE_VERSION=$(sed -n 's/^kube_version: //p' roles/kubespray-defaults/defaults/main/main.yml) \
|
&& KUBE_VERSION=$(sed -n 's/^kube_version: //p' roles/kubespray-defaults/defaults/main/main.yml) \
|
||||||
&& curl -L https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/$(dpkg --print-architecture)/kubectl -o /usr/local/bin/kubectl \
|
&& curl -L https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/$(dpkg --print-architecture)/kubectl -o /usr/local/bin/kubectl \
|
||||||
&& echo $(curl -L https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/$(dpkg --print-architecture)/kubectl.sha256) /usr/local/bin/kubectl | sha256sum --check \
|
&& echo $(curl -L https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/$(dpkg --print-architecture)/kubectl.sha256) /usr/local/bin/kubectl | sha256sum --check \
|
||||||
|
|
|
@ -83,8 +83,7 @@ cleanup-packet:
|
||||||
|
|
||||||
create-vagrant:
|
create-vagrant:
|
||||||
vagrant up
|
vagrant up
|
||||||
find / -name vagrant_ansible_inventory
|
cp $(CI_PROJECT_DIR)/inventory/sample/vagrant_ansible_inventory $(INVENTORY)
|
||||||
cp /builds/kargo-ci/kubernetes-sigs-kubespray/inventory/sample/vagrant_ansible_inventory $(INVENTORY)
|
|
||||||
|
|
||||||
delete-vagrant:
|
delete-vagrant:
|
||||||
vagrant destroy -f
|
vagrant destroy -f
|
||||||
|
|
|
@ -2,7 +2,6 @@ $os = "ubuntu2004"
|
||||||
|
|
||||||
# For CI we are not worries about data persistence across reboot
|
# For CI we are not worries about data persistence across reboot
|
||||||
$libvirt_volume_cache = "unsafe"
|
$libvirt_volume_cache = "unsafe"
|
||||||
|
|
||||||
# Checking for box update can trigger API rate limiting
|
# Checking for box update can trigger API rate limiting
|
||||||
# https://www.vagrantup.com/docs/vagrant-cloud/request-limits.html
|
# https://www.vagrantup.com/docs/vagrant-cloud/request-limits.html
|
||||||
$box_check_update = false
|
$box_check_update = false
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
---
|
---
|
||||||
# Kubespray settings
|
# Kubespray settings
|
||||||
kube_network_plugin: flannel
|
kube_network_plugin: flannel
|
||||||
|
ansible_ssh_private_key: .vagrant.d/insecure_private_key
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# install_vagrant() {
|
||||||
|
# sudo apt install vagrant-libvirt vagrant -y
|
||||||
|
# sudo vagrant plugin install vagrant-libvirt
|
||||||
|
# }
|
||||||
|
|
||||||
|
# prep(){
|
||||||
|
# sudo apt-get update -y
|
||||||
|
# sudo apt-get install ca-certificates curl libvirt-daemon-system\
|
||||||
|
# libvirt-clients qemu-utils qemu-kvm htop atop -y
|
||||||
|
|
||||||
|
# sudo install -m 0755 -d /etc/apt/keyrings
|
||||||
|
# }
|
||||||
|
# install_docker() {
|
||||||
|
# VERSION_STRING=5:26.1.0-1~ubuntu.24.04~noble
|
||||||
|
# sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
# sudo chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
# # Add the repository to Apt sources:
|
||||||
|
# echo \
|
||||||
|
# "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||||||
|
# $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||||
|
# sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
# sudo apt-get update -y
|
||||||
|
|
||||||
|
# sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
||||||
|
# }
|
||||||
|
# install_docker_auto () {
|
||||||
|
# curl -fsSL https://get.docker.com -o get-docker.sh
|
||||||
|
# sudo sh ./get-docker.sh --dry-run
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VAGRANT_VERSION=2.4.1
|
||||||
|
VAGRANT_DEFAULT_PROVIDER=libvirt
|
||||||
|
VAGRANT_ANSIBLE_TAGS=facts
|
||||||
|
LANG=C.UTF-8
|
||||||
|
DEBIAN_FRONTEND=noninteractive
|
||||||
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
|
KUBE_VERSION=1.29.5
|
||||||
|
pipeline_install() {
|
||||||
|
cp /etc/apt/sources.list /etc/apt/sources.list."$(date +"%F")"
|
||||||
|
sed -i -e '/^# deb-src.*universe$/s/# //g' /etc/apt/sources.list
|
||||||
|
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
|
||||||
|
|
||||||
|
apt update
|
||||||
|
# libssl-dev \
|
||||||
|
# python3-dev \
|
||||||
|
# # jq \
|
||||||
|
# moreutils \
|
||||||
|
# libvirt-dev \
|
||||||
|
# # rsync \
|
||||||
|
# git \
|
||||||
|
# # htop \
|
||||||
|
# gpg \
|
||||||
|
# atop
|
||||||
|
|
||||||
|
# gnupg2 \
|
||||||
|
# software-properties-common
|
||||||
|
#
|
||||||
|
apt install --no-install-recommends -y \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
python3-pip \
|
||||||
|
sshpass \
|
||||||
|
apt-transport-https \
|
||||||
|
openssh-client \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
libfuse2 \
|
||||||
|
unzip \
|
||||||
|
qemu-utils \
|
||||||
|
libvirt-daemon-system \
|
||||||
|
libvirt-clients \
|
||||||
|
qemu-kvm \
|
||||||
|
ebtables libguestfs-tools \
|
||||||
|
ruby-fog-libvirt \
|
||||||
|
libvirt-dev \
|
||||||
|
gcc \
|
||||||
|
build-essential \
|
||||||
|
ruby-libvirt \
|
||||||
|
libxslt-dev libxml2-dev zlib1g-dev \
|
||||||
|
python3-venv python3-full \
|
||||||
|
dnsmasq
|
||||||
|
|
||||||
|
apt-get build-dep -y ruby-libvirt ruby-dev
|
||||||
|
### VAGRANT ###
|
||||||
|
# apt-get install -y unzip
|
||||||
|
curl -LO https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_linux_amd64.zip
|
||||||
|
unzip vagrant_${VAGRANT_VERSION}_linux_amd64.zip
|
||||||
|
mv vagrant /usr/local/bin/vagrant
|
||||||
|
chmod a+x /usr/local/bin/vagrant
|
||||||
|
# ls -la /usr/local/bin/vagrant
|
||||||
|
/usr/local/bin/vagrant plugin install vagrant-libvirt
|
||||||
|
usermod -aG kvm kubespray
|
||||||
|
usermod -aG libvirt kubespray
|
||||||
|
|
||||||
|
### DOCKER ###
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
|
||||||
|
add-apt-repository -y "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||||
|
apt update
|
||||||
|
apt install --no-install-recommends -y docker-ce
|
||||||
|
apt autoremove -y --purge && apt clean && rm -rf /var/lib/apt/lists/* /var/log/*
|
||||||
|
|
||||||
|
### KUBECTL ###
|
||||||
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
|
mv kubectl /usr/local/bin/kubectl
|
||||||
|
chmod a+x /usr/local/bin/kubectl
|
||||||
|
systemctl restart libvirtd
|
||||||
|
# Install Vagrant
|
||||||
|
# apt update -y
|
||||||
|
# echo apt-get install -y unzip libfuse2 vagrant vagrant-libvirt
|
||||||
|
# apt --fix-broken install -y
|
||||||
|
# dpkg --configure -a -y
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
# wrapped up in a function so that we have some protection against only getting
|
||||||
|
# half the file during "curl | sh"
|
||||||
|
pipeline_install
|
Loading…
Reference in New Issue