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

Add flavor to run Gardener in the mini-lab #202

Merged
merged 34 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c64e43e
[skip ci] Next attempt to run Gardener in mini-lab.
Gerrit91 Nov 13, 2024
c0ec9e6
[skip ci] Merge remote-tracking branch 'origin/master' into gardener-…
Gerrit91 Nov 20, 2024
a1f220a
Move to PowerDNS extension.
Gerrit91 Nov 20, 2024
1f6d8a6
No override.
Gerrit91 Nov 20, 2024
056336c
Merge branch 'master' into gardener-local
Gerrit91 Nov 25, 2024
ef5a679
Progress.
Gerrit91 Dec 12, 2024
47a074d
Merge remote-tracking branch 'origin/master' into gardener-local
Gerrit91 Dec 13, 2024
91fe624
Adaptions.
Gerrit91 Dec 13, 2024
cd17756
Unused var.
Gerrit91 Dec 13, 2024
40a6844
Merge branch 'master' into gardener-local
Gerrit91 Jan 8, 2025
c890d9b
metal-roles was merged.
Gerrit91 Jan 8, 2025
41fc464
Merge remote-tracking branch 'origin/gardener-local' into gardener-local
Gerrit91 Jan 8, 2025
869dcd0
Merge branch 'master' into gardener-local
Gerrit91 Jan 13, 2025
936af29
Add module to patch istio ingress gateway svc.
Gerrit91 Jan 13, 2025
17e5126
Add retries.
Gerrit91 Jan 13, 2025
e8e185a
Not required anymore to overwrite DNS extension.
Gerrit91 Jan 13, 2025
c914dd0
Fix wait condition.
Gerrit91 Jan 13, 2025
c2c9b9c
Default to false.
Gerrit91 Jan 14, 2025
412d17b
Fix on wait condition.
Gerrit91 Jan 14, 2025
f67fbe2
Fix.
Gerrit91 Jan 14, 2025
84b9a80
Wait until seed is ready.
Gerrit91 Jan 14, 2025
9470eba
Test the flavor.
Gerrit91 Jan 14, 2025
065c579
Remove certs.
Gerrit91 Jan 14, 2025
17c0bb9
Generate certs dynamically.
Gerrit91 Jan 14, 2025
4d31ec6
Revert.
Gerrit91 Jan 14, 2025
64ec848
Rename orgs.
Gerrit91 Jan 14, 2025
3c09002
Deps.
Gerrit91 Jan 14, 2025
e55b150
Remove vault stuff.
Gerrit91 Jan 14, 2025
5a8affd
Add target to roll certs.
Gerrit91 Jan 14, 2025
c10a73d
Remove mariadb from PowerDNS.
Gerrit91 Jan 15, 2025
ece939d
Reduce PowerDNS requests.
Gerrit91 Jan 15, 2025
21a5cb9
Improve roll_certs shell script.
Gerrit91 Jan 15, 2025
1c12183
Fix cumulus repos.
Gerrit91 Jan 15, 2025
d92a628
Update 2.3.8.
Gerrit91 Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
flavors:
- name: cumulus
- name: sonic
- name: gardener

steps:
- name: Gain back workspace permissions # https://github.com/actions/checkout/issues/211
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ requirements.yaml
.extra_vars.yaml
sonic-vs.img
*.bak
.ansible
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ansible caches git clones here, which are happening in the Gardener role.

files/certs/*.pem
files/certs/**/*.pem
files/certs/**/*.crt
41 changes: 40 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ else ifeq ($(MINI_LAB_FLAVOR),capms)
LAB_MACHINES=machine01,machine02,machine03
LAB_TOPOLOGY=mini-lab.capms.yaml
VRF=Vrf20
else ifeq ($(MINI_LAB_FLAVOR),gardener)
GARDENER_ENABLED=true
# usually gardener restricts the maximum version for k8s:
K8S_VERSION=1.30.8
LAB_MACHINES=machine01,machine02
LAB_TOPOLOGY=mini-lab.sonic.yaml
VRF=Vrf20
else
$(error Unknown flavor $(MINI_LAB_FLAVOR))
endif
Expand All @@ -50,7 +57,7 @@ else
endif

.PHONY: up
up: env control-plane-bake partition-bake
up: env gen-certs control-plane-bake partition-bake
@chmod 600 files/ssh/id_rsa
docker compose up --remove-orphans --force-recreate control-plane partition
@$(MAKE) --no-print-directory start-machines
Expand All @@ -67,6 +74,21 @@ restart: down up
.PHONY: down
down: cleanup

