Skip to content

Commit

Permalink
Merge pull request #147 from lablabs/feat/ci_molecule_5
Browse files Browse the repository at this point in the history
Molecule 5.0 and Kube proxy default value
  • Loading branch information
MonolithProjects authored May 8, 2023
2 parents 1c7e275 + 1b2d29e commit 63790ce
Show file tree
Hide file tree
Showing 14 changed files with 308 additions and 81 deletions.
135 changes: 106 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
name: molecule test

on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
paths:
- 'defaults/**'
- 'handlers/**'
- 'molecule/**'
- 'tasks/**'
- 'templates/**'
- 'vars/**'
schedule:
- cron: '0 1 1 * *'
workflow_dispatch:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
paths:
- 'defaults/**'
- 'handlers/**'
- 'molecule/**'
- 'tasks/**'
- 'templates/**'
- 'vars/**'
schedule:
- cron: '0 1 1 * *'
workflow_dispatch:

jobs:
standalone:
name: Single node setup
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: ${{ !contains(github.event_name, 'pull_request') }}
matrix:
config:
- image: "rockylinux8"
tag: "latest"
cgroup_mode: "private"
# - image: "ubuntu2004"
# tag: "latest"
# cgroup_mode: "private"
cgroup_mode: "host"
volumes: "rw"
- image: "ubuntu2204"
tag: "latest"
cgroup_mode: "private"
cgroup_mode: "host"
volumes: "rw"
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -44,7 +42,7 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip3 install ansible ansible-lint docker molecule[docker] yamllint
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2"

- name: Run Molecule tests
run: molecule test
Expand All @@ -53,19 +51,20 @@ jobs:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_IMAGE: ${{ matrix.config.image }}
MOLECULE_TAG: ${{ matrix.config.tag }}
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
MOLECULE_DOCKER_VOLUMES: ${{ matrix.config.volumes }}

cluster:
name: Cluster setup
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
runs-on: ubuntu-22.04
needs: standalone
strategy:
matrix:
config:
- image: "ubuntu2204"
tag: "latest"
cgroup_mode: "private"
cgroup_mode: "host"
volumes: "rw"
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -78,14 +77,92 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip3 install ansible ansible-lint docker molecule[docker] yamllint
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2"

- name: Run Molecule tests
run: molecule test
run: molecule test --scenario-name cluster
working-directory: ./lablabs.rke2
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_IMAGE: ${{ matrix.config.image }}
MOLECULE_TAG: ${{ matrix.config.tag }}
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}

# TODO: Fix HA Cluster molecule tests (dind deployment is failing from version 1.22.15+rke2r1)
#
# ha_cluster:
# name: HA Cluster setup
# if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
# runs-on: ubuntu-22.04
# needs: cluster
# strategy:
# matrix:
# config:
# - image: "ubuntu2204"
# cgroup_mode: "host"
# volumes: "rw"
# steps:
# - name: checkout
# uses: actions/checkout@v3
# with:
# path: 'lablabs.rke2'

# - name: Set up Python 3
# uses: actions/setup-python@v4
# with:
# python-version: '3.x'

# - name: Install test dependencies
# run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2"

# - name: Increase nf_conntrack_max
# run: sudo sysctl -w net.netfilter.nf_conntrack_max=393216

# - name: Run Molecule tests
# run: molecule test --scenario-name ha_cluster
# working-directory: ./lablabs.rke2
# env:
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
# MOLECULE_IMAGE: ${{ matrix.config.image }}
# MOLECULE_TAG: ${{ matrix.config.tag }}
# MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}

# ha_cluster_kubevip:
# name: HA Cluster kube-vip setup
# if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
# runs-on: ubuntu-22.04
# needs: cluster
# strategy:
# matrix:
# config:
# - image: "ubuntu2204"
# cgroup_mode: "host"
# volumes: "rw"
# steps:
# - name: checkout
# uses: actions/checkout@v3
# with:
# path: 'lablabs.rke2'

# - name: Set up Python 3
# uses: actions/setup-python@v4
# with:
# python-version: '3.x'

