Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 35 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# runs at parse time on every invocation: ensure certs exist, then (re)generate .env
$(shell [ -f files/certs/ca.pem ] || ./scripts/gen-certs.sh)
$(shell ./env.sh 1>&2)
-include .env

.DEFAULT_GOAL := up
.EXPORT_ALL_VARIABLES:

-include .env
# disable built-in implicit rules (e.g. the "%: %.sh" rule that silently turns a
# stray/misspelled prerequisite into a junk executable instead of erroring out)
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

# Commands
YQ=docker run --rm -i -v $(shell pwd):/workdir mikefarah/yq:4

KINDCONFIG := $(or $(KINDCONFIG),control-plane/kind.yaml)
KUBECONFIG := $(shell pwd)/.kubeconfig

METALCTL_HMAC := $(or $(METALCTL_HMAC),metal-admin)
METALCTL_API_URL := $(or $(METALCTL_API_URL),http://api.172.17.0.1.nip.io:8080/metal)
METAL_APIV2_URL := $(or $(METAL_APIV2_URL),http://v2.172.17.0.1.nip.io:8080)

MKE2FS_CONFIG := $(shell pwd)/mke2fs.conf
# Default values
CONTAINERLAB=$(shell which containerlab)
Expand All @@ -27,6 +31,11 @@ MINI_LAB_VM_IMAGE := $(or $(MINI_LAB_VM_IMAGE),ghcr.io/metal-stack/mini-lab-vms:
MINI_LAB_SONIC_IMAGE := $(or $(MINI_LAB_SONIC_IMAGE),ghcr.io/metal-stack/mini-lab-sonic:latest)
MINI_LAB_DELL_SONIC_VERSION := $(or $(MINI_LAB_DELL_SONIC_VERSION),4.5.1)

MINI_LAB_INTERNAL_NETWORK=mini_lab_internal
# define this here as well so that kind picks up the network on a clean checkout,
# where .env does not exist yet at make parse time (-include .env above)
KIND_EXPERIMENTAL_DOCKER_NETWORK := $(or $(KIND_EXPERIMENTAL_DOCKER_NETWORK),$(MINI_LAB_INTERNAL_NETWORK))

MACHINE_OS=debian-13.0
MAX_RETRIES := 30

Expand Down Expand Up @@ -75,7 +84,7 @@ COMPOSE_ARGS += $(if $(MINI_LAB_HELM_CHARTS),-f compose.dev/helm-charts.yaml)
endif

.PHONY: up
up: env gen-certs verify-deployment-image control-plane-bake partition-bake
up: gen-certs verify-deployment-image control-plane-bake partition-bake
@chmod 600 files/ssh/id_ed25519
docker compose $(COMPOSE_ARGS) up --pull=always --abort-on-container-failure --remove-orphans --force-recreate control-plane partition
@$(MAKE) --no-print-directory start-machines
Expand All @@ -93,23 +102,12 @@ 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
./scripts/gen-certs.sh

.PHONY: control-plane
control-plane: control-plane-bake env
control-plane: control-plane-bake
docker compose $(COMPOSE_ARGS) up --remove-orphans --force-recreate control-plane

.PHONY: create-proxy-registries
Expand All @@ -118,13 +116,16 @@ create-proxy-registries:

.PHONY: control-plane-bake
control-plane-bake:

@if ! docker network ls | grep -q mini_lab_internal; then docker network create mini_lab_internal --gateway 172.42.0.1 --ip-range=172.42.0.0/16 --subnet=172.42.0.0/16 --ipv6=false ; fi
@if ! which kind > /dev/null; then echo "kind needs to be installed"; exit 1; fi
@if ! kind get clusters | grep metal-control-plane > /dev/null; then \
kind create cluster $(KIND_ARGS) \
--name metal-control-plane \
--config $(KINDCONFIG) \
--kubeconfig $(KUBECONFIG); fi
$(MAKE) create-proxy-registries
docker compose up -d --force-recreate cloud-provider-kind

.PHONY: partition
partition: partition-bake
Expand All @@ -144,7 +145,7 @@ endif
./scripts/deactivate_offloading.sh; fi

.PHONY: verify-deployment-image
verify-deployment-image: env
verify-deployment-image:
@if which cosign 1> /dev/null 2> /dev/null; then \
echo -e "\033[0;32mcosign is installed, verifying deployment base image\033[0m" && \
. ./.env && cosign verify --key files/cosign.pub ghcr.io/metal-stack/metal-deployment-base:$$DEPLOYMENT_BASE_IMAGE_TAG; \
Expand All @@ -170,12 +171,18 @@ external_network:
sudo ip -6 route add 2001:db8:0:113::/64 via 2001:db8:0:1::1 dev mini_lab_ext; \
fi

.PHONY: env
env:
@./env.sh
files/certs/ca.pem:
@./scripts/gen-certs.sh

.env: files/certs/ca.pem
@./env.sh 1>&2

.PHONY: gen-certs # keep as a convenience alias
gen-certs: files/certs/ca.pem

.PHONY: cleanup
cleanup: cleanup-control-plane cleanup-partition
docker network rm --force mini_lab_internal

.PHONY: cleanup-control-plane
cleanup-control-plane:
Expand All @@ -193,7 +200,7 @@ cleanup-partition:
docker network rm --force mini_lab_ext

.PHONY: _privatenet
_privatenet: env
_privatenet:
docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl network list --name user-private-network | grep user-private-network || docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl network allocate --partition mini-lab --project 00000000-0000-0000-0000-000000000001 --name user-private-network

.PHONY: update-userdata
Expand Down Expand Up @@ -236,7 +243,7 @@ public-ipv6:
@docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl network ip create --name test --network internet-mini-lab --project 00000000-0000-0000-0000-000000000001 --addressfamily IPv6 -o template --template "{{ .ipaddress }}"

.PHONY: ls
ls: env
ls:
docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl machine ls

## SWITCH MANAGEMENT ##
Expand Down Expand Up @@ -342,7 +349,7 @@ console-machine04:
@$(MAKE) --no-print-directory _console VM=machine04

.PHONY: _password
_password: env
_password:
docker compose run $(DOCKER_COMPOSE_RUN_ARG) metalctl machine consolepassword $(MACHINE_UUID)

.PHONY: password-machine01
Expand Down Expand Up @@ -433,6 +440,7 @@ dev-env:
@echo "export METALCTL_HMAC=${METALCTL_HMAC}"
@echo "export METAL_APIV2_URL=${METAL_APIV2_URL}"
@echo "export KUBECONFIG=$(KUBECONFIG)"
@echo "export METALCTL_CERTIFICATE_AUTHORITY_DATA=$(METALCTL_CERTIFICATE_AUTHORITY_DATA)"

build-dell-sonic:
if [ ! -f "sonic-vs.img" ]; then \
Expand All @@ -451,7 +459,7 @@ build-dell-sonic:
fetch-virtual-kubeconfig:
# TODO: it's hard to get the latest issued generic kubeconfig secret... just take the first result for now
kubectl --kubeconfig=$(KUBECONFIG) get secret -n garden $(shell kubectl --kubeconfig=$(KUBECONFIG) get secret -n garden -l managed-by=secrets-manager,manager-identity=gardener-operator,name=generic-token-kubeconfig --no-headers | awk '{ print $$1 }') -o jsonpath='{.data.kubeconfig}' | base64 -d > .virtual-kubeconfig
@kubectl --kubeconfig=.virtual-kubeconfig config set-cluster garden --server=https://api.gardener-kube-apiserver.172.17.0.1.nip.io:4443
@kubectl --kubeconfig=.virtual-kubeconfig config set-cluster garden --server=https://api.gardener-kube-apiserver.172.42.0.1.nip.io:4443
@kubectl --kubeconfig=.virtual-kubeconfig config set-credentials garden --token=$(shell kubectl --kubeconfig=$(KUBECONFIG) get secret -n garden shoot-access-virtual-garden -o jsonpath='{.data.token}' | base64 -d)
@kubectl --kubeconfig=$(KUBECONFIG) config unset users.garden
@kubectl --kubeconfig=$(KUBECONFIG) config unset contexts.garden
Expand Down
15 changes: 15 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ services:
environment:
- METALCTL_HMAC=${METALCTL_HMAC}
- METALCTL_API_URL=${METALCTL_API_URL}
- METALCTL_CERTIFICATE_AUTHORITY_DATA=${METALCTL_CERTIFICATE_AUTHORITY_DATA}
- METALCTL_HMAC_AUTH_TYPE=${METALCTL_HMAC_AUTH_TYPE:-Metal-Admin}
volumes:
- ./files/ssh:/root/.ssh:ro
Expand Down Expand Up @@ -126,6 +127,20 @@ services:
- REGISTRY_PROXY_TTL=168h
- REGISTRY_STORAGE_DELETE_ENABLED=true
- OTEL_TRACES_EXPORTER=none
cloud-provider-kind:
image: registry.k8s.io/cloud-provider-kind/cloud-controller-manager:v0.10.0
restart: always
networks:
- kind
environment:
- KIND_EXPERIMENTAL_DOCKER_NETWORK=${KIND_EXPERIMENTAL_DOCKER_NETWORK:-kind}
command:
# v0.10.0 of cloud controller does not support tcproutes, since it does not support the experimental gateway api channel
# using envoy-gateway deployed via roles/gateway instead
- --gateway-channel
- disabled
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
proxy-docker:
proxy-gcr:
Expand Down
6 changes: 1 addition & 5 deletions control-plane/kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
networking:
apiServerPort: 6443
apiServerAddress: 0.0.0.0
apiServerAddress: 172.42.0.1
Comment thread
l0wl3vel marked this conversation as resolved.
nodes:
- role: control-plane
extraMounts:
Expand All @@ -13,10 +13,6 @@ nodes:
hostPort: 4443
- containerPort: 8080
hostPort: 8080
- containerPort: 4150
hostPort: 4150
- containerPort: 50051
hostPort: 50051
# if you want to run gardener operator + metal-stack, you need more pods
kubeadmConfigPatches:
- |
Expand Down
6 changes: 4 additions & 2 deletions deploy_control_plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
roles:
- name: ansible-common
tags: always
- name: ingress-controller
tags: ingress-controller
- name: metal-roles/control-plane/roles/prepare
tags: prepare
- name: gateway
tags: gateway
- name: ingress-controller
tags: ingress-controller
- name: metal-roles/control-plane/roles/nsq
tags: nsq
- name: metal-roles/control-plane/roles/metal-db
Expand Down
4 changes: 2 additions & 2 deletions deploy_gardener.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name: shoot-info
namespace: kube-system
data:
nodeNetwork: 172.18.0.0/16
nodeNetwork: 172.42.0.0/16
podNetwork: 10.244.0.0/24
serviceNetwork: 10.96.0.0/16
tags: gardener
Expand Down Expand Up @@ -81,7 +81,7 @@
status:
loadBalancer:
ingress:
- ip: "172.17.0.1"
- ip: "172.42.0.1"
tags: gardener

- name: Expose istio gateway through ingress-nginx (for local environments)
Expand Down
4 changes: 2 additions & 2 deletions docs/overview-kamaji.drawio.svg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ingress-controller NGINX should be updated to Envoy Gateway? :)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/overview.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ DEPLOYMENT_BASE_IMAGE_TAG=${DEPLOYMENT_BASE_IMAGE_TAG}
CI=${CI:=false}
DOCKER_HUB_USER=${DOCKER_HUB_USER:=}
DOCKER_HUB_TOKEN=${DOCKER_HUB_TOKEN:=}
KIND_EXPERIMENTAL_DOCKER_NETWORK=${MINI_LAB_INTERNAL_NETWORK:=mini_lab_internal}

METALCTL_HMAC=${METALCTL_HMAC:=metal-admin}
METALCTL_API_URL=${METALCTL_API_URL:=https://api.172.42.0.42.nip.io/metal}
METALCTL_CERTIFICATE_AUTHORITY_DATA=${METALCTL_CERTIFICATE_AUTHORITY_DATA:=$(cat files/certs/ca.pem | base64 -w0)}

METAL_APIV2_URL=${METAL_APIV2_URL:=http://v2.172.42.0.42.nip.io}
EOF
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"CN": "metal-api",
"hosts": [
"172.17.0.1",
"api.172.42.0.42.nip.io",
"v2.172.42.0.42.nip.io",
"172.42.0.42",
"203.0.113.1"
],
"key": {
Expand Down
4 changes: 2 additions & 2 deletions files/dev_images.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Do not change these values
metal_api_image_tag: dev
metal_core_image_name: 172.17.0.1:5000/metalstack/metal-core
metal_core_image_name: 172.42.0.42:5000/metalstack/metal-core
metal_core_image_tag: dev
metal_hammer_image_url: http://172.17.0.1:20015/metal-hammer-initrd.img.lz4
metal_hammer_image_url: http://172.42.0.42:20015/metal-hammer-initrd.img.lz4
2 changes: 1 addition & 1 deletion files/startup-config/leaf01_4.4.3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"DNS_SERVER": {
"172.17.0.1": {},
"172.42.0.1": {},
"1.1.1.1": {},
"1.0.0.1": {}
},
Expand Down
2 changes: 1 addition & 1 deletion files/startup-config/leaf01_4.5.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"DNS_SERVER": {
"172.17.0.1": {},
"172.42.0.1": {},
"1.1.1.1": {},
"1.0.0.1": {}
},
Expand Down
2 changes: 1 addition & 1 deletion files/startup-config/leaf02_4.4.3.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"DNS_SERVER": {
"172.17.0.1": {},
"172.42.0.1": {},
"1.1.1.1": {},
"1.0.0.1": {}
},
Expand Down
2 changes: 1 addition & 1 deletion files/startup-config/leaf02_4.5.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
},
"DNS_SERVER": {
"172.17.0.1": {},
"172.42.0.1": {},
"1.1.1.1": {},
"1.0.0.1": {}
},
Expand Down
3 changes: 2 additions & 1 deletion inventories/group_vars/all/control_plane.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
metal_control_plane_provider_tenant: metal-stack
metal_control_plane_ingress_dns: 172.17.0.1.nip.io
metal_control_plane_ingress_dns: 172.42.0.1.nip.io
metal_control_plane_gateway_dns: 172.42.0.42.nip.io
metal_control_plane_stage_name: test
metal_control_plane_namespace: metal-control-plane
metal_control_plane_image_pull_policy: Always
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
gardener_gardenlet_default_dns_domain: "gardener.172.17.0.1.nip.io"
gardener_gardenlet_default_dns_domain: "gardener.172.42.0.1.nip.io"
gardener_gardenlet_default_dns_provider: powerdns
gardener_gardenlet_default_dns_credentials:
apiKey: "{{ powerdns_api_key | b64encode }}"
Expand Down
4 changes: 2 additions & 2 deletions inventories/group_vars/control_plane/gardener/operator.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
gardener_operator_ingress_dns_domain: "gardener.172.17.0.1.nip.io"
gardener_operator_ingress_dns_domain: "gardener.{{ metal_control_plane_ingress_dns }}"

gardener_operator_backup_infrastructure:
provider: S3
Expand All @@ -17,7 +17,7 @@ gardener_operator_backup_infrastructure_secret:
s3ForcePathStyle: "{{ 'true' | b64encode }}"

# enable mini-lab patches
gardener_operator_patch_istio_ingress_gateway_service_ip: 172.17.0.1
gardener_operator_patch_istio_ingress_gateway_service_ip: 172.42.0.1
gardener_operator_expose_virtual_garden_through_ingress_nginx: true

# for local setups this should be sufficient
Expand Down
6 changes: 3 additions & 3 deletions inventories/group_vars/control_plane/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
ingress_tcp_service_exposals:
"4150": "{{ metal_control_plane_namespace }}/nsqd:4150"
"50051": "{{ metal_control_plane_namespace }}/metal-api:50051"
gateway_tcp_listeners:
nsq: 4150
metal-api-grpc: 50051
Loading
Loading