Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ae9ee82f0 | |||
| 5380f93b64 | |||
| a414453ad4 | |||
| 23c5d9ec89 | |||
| 6b339e1985 | |||
| a031807660 | |||
| 7dd305aabc | |||
| 500931e2fd | |||
| cf357cf164 | |||
| 215e0d10ed | |||
| c6ed680dc1 | |||
| 8343a6199e | |||
| b524f97552 | |||
| f741040e44 | |||
| 09bc628ba6 | |||
| 71ff6b86cd | |||
| 23729ddbbe | |||
| e254c407f0 | |||
| 713b4694e1 | |||
| 952d513124 | |||
| dd1e596332 | |||
| 6af47f96d0 | |||
| 664deec6c3 | |||
| 646459e7f5 | |||
| 64242d9729 | |||
| f4864ddb64 | |||
| 6a83cde0c6 | |||
| 77ac928c0d | |||
| 8300a7aaac | |||
| bdc6af5f46 | |||
| dc8276157a | |||
| 37f0cb11d2 | |||
| 68e7c77b22 | |||
| d82c4feac8 | |||
| 9217d8607b | |||
| fbc15aa1a1 | |||
| b55ec046ad | |||
| b3cc178045 | |||
| 13be424187 | |||
| d9cecd5364 | |||
| afb96dbee2 | |||
| 30ffc69192 | |||
| 94e385c28e | |||
| dbb2cda17a | |||
| d24cdb97db | |||
| 5bebec930b | |||
| ac52acdec1 | |||
| 105b2c2f1e | |||
| d20f485fca | |||
| f9bb9dabae | |||
| 6f15ef260e | |||
| de1966fe02 | |||
| fc823122d8 | |||
| 2f8d94bb5e | |||
| 5268ef305a | |||
| a840571733 | |||
| 9c3814ce72 | |||
| 0e60f4643b | |||
| bb20514a6a | |||
| b1370406ea | |||
| 12d57a07d0 | |||
| 4f3b8ec9e0 | |||
| 45ddd65e74 | |||
| b2a62ea4eb | |||
| a8697edc99 | |||
| d3218f5d5c | |||
| 590a8029fd | |||
| cb2fa7c441 | |||
| 14508ec8dc | |||
| fb6c9a6866 | |||
| d5d02280c1 | |||
| 57e528832b | |||
| cd76fa05a7 | |||
| d5b37acd8a | |||
| 5225493ca0 | |||
| 4acbe91b6c | |||
| f1c2f3b7dd | |||
| 76718a010c |
@@ -12,3 +12,4 @@
|
|||||||
- [ ] Ran `reset.yml` playbook
|
- [ ] Ran `reset.yml` playbook
|
||||||
- [ ] Did not add any unnecessary changes
|
- [ ] Did not add any unnecessary changes
|
||||||
- [ ] 🚀
|
- [ ] 🚀
|
||||||
|
- [ ] Ran pre-commit install at least once before committing
|
||||||
|
|||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# download-boxes.sh
|
||||||
|
# Check all molecule.yml files for required Vagrant boxes and download the ones that are not
|
||||||
|
# already present on the system.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
YQ_VERSION=v4.29.2
|
||||||
|
YQ_BINARY=yq_linux_amd64
|
||||||
|
GIT_ROOT=$(git rev-parse --show-toplevel)
|
||||||
|
PROVIDER=virtualbox
|
||||||
|
|
||||||
|
# get yq used for filtering
|
||||||
|
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY} -O /usr/bin/yq &&\
|
||||||
|
sudo chmod +x /usr/bin/yq
|
||||||
|
|
||||||
|
# Read all boxes for all platforms from the "molecule.yml" files
|
||||||
|
all_boxes=$(cat "${GIT_ROOT}"/molecule/*/molecule.yml |
|
||||||
|
yq -r '.platforms[].box' | # Read the "box" property of each node under "platforms"
|
||||||
|
grep --invert-match --regexp=--- | # Filter out file separators
|
||||||
|
sort |
|
||||||
|
uniq)
|
||||||
|
|
||||||
|
# Read the boxes that are currently present on the system (for the current provider)
|
||||||
|
present_boxes=$(
|
||||||
|
(vagrant box list |
|
||||||
|
grep "${PROVIDER}" | # Filter by boxes available for the current provider
|
||||||
|
awk '{print $1;}' | # The box name is the first word in each line
|
||||||
|
sort |
|
||||||
|
uniq) ||
|
||||||
|
echo "" # In case any of these commands fails, just use an empty list
|
||||||
|
)
|
||||||
|
|
||||||
|
# The boxes that we need to download are the ones present in $all_boxes, but not $present_boxes.
|
||||||
|
download_boxes=$(comm -2 -3 <(echo "${all_boxes}") <(echo "${present_boxes}"))
|
||||||
|
|
||||||
|
# Actually download the necessary boxes
|
||||||
|
if [ -n "${download_boxes}" ]; then
|
||||||
|
echo "${download_boxes}" | while IFS= read -r box; do
|
||||||
|
vagrant box add --provider "${PROVIDER}" "${box}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
+57
-14
@@ -5,26 +5,69 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- '**/README.md'
|
||||||
jobs:
|
jobs:
|
||||||
ansible-lint:
|
pre-commit-ci:
|
||||||
name: YAML Lint + Ansible Lint
|
name: Pre-Commit
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.10"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the codebase
|
- name: Check out the codebase
|
||||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
|
||||||
|
|
||||||
- name: Set up Python 3.x
|
|
||||||
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 #4.0.2
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Install test dependencies
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||||
run: pip3 install yamllint ansible-lint ansible
|
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # 4.3.0
|
||||||
|
with:
|
||||||
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
cache: 'pip' # caching pip dependencies
|
||||||
|
|
||||||
- name: Run yamllint
|
- name: Cache pip
|
||||||
run: yamllint .
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Run ansible-lint
|
- name: Cache Ansible
|
||||||
run: ansible-lint
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
|
||||||
|
with:
|
||||||
|
path: ~/.ansible/collections
|
||||||
|
key: ${{ runner.os }}-ansible-${{ hashFiles('collections/requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-ansible-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "::group::Upgrade pip"
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
echo "::group::Install Python requirements from requirements.txt"
|
||||||
|
python3 -m pip install -r requirements.txt
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
echo "::group::Install Ansible role requirements from collections/requirements.yml"
|
||||||
|
ansible-galaxy install -r collections/requirements.yml
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Run pre-commit
|
||||||
|
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # 3.0.0
|
||||||
|
|
||||||
|
ensure-pinned-actions:
|
||||||
|
name: Ensure SHA Pinned Actions
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
|
||||||
|
- name: Ensure SHA pinned actions
|
||||||
|
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@6ca5574367befbc9efdb2fa25978084159c5902d # 1.3.0
|
||||||
|
with:
|
||||||
|
allowlist: |
|
||||||
|
aws-actions/
|
||||||
|
docker/login-action
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- '**/README.md'
|
||||||
jobs:
|
jobs:
|
||||||
molecule:
|
molecule:
|
||||||
name: Molecule
|
name: Molecule
|
||||||
runs-on: macos-12
|
runs-on: self-hosted
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -20,10 +21,39 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
env:
|
env:
|
||||||
PYTHON_VERSION: "3.10"
|
PYTHON_VERSION: "3.10"
|
||||||
|
VAGRANT_DEFAULT_PROVIDER: virtualbox
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the codebase
|
- name: Check out the codebase
|
||||||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # 3.0.2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
|
- name: Install Virtual Box from Oracle
|
||||||
|
run: |
|
||||||
|
echo "::group::Virtual Box"
|
||||||
|
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg
|
||||||
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee -a /etc/apt/sources.list.d/virtualbox.list
|
||||||
|
sudo apt update && sudo apt install -y linux-headers-generic linux-headers-5.15.0-52-generic build-essential dkms virtualbox-dkms virtualbox-6.1
|
||||||
|
echo "::endgroup::"
|
||||||
|
echo "::group::Virtual Box Test"
|
||||||
|
vboxmanage --version
|
||||||
|
sudo /sbin/vboxconfig
|
||||||
|
sudo modprobe vboxdrv
|
||||||
|
vboxmanage --version
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Install Vagrant
|
||||||
|
run: |
|
||||||
|
echo "::group::Install Vagrant"
|
||||||
|
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
||||||
|
sudo apt update && sudo apt install -y vagrant
|
||||||
|
vagrant version
|
||||||
|
vagrant plugin list
|
||||||
|
vagrant plugin install vagrant-vbguest
|
||||||
|
vagrant plugin list
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Configure VirtualBox
|
- name: Configure VirtualBox
|
||||||
run: |-
|
run: |-
|
||||||
@@ -33,8 +63,16 @@ jobs:
|
|||||||
* fdad:bad:ba55::/64
|
* fdad:bad:ba55::/64
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
- name: Cache pip
|
||||||
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('./requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Cache Vagrant boxes
|
- name: Cache Vagrant boxes
|
||||||
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # 3.0.8
|
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # 3.0.11
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.vagrant.d/boxes
|
~/.vagrant.d/boxes
|
||||||
@@ -42,15 +80,27 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
vagrant-boxes
|
vagrant-boxes
|
||||||
|
|
||||||
|
- name: Download Vagrant boxes for all scenarios
|
||||||
|
# To save some cache space, all scenarios share the same cache key.
|
||||||
|
# On the other hand, this means that the cache contents should be
|
||||||
|
# the same across all scenarios. This step ensures that.
|
||||||
|
run: ./.github/download-boxes.sh
|
||||||
|
|
||||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 # 4.3.0
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
cache: 'pip' # caching pip dependencies
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: >-
|
run: |
|
||||||
python3 -m pip install --upgrade pip &&
|
echo "::group::Upgrade pip"
|
||||||
|
python3 -m pip install --upgrade pip
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
echo "::group::Install Python requirements from requirements.txt"
|
||||||
python3 -m pip install -r requirements.txt
|
python3 -m pip install -r requirements.txt
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Test with molecule
|
- name: Test with molecule
|
||||||
run: molecule test --scenario-name ${{ matrix.scenario }}
|
run: molecule test --scenario-name ${{ matrix.scenario }}
|
||||||
@@ -58,10 +108,12 @@ jobs:
|
|||||||
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
|
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
|
||||||
ANSIBLE_SSH_RETRIES: 4
|
ANSIBLE_SSH_RETRIES: 4
|
||||||
ANSIBLE_TIMEOUT: 60
|
ANSIBLE_TIMEOUT: 60
|
||||||
|
PY_COLORS: 1
|
||||||
|
ANSIBLE_FORCE_COLOR: 1
|
||||||
|
|
||||||
- name: Upload log files
|
- name: Upload log files
|
||||||
if: always() # do this even if a step before has failed
|
if: always() # do this even if a step before has failed
|
||||||
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # 3.1.0
|
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # 3.1.1
|
||||||
with:
|
with:
|
||||||
name: logs
|
name: logs
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.3.0
|
||||||
|
hooks:
|
||||||
|
- id: requirements-txt-fixer
|
||||||
|
- id: sort-simple-yaml
|
||||||
|
- id: detect-private-key
|
||||||
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
|
rev: v1.28.0
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
args: [-c=.yamllint]
|
||||||
|
- repo: https://github.com/ansible-community/ansible-lint.git
|
||||||
|
rev: v6.8.2
|
||||||
|
hooks:
|
||||||
|
- id: ansible-lint
|
||||||
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
|
rev: v0.8.0.4
|
||||||
|
hooks:
|
||||||
|
- id: shellcheck
|
||||||
@@ -16,9 +16,9 @@ If you want more context on how this works, see:
|
|||||||
|
|
||||||
Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a HA Kubernetes cluster on machines running:
|
Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a HA Kubernetes cluster on machines running:
|
||||||
|
|
||||||
- [X] Debian
|
- [x] Debian (tested on version 11)
|
||||||
- [X] Ubuntu
|
- [x] Ubuntu (tested on version 22.04)
|
||||||
- [X] CentOS
|
- [x] Rocky (tested on version 9)
|
||||||
|
|
||||||
on processor architecture:
|
on processor architecture:
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ on processor architecture:
|
|||||||
|
|
||||||
- `server` and `agent` nodes should have passwordless SSH access, if not you can supply arguments to provide credentials `--ask-pass --ask-become-pass` to each command.
|
- `server` and `agent` nodes should have passwordless SSH access, if not you can supply arguments to provide credentials `--ask-pass --ask-become-pass` to each command.
|
||||||
|
|
||||||
- You will also need to install collections that this playbook uses by running `ansible-galaxy install -r ./collections/requirements.yml`
|
- You will also need to install collections that this playbook uses by running `ansible-galaxy collection install -r ./collections/requirements.yml`
|
||||||
|
|
||||||
## 🚀 Getting Started
|
## 🚀 Getting Started
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
k3s_version: v1.24.4+k3s1
|
k3s_version: v1.24.6+k3s1
|
||||||
# this is the user that has ssh access to these machines
|
# this is the user that has ssh access to these machines
|
||||||
ansible_user: ansibleuser
|
ansible_user: ansibleuser
|
||||||
systemd_dir: /etc/systemd/system
|
systemd_dir: /etc/systemd/system
|
||||||
@@ -22,25 +22,30 @@ k3s_token: "some-SUPER-DEDEUPER-secret-password"
|
|||||||
# it for each of your hosts, though.
|
# it for each of your hosts, though.
|
||||||
k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}'
|
k3s_node_ip: '{{ ansible_facts[flannel_iface]["ipv4"]["address"] }}'
|
||||||
|
|
||||||
|
# Disable the taint manually by setting: k3s_master_taint = false
|
||||||
|
k3s_master_taint: "{{ true if groups['node'] | default([]) | length >= 1 else false }}"
|
||||||
|
|
||||||
# these arguments are recommended for servers as well as agents:
|
# these arguments are recommended for servers as well as agents:
|
||||||
extra_args: >-
|
extra_args: >-
|
||||||
--flannel-iface={{ flannel_iface }}
|
--flannel-iface={{ flannel_iface }}
|
||||||
--node-ip={{ k3s_node_ip }}
|
--node-ip={{ k3s_node_ip }}
|
||||||
|
|
||||||
# change these to your liking, the only required one is --disable servicelb
|
# change these to your liking, the only required are: --disable servicelb, --tls-san {{ apiserver_endpoint }}
|
||||||
extra_server_args: >-
|
extra_server_args: >-
|
||||||
{{ extra_args }}
|
{{ extra_args }}
|
||||||
|
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
|
||||||
|
--tls-san {{ apiserver_endpoint }}
|
||||||
--disable servicelb
|
--disable servicelb
|
||||||
--disable traefik
|
--disable traefik
|
||||||
extra_agent_args: >-
|
extra_agent_args: >-
|
||||||
{{ extra_args }}
|
{{ extra_args }}
|
||||||
|
|
||||||
# image tag for kube-vip
|
# image tag for kube-vip
|
||||||
kube_vip_tag_version: "v0.5.0"
|
kube_vip_tag_version: "v0.5.5"
|
||||||
|
|
||||||
# image tag for metal lb
|
# image tag for metal lb
|
||||||
metal_lb_speaker_tag_version: "v0.13.5"
|
metal_lb_speaker_tag_version: "v0.13.6"
|
||||||
metal_lb_controller_tag_version: "v0.13.5"
|
metal_lb_controller_tag_version: "v0.13.6"
|
||||||
|
|
||||||
# metallb ip range for load balancer
|
# metallb ip range for load balancer
|
||||||
metal_lb_ip_range: "192.168.30.80-192.168.30.90"
|
metal_lb_ip_range: "192.168.30.80-192.168.30.90"
|
||||||
|
|||||||
@@ -3,43 +3,52 @@ dependency:
|
|||||||
name: galaxy
|
name: galaxy
|
||||||
driver:
|
driver:
|
||||||
name: vagrant
|
name: vagrant
|
||||||
platforms:
|
.platform_presets:
|
||||||
- &control
|
- &control
|
||||||
name: control1
|
|
||||||
box: generic/ubuntu2204
|
|
||||||
memory: 2048
|
memory: 2048
|
||||||
cpus: 2
|
cpus: 2
|
||||||
|
groups:
|
||||||
|
- k3s_cluster
|
||||||
|
- master
|
||||||
|
- &node
|
||||||
|
memory: 2048
|
||||||
|
cpus: 2
|
||||||
|
groups:
|
||||||
|
- k3s_cluster
|
||||||
|
- node
|
||||||
|
- &debian
|
||||||
|
box: generic/debian11
|
||||||
|
- &rocky
|
||||||
|
box: generic/rocky9
|
||||||
|
- &ubuntu
|
||||||
|
box: generic/ubuntu2204
|
||||||
config_options:
|
config_options:
|
||||||
# We currently can not use public-key based authentication on Ubuntu 22.04,
|
# We currently can not use public-key based authentication on Ubuntu 22.04,
|
||||||
# see: https://github.com/chef/bento/issues/1405
|
# see: https://github.com/chef/bento/issues/1405
|
||||||
ssh.username: "vagrant"
|
ssh.username: "vagrant"
|
||||||
ssh.password: "vagrant"
|
ssh.password: "vagrant"
|
||||||
groups:
|
platforms:
|
||||||
- k3s_cluster
|
- <<: [*control, *ubuntu]
|
||||||
- master
|
name: control1
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: 192.168.30.38
|
ip: 192.168.30.38
|
||||||
- <<: *control
|
- <<: [*control, *debian]
|
||||||
name: control2
|
name: control2
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: 192.168.30.39
|
ip: 192.168.30.39
|
||||||
- <<: *control
|
- <<: [*control, *rocky]
|
||||||
name: control3
|
name: control3
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: 192.168.30.40
|
ip: 192.168.30.40
|
||||||
- &node
|
- <<: [*node, *ubuntu]
|
||||||
<<: *control
|
|
||||||
name: node1
|
name: node1
|
||||||
groups:
|
|
||||||
- k3s_cluster
|
|
||||||
- node
|
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: 192.168.30.41
|
ip: 192.168.30.41
|
||||||
- <<: *node
|
- <<: [*node, *rocky]
|
||||||
name: node2
|
name: node2
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- name: Apply overrides
|
||||||
|
ansible.builtin.import_playbook: >-
|
||||||
|
{{ lookup("ansible.builtin.env", "MOLECULE_SCENARIO_DIRECTORY") }}/overrides.yml
|
||||||
|
|
||||||
|
- name: Network setup
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Disable firewalld
|
||||||
|
when: ansible_distribution == "Rocky"
|
||||||
|
# Rocky Linux comes with firewalld enabled. It blocks some of the network
|
||||||
|
# connections needed for our k3s cluster. For our test setup, we just disable
|
||||||
|
# it since the VM host's firewall is still active for connections to and from
|
||||||
|
# the Internet.
|
||||||
|
# When building your own cluster, please DO NOT blindly copy this. Instead,
|
||||||
|
# please create a custom firewall configuration that fits your network design
|
||||||
|
# and security needs.
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: firewalld
|
||||||
|
enabled: no
|
||||||
|
state: stopped
|
||||||
|
become: true
|
||||||
+16
-10
@@ -3,28 +3,34 @@ dependency:
|
|||||||
name: galaxy
|
name: galaxy
|
||||||
driver:
|
driver:
|
||||||
name: vagrant
|
name: vagrant
|
||||||
platforms:
|
.platform_presets:
|
||||||
- &control
|
- &control
|
||||||
name: control1
|
|
||||||
box: generic/ubuntu2204
|
|
||||||
memory: 2048
|
memory: 2048
|
||||||
cpus: 2
|
cpus: 2
|
||||||
|
groups:
|
||||||
|
- k3s_cluster
|
||||||
|
- master
|
||||||
|
- &node
|
||||||
|
memory: 2048
|
||||||
|
cpus: 2
|
||||||
|
groups:
|
||||||
|
- k3s_cluster
|
||||||
|
- node
|
||||||
|
- &ubuntu
|
||||||
|
box: generic/ubuntu2204
|
||||||
config_options:
|
config_options:
|
||||||
# We currently can not use public-key based authentication on Ubuntu 22.04,
|
# We currently can not use public-key based authentication on Ubuntu 22.04,
|
||||||
# see: https://github.com/chef/bento/issues/1405
|
# see: https://github.com/chef/bento/issues/1405
|
||||||
ssh.username: "vagrant"
|
ssh.username: "vagrant"
|
||||||
ssh.password: "vagrant"
|
ssh.password: "vagrant"
|
||||||
groups:
|
platforms:
|
||||||
- k3s_cluster
|
- <<: [*control, *ubuntu]
|
||||||
- master
|
name: control1
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: fdad:bad:ba55::de:11
|
ip: fdad:bad:ba55::de:11
|
||||||
- <<: *control
|
- <<: [*node, *ubuntu]
|
||||||
name: node1
|
name: node1
|
||||||
groups:
|
|
||||||
- k3s_cluster
|
|
||||||
- node
|
|
||||||
interfaces:
|
interfaces:
|
||||||
- network_name: private_network
|
- network_name: private_network
|
||||||
ip: fdad:bad:ba55::de:21
|
ip: fdad:bad:ba55::de:21
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
# the default has IPv4 ranges only.
|
# the default has IPv4 ranges only.
|
||||||
extra_server_args: >-
|
extra_server_args: >-
|
||||||
{{ extra_args }}
|
{{ extra_args }}
|
||||||
|
--tls-san {{ apiserver_endpoint }}
|
||||||
|
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
|
||||||
--disable servicelb
|
--disable servicelb
|
||||||
--disable traefik
|
--disable traefik
|
||||||
--disable-network-policy
|
--disable-network-policy
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
run_once: true
|
run_once: true
|
||||||
delegate_to: "{{ outside_host }}"
|
delegate_to: "{{ outside_host }}"
|
||||||
block:
|
block:
|
||||||
- ansible.builtin.import_tasks: kubecfg-fetch.yml
|
- name: "Test CASE: Get kube config"
|
||||||
|
ansible.builtin.import_tasks: kubecfg-fetch.yml
|
||||||
- name: "TEST CASE: Get nodes"
|
- name: "TEST CASE: Get nodes"
|
||||||
ansible.builtin.include_tasks: test/get-nodes.yml
|
ansible.builtin.include_tasks: test/get-nodes.yml
|
||||||
- name: "TEST CASE: Deploy example"
|
- name: "TEST CASE: Deploy example"
|
||||||
ansible.builtin.include_tasks: test/deploy-example.yml
|
ansible.builtin.include_tasks: test/deploy-example.yml
|
||||||
always:
|
always:
|
||||||
- ansible.builtin.import_tasks: kubecfg-cleanup.yml
|
- name: "TEST CASE: Cleanup"
|
||||||
|
ansible.builtin.import_tasks: kubecfg-cleanup.yml
|
||||||
|
|||||||
@@ -43,6 +43,10 @@
|
|||||||
{{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }}
|
{{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }}
|
||||||
port: >-
|
port: >-
|
||||||
{{ nginx_services.resources[0].spec.ports[0].port }}
|
{{ nginx_services.resources[0].spec.ports[0].port }}
|
||||||
|
# Deactivated linter rules:
|
||||||
|
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
|
||||||
|
# would be undefined. This will not be the case during playbook execution.
|
||||||
|
# noqa jinja[invalid]
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: "Remove namespace: {{ testing_namespace }}"
|
- name: "Remove namespace: {{ testing_namespace }}"
|
||||||
|
|||||||
@@ -22,3 +22,7 @@
|
|||||||
| unique
|
| unique
|
||||||
| sort
|
| sort
|
||||||
}}
|
}}
|
||||||
|
# Deactivated linter rules:
|
||||||
|
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
|
||||||
|
# would be undefined. This will not be the case during playbook execution.
|
||||||
|
# noqa jinja[invalid]
|
||||||
|
|||||||
+72
-8
@@ -1,8 +1,72 @@
|
|||||||
ansible-core>=2.13.2
|
ansible-compat==2.2.1
|
||||||
jmespath
|
ansible-core==2.13.5
|
||||||
jsonpatch
|
ansible-lint==6.8.4
|
||||||
kubernetes>=12.0.0
|
arrow==1.2.3
|
||||||
molecule-vagrant>=1.0.0
|
attrs==22.1.0
|
||||||
molecule>=4.0.1
|
binaryornot==0.4.4
|
||||||
netaddr>=0.8.0
|
black==22.10.0
|
||||||
pyyaml>=3.11
|
bracex==2.3.post1
|
||||||
|
cachetools==5.2.0
|
||||||
|
Cerberus==1.3.2
|
||||||
|
certifi==2022.9.24
|
||||||
|
cffi==1.15.1
|
||||||
|
chardet==5.0.0
|
||||||
|
charset-normalizer==2.1.1
|
||||||
|
click==8.1.3
|
||||||
|
click-help-colors==0.9.1
|
||||||
|
commonmark==0.9.1
|
||||||
|
cookiecutter==2.1.1
|
||||||
|
cryptography==38.0.1
|
||||||
|
distro==1.8.0
|
||||||
|
enrich==1.2.7
|
||||||
|
filelock==3.8.0
|
||||||
|
google-auth==2.13.0
|
||||||
|
idna==3.4
|
||||||
|
importlib-resources==5.10.0
|
||||||
|
Jinja2==3.1.2
|
||||||
|
jinja2-time==0.2.0
|
||||||
|
jmespath==1.0.1
|
||||||
|
jsonpatch==1.32
|
||||||
|
jsonpointer==2.3
|
||||||
|
jsonschema==4.16.0
|
||||||
|
kubernetes==24.2.0
|
||||||
|
MarkupSafe==2.1.1
|
||||||
|
molecule==4.0.1
|
||||||
|
molecule-vagrant==1.0.0
|
||||||
|
mypy-extensions==0.4.3
|
||||||
|
netaddr==0.8.0
|
||||||
|
oauthlib==3.2.2
|
||||||
|
packaging==21.3
|
||||||
|
pathspec==0.10.1
|
||||||
|
pkgutil-resolve-name==1.3.10
|
||||||
|
platformdirs==2.5.2
|
||||||
|
pluggy==1.0.0
|
||||||
|
pre-commit==2.20.0
|
||||||
|
pyasn1==0.4.8
|
||||||
|
pyasn1-modules==0.2.8
|
||||||
|
pycparser==2.21
|
||||||
|
Pygments==2.13.0
|
||||||
|
pyparsing==3.0.9
|
||||||
|
pyrsistent==0.18.1
|
||||||
|
python-dateutil==2.8.2
|
||||||
|
python-slugify==6.1.2
|
||||||
|
python-vagrant==1.0.0
|
||||||
|
PyYAML==6.0
|
||||||
|
requests==2.28.1
|
||||||
|
requests-oauthlib==1.3.1
|
||||||
|
resolvelib==0.8.1
|
||||||
|
rich==12.6.0
|
||||||
|
rsa==4.9
|
||||||
|
ruamel.yaml==0.17.21
|
||||||
|
ruamel.yaml.clib==0.2.7
|
||||||
|
selinux==0.2.1
|
||||||
|
six==1.16.0
|
||||||
|
subprocess-tee==0.3.5
|
||||||
|
text-unidecode==1.3
|
||||||
|
tomli==2.0.1
|
||||||
|
typing-extensions==4.4.0
|
||||||
|
urllib3==1.26.12
|
||||||
|
wcmatch==8.4.1
|
||||||
|
websocket-client==1.4.1
|
||||||
|
yamllint==1.28.0
|
||||||
|
zipp==3.10.0
|
||||||
|
|||||||
@@ -5,3 +5,9 @@
|
|||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
- role: reset
|
- role: reset
|
||||||
|
- role: raspberrypi
|
||||||
|
vars: {state: absent}
|
||||||
|
post_tasks:
|
||||||
|
- name: Reboot and wait for node to come back up
|
||||||
|
reboot:
|
||||||
|
reboot_timeout: 3600
|
||||||
|
|||||||
@@ -152,12 +152,19 @@
|
|||||||
owner: "{{ ansible_user }}"
|
owner: "{{ ansible_user }}"
|
||||||
mode: "u=rw,g=,o="
|
mode: "u=rw,g=,o="
|
||||||
|
|
||||||
- name: Configure kubectl cluster to https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
|
- name: Configure kubectl cluster to {{ endpoint_url }}
|
||||||
command: >-
|
command: >-
|
||||||
k3s kubectl config set-cluster default
|
k3s kubectl config set-cluster default
|
||||||
--server=https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
|
--server={{ endpoint_url }}
|
||||||
--kubeconfig ~{{ ansible_user }}/.kube/config
|
--kubeconfig ~{{ ansible_user }}/.kube/config
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
vars:
|
||||||
|
endpoint_url: >-
|
||||||
|
https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443
|
||||||
|
# Deactivated linter rules:
|
||||||
|
# - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap
|
||||||
|
# would be undefined. This will not be the case during playbook execution.
|
||||||
|
# noqa jinja[invalid]
|
||||||
|
|
||||||
- name: Create kubectl symlink
|
- name: Create kubectl symlink
|
||||||
file:
|
file:
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
# Timeout to wait for MetalLB services to come up
|
# Timeout to wait for MetalLB services to come up
|
||||||
metal_lb_available_timeout: 60s
|
metal_lb_available_timeout: 120s
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
command: >-
|
command: >-
|
||||||
k3s kubectl wait {{ item.resource }}
|
k3s kubectl wait {{ item.resource }}
|
||||||
--namespace='metallb-system'
|
--namespace='metallb-system'
|
||||||
{% if item.name | default(False) -%} {{ item.name }} {%- endif %}
|
{% if item.name | default(False) -%}{{ item.name }}{%- endif %}
|
||||||
{% if item.selector | default(False) -%} --selector='{{ item.selector }}' {%- endif %}
|
{% if item.selector | default(False) -%}--selector='{{ item.selector }}'{%- endif %}
|
||||||
{% if item.condition | default(False) -%} {{ item.condition }} {%- endif %}
|
{% if item.condition | default(False) -%}{{ item.condition }}{%- endif %}
|
||||||
--timeout='{{ metal_lb_available_timeout }}'
|
--timeout='{{ metal_lb_available_timeout }}'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# Indicates whether the k3s prerequisites for Raspberry Pi should be set up
|
||||||
|
# Possible values:
|
||||||
|
# - present
|
||||||
|
# - absent
|
||||||
|
state: present
|
||||||
@@ -47,13 +47,20 @@
|
|||||||
- raspberry_pi|default(false)
|
- raspberry_pi|default(false)
|
||||||
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
|
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
|
||||||
|
|
||||||
- name: execute OS related tasks on the Raspberry Pi
|
- name: execute OS related tasks on the Raspberry Pi - {{ action }}
|
||||||
include_tasks: "{{ item }}"
|
include_tasks: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- "prereq/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
|
- "{{ action }}/{{ detected_distribution }}-{{ detected_distribution_major_version }}.yml"
|
||||||
- "prereq/{{ detected_distribution }}.yml"
|
- "{{ action }}/{{ detected_distribution }}.yml"
|
||||||
- "prereq/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
- "{{ action }}/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||||
- "prereq/{{ ansible_distribution }}.yml"
|
- "{{ action }}/{{ ansible_distribution }}.yml"
|
||||||
- "prereq/default.yml"
|
- "{{ action }}/default.yml"
|
||||||
|
vars:
|
||||||
|
action: >-
|
||||||
|
{% if state == "present" -%}
|
||||||
|
setup
|
||||||
|
{%- else -%}
|
||||||
|
teardown
|
||||||
|
{%- endif %}
|
||||||
when:
|
when:
|
||||||
- raspberry_pi|default(false)
|
- raspberry_pi|default(false)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Enable cgroup via boot commandline if not already enabled for Centos
|
- name: Enable cgroup via boot commandline if not already enabled for Rocky
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /boot/cmdline.txt
|
path: /boot/cmdline.txt
|
||||||
backrefs: yes
|
backrefs: yes
|
||||||
+3
-3
@@ -6,8 +6,8 @@
|
|||||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
||||||
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||||
notify: reboot
|
notify: reboot
|
||||||
when: not ansible_check_mode
|
|
||||||
|
|
||||||
- name: Install linux-modules-extra-raspi
|
- name: Install linux-modules-extra-raspi
|
||||||
apt: name=linux-modules-extra-raspi state=present
|
apt:
|
||||||
when: (raspberry_pi) and (not ansible_check_mode)
|
name: linux-modules-extra-raspi
|
||||||
|
state: present
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Remove linux-modules-extra-raspi
|
||||||
|
apt:
|
||||||
|
name: linux-modules-extra-raspi
|
||||||
|
state: absent
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
---
|
||||||
@@ -50,14 +50,7 @@
|
|||||||
systemd:
|
systemd:
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
|
|
||||||
- name: Remove linux-modules-extra-raspi
|
- name: Remove tmp directory used for manifests
|
||||||
apt: name=linux-modules-extra-raspi state=absent
|
|
||||||
|
|
||||||
- name: Remove tmp director used for manifests
|
|
||||||
file:
|
file:
|
||||||
path: /tmp/k3s
|
path: /tmp/k3s
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Reboot and wait for node to come back up
|
|
||||||
reboot:
|
|
||||||
reboot_timeout: 3600
|
|
||||||
|
|||||||
Reference in New Issue
Block a user