# - name: Install test dependencies
# run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2"

# - name: Increase nf_conntrack_max
# run: sudo sysctl -w net.netfilter.nf_conntrack_max=393216

# - name: Run Molecule tests
# run: molecule test --scenario-name ha_cluster_kubevip
# working-directory: ./lablabs.rke2
# env:
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
# MOLECULE_IMAGE: ${{ matrix.config.image }}
# MOLECULE_TAG: ${{ matrix.config.tag }}
# MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ rke2_channel: stable
rke2_disable:

# Option to disable kube-proxy
disable_kube_proxy: true
disable_kube_proxy: false

# Path to custom manifests deployed during the RKE2 installation
# It is possible to use Jinja2 templating in the manifests
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ rke2_channel: stable
rke2_disable:

# Option to disable kube-proxy
disable_kube_proxy: true
disable_kube_proxy: false

# Path to custom manifests deployed during the RKE2 installation
# It is possible to use Jinja2 templating in the manifests
Expand Down
2 changes: 1 addition & 1 deletion molecule/cluster/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all
become: yes
vars:
rke2_version: v1.20.15+rke2r1
rke2_version: v1.22.12+rke2r1
rke2_snapshooter: native
rke2_server_node_taints:
- 'CriticalAddonsOnly=true:NoExecute'
Expand Down
27 changes: 12 additions & 15 deletions molecule/cluster/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
---
dependency:
name: 'shell'
command: ansible-playbook ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/dependency.yml -i localhost,
command: ansible-playbook ${MOLECULE_PROJECT_DIRECTORY}/molecule/cluster/dependency.yml -i localhost,
driver:
name: docker
lint: |
yamllint -s .
ansible-lint --exclude molecule/ --exclude .github/
platforms:
- name: node1
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:${MOLECULE_TAG:-latest}"
command: ${MOLECULE_DOCKER_COMMAND:-""}
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroups_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: /usr/sbin/init
privileged: true
pre_build_image: true
networks:
Expand All @@ -22,11 +19,11 @@ platforms:
- masters
- k8s_cluster
- name: node2
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:${MOLECULE_TAG:-latest}"
command: ${MOLECULE_DOCKER_COMMAND:-""}
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroups_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: /usr/sbin/init
privileged: true
pre_build_image: true
networks:
Expand All @@ -42,20 +39,20 @@ provisioner:
rke2_type: server
workers:
rke2_type: agent

verifier:
name: ansible
scenario:
name: cluster
test_sequence:
- lint
- dependency
- cleanup
- destroy
- syntax
- dependency
- create
- prepare
- converge
# - idempotence
- side_effect
- verify
- cleanup
- destroy
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
hosts: all
become: yes
vars:
rke2_version: v1.20.15+rke2r1
rke2_version: v1.27.1+rke2r1
rke2_snapshooter: native
roles:
- role: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
16 changes: 7 additions & 9 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ dependency:
command: ansible-playbook ${MOLECULE_PROJECT_DIRECTORY}/molecule/default/dependency.yml -i localhost,
driver:
name: docker
lint: |
yamllint -s .
ansible-lint --exclude molecule/ --exclude .github/
platforms:
- name: node1
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:${MOLECULE_TAG:-latest}"
command: ${MOLECULE_DOCKER_COMMAND:-""}
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroups_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: /usr/sbin/init
privileged: true
pre_build_image: true
networks:
Expand All @@ -28,14 +25,15 @@ verifier:
scenario:
name: default
test_sequence:
- lint
- dependency
- cleanup
- destroy
- syntax
- dependency
- create
- prepare
- converge
# - idempotence
- side_effect
- verify
- cleanup
- destroy
3 changes: 1 addition & 2 deletions molecule/ha_cluster/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
hosts: all
become: yes
vars:
rke2_version: v1.25.3+rke2r1
rke2_cis_profile: cis-1.23
rke2_version: v1.22.12+rke2r1
rke2_ha_mode: true
rke2_api_ip: 192.168.123.100
rke2_snapshooter: native
Expand Down
Loading

0 comments on commit 63790ce

Please sign in to comment.