.PHONY: gen-certs
gen-certs:
@if ! [ -f "files/certs/ca.pem" ]; then \
echo "certificate generation required, running cfssl container"; \
docker run --rm \
--user $$(id -u):$$(id -g) \
--entrypoint bash \
-v ${PWD}:/work \
cfssl/cfssl /work/scripts/roll_certs.sh; fi

.PHONY: roll-certs
roll-certs:
rm files/certs/ca.pem
$(MAKE) gen-certs

.PHONY: control-plane
control-plane: control-plane-bake env
docker compose up --remove-orphans --force-recreate control-plane
Expand Down Expand Up @@ -272,3 +294,20 @@ dev-env:
@echo "export METALCTL_API_URL=http://api.172.17.0.1.nip.io:8080/metal"
@echo "export METALCTL_HMAC=metal-admin"
@echo "export KUBECONFIG=$(KUBECONFIG)"

## Gardener integration

.PHONY: fetch-virtual-kubeconfig
fetch-virtual-kubeconfig:
kubectl config unset users.virtual-garden
kubectl config unset contexts.virtual-garden
kubectl config unset clusters.virtual-garden
kubectl get secret -n garden garden-kubeconfig-for-admin -o jsonpath='{.data.kubeconfig}' | base64 -d > .virtual-kubeconfig
kubectl --kubeconfig=.virtual-kubeconfig config rename-context garden virtual-garden
sed -i 's/name: garden/name: virtual-garden/g' .virtual-kubeconfig
sed -i 's/name: admin/name: virtual-garden/g' .virtual-kubeconfig
kubectl --kubeconfig=.virtual-kubeconfig config set contexts.virtual-garden.cluster virtual-garden
kubectl --kubeconfig=.virtual-kubeconfig config set contexts.virtual-garden.user virtual-garden
KUBECONFIG=$$KUBECONFIG:.virtual-kubeconfig kubectl config view --flatten > .merged-kubeconfig
rm .virtual-kubeconfig
mv .merged-kubeconfig .kubeconfig
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ docker compose run --rm metalctl machine rm 00000000-0000-0000-0000-000000000001

There are two versions, or flavors, of the mini-lab environment which differ in regards to the NOS running on the leaves:

- `cumulus` -- runs 2 Cumulus switches.
- `sonic` -- runs 2 SONiC switches
- `cumulus`: runs 2 Cumulus switches.
- `sonic`: runs 2 SONiC switches
- `capms`: runs the SONiC flavor but with three instead of two machines (this is used for [cluster-provider-metal-stack](https://github.com/metal-stack/cluster-api-provider-metal-stack) in order to have dedicated hosts for control plane / worker / firewall)
- `gardener`: installs the [Gardener](https://gardener.cloud) in the mini-lab

In order to start specific flavor, you can define the flavor as follows:

Expand Down
13 changes: 1 addition & 12 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ services:
- CI=${CI}
- DOCKER_HUB_USER=${DOCKER_HUB_USER}
- DOCKER_HUB_TOKEN=${DOCKER_HUB_TOKEN}
- GARDENER_ENABLED=${GARDENER_ENABLED:-}
network_mode: host
working_dir: /mini-lab
dns:
Gerrit91 marked this conversation as resolved.
Show resolved Hide resolved
- 172.17.0.1
- 1.1.1.1
- 1.0.0.1
entrypoint:
- /bin/bash
- -ce
Expand Down Expand Up @@ -55,10 +52,6 @@ services:
- DOCKER_HUB_TOKEN=${DOCKER_HUB_TOKEN}
network_mode: host
working_dir: /mini-lab
dns:
- 172.17.0.1
- 1.1.1.1
- 1.0.0.1
entrypoint:
- /bin/bash
- -ce
Expand All @@ -82,8 +75,4 @@ services:
- ./files/ignition.json:/tmp/ignition.json
- ./files/rules.yaml:/tmp/rules.yaml
network_mode: host
dns:
- 172.17.0.1
- 1.1.1.1
- 1.0.0.1
command: --version
8 changes: 4 additions & 4 deletions deploy_control_plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
hosts: control-plane
connection: local
gather_facts: false
vars:
setup_yaml:
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
meta_var: metal_stack_release
roles:
- name: ansible-common
tags: always
Expand All @@ -26,3 +22,7 @@
tags: auditing
- name: metal-roles/control-plane/roles/metal
tags: metal

- name: deploy gardener
import_playbook: deploy_gardener.yaml
when: gardener_enabled
82 changes: 82 additions & 0 deletions deploy_gardener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
- name: deploy gardener
hosts: control-plane
connection: local
gather_facts: false
pre_tasks:
- name: Fake Gardener metal shoot
k8s:
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: shoot-info
namespace: kube-system
data:
nodeNetwork: 172.18.0.0/16
podNetwork: 10.244.0.0/24
serviceNetwork: 10.96.0.0/16

- name: Create garden namespace
k8s:
definition:
apiVersion: v1
kind: Namespace
metadata:
name: garden

# our current state in metal-roles/gardener does not support network policies from gardenlet <-> virtual garden
# this should be possible to resolve when we use the Gardener Operator
- name: Deploy allow all network policy
k8s:
definition: "{{ lookup('file', 'netpol-allow-all.yaml') }}"
namespace: garden
apply: yes
roles:
- name: ansible-common
tags: always
- name: minio
- name: powerdns
tags: powerdns
- name: metal-roles/control-plane/roles/gardener
tags: gardener
vars:
metal_control_plane_host_provider: metal

post_tasks:
# gardener exposes the istio ingress gateway through service type load balancer
# we can fake the exposal by patching the status field, which is also what's
# done in the gardener local environment
- name: Wait for istio ingress gateway service
kubernetes.core.k8s_info:
api_version: v1
kind: Service
name: istio-ingressgateway
namespace: istio-ingress
register: result
until: result.resources
retries: 30
delay: 10

- name: Patch ingress status of istio ingress gateway to allow seed to get ready
patch_service_status_k8s:
name: istio-ingressgateway
namespace: istio-ingress
body:
status:
loadBalancer:
ingress:
- ip: "172.17.0.1"

- name: Wait until seed is ready
kubernetes.core.k8s_info:
api_version: "core.gardener.cloud/v1beta1"
kind: Seed
name: "{{ metal_control_plane_stage_name }}"
kubeconfig: "{{ gardener_kube_apiserver_kubeconfig_path }}"
wait: yes
wait_condition:
reason: GardenletReady
status: "True"
type: GardenletReady
wait_timeout: 300
28 changes: 16 additions & 12 deletions deploy_partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
command: tar xf /root/jessie-apt-transport-fix.tar.gz
- name: install apt-transport
shell: dpkg -i /root/https-deps/*.deb && apt-get install -fy
- name: use own repo mirrors (old ones are 404)
copy:
dest: /etc/apt/sources.list
content: |
deb https://cumulus-3.apt.metal-stack.io/cumulus CumulusLinux-3 main
deb-src https://cumulus-3.apt.metal-stack.io/cumulus CumulusLinux-3 main

deb https://cumulus-3.apt.metal-stack.io/cumulus-updates CumulusLinux-3-updates main
deb-src https://cumulus-3.apt.metal-stack.io/cumulus-updates CumulusLinux-3-updates main

deb https://cumulus-3.apt.metal-stack.io/cumulus-security-updates CumulusLinux-3-security-updates main
deb-src https://cumulus-3.apt.metal-stack.io/cumulus-security-updates CumulusLinux-3-security-updates main
- name: set resolv.conf
shell: rm /etc/resolv.conf && echo 'nameserver 8.8.8.8' > /etc/resolv.conf
- name: use own repo key
shell: curl -fsSL https://cumulus-3.apt.metal-stack.io/cumulus-3-repo.gpg | apt-key add -
roles:
- name: cumulus
tags: cumulus
Expand All @@ -37,10 +53,6 @@

- name: Deploy dhcp server and pixiecore on leaf01
hosts: leaf01
vars:
setup_yaml:
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
meta_var: metal_stack_release
roles:
- name: ansible-common
tags: always
Expand All @@ -51,10 +63,6 @@

- name: Deploy metal-core
hosts: leaves
vars:
setup_yaml:
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
meta_var: metal_stack_release
roles:
- name: ansible-common
tags: always
Expand All @@ -65,10 +73,6 @@
hosts: localhost
connection: local
gather_facts: no
vars:
setup_yaml:
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
meta_var: metal_stack_release
roles:
- name: ansible-common
tags: always
Expand Down
2 changes: 1 addition & 1 deletion files/certs/ca-csr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{
"C": "DE",
"L": "Munich",
"O": "Metal-Stack",
"O": "metal-stack",
"OU": "DevOps",
"ST": "Bavaria"
}
Expand Down
51 changes: 0 additions & 51 deletions files/certs/ca-key.pem

This file was deleted.

33 changes: 0 additions & 33 deletions files/certs/ca.pem

This file was deleted.

17 changes: 17 additions & 0 deletions files/certs/gardener-admission-controller/client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"CN": "client",
"hosts": [""],
"key": {
"algo": "ecdsa",
"size": 256
},
"names": [
{
"C": "DE",
"L": "Munich",
"O": "metal-stack",
"OU": "DevOps",
"ST": "Bavaria"
}
]
}
Loading
Loading