From dcbf4ffdb3715fc0dfaa1ed5d915da62e7d72b74 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Mon, 21 Oct 2024 07:36:00 +1100 Subject: [PATCH] test: ability to install stable chart versions --- Makefile | 163 +++++++++++------- .../developing-lagoon.md | 124 ++++++++++++- k3d.config.yaml.tpl | 9 +- .../k3d-seed-data/00-populate-kubernetes.gql | 46 ++--- 4 files changed, 252 insertions(+), 90 deletions(-) diff --git a/Makefile b/Makefile index 92849952d3..58066aba62 100644 --- a/Makefile +++ b/Makefile @@ -394,15 +394,56 @@ compose-api-logs-development: KUBECTL_VERSION := v1.31.0 HELM_VERSION := v3.16.1 -K3D_VERSION = v5.7.3 +K3D_VERSION = v5.7.4 GOJQ_VERSION = v0.12.16 STERN_VERSION = v2.6.1 CHART_TESTING_VERSION = v3.11.0 -K3D_IMAGE = docker.io/rancher/k3s:v1.31.0-k3s1 +K3D_IMAGE = docker.io/rancher/k3s:v1.31.1-k3s1 TESTS = [nginx,api,features-kubernetes,bulk-deployment,features-kubernetes-2,features-variables,active-standby-kubernetes,tasks,drush,python,gitlab,github,bitbucket,services,workflows] -CHARTS_TREEISH = main +CHARTS_TREEISH = stable-chart-install +CHARTS_REPOSITORY = https://github.com/uselagoon/lagoon-charts.git +#CHARTS_REPOSITORY = ../lagoon-charts TASK_IMAGES = task-activestandby +# can be used to skip installing all the lagoon-dependencies (registry, ingress, minio, providers) +INSTALL_LAGOON_DEPS = true + +# the following can be used to install stable versions of lagoon directly from chart versions +# rather than the bleeding edge from CHARTS_TREEISH +# these will not build or use built images from this repository, just what the charts provide +# this can be used to install a known version and then revert to test upgrading from a stable version +INSTALL_STABLE_CORE = false +INSTALL_STABLE_REMOTE = false +INSTALL_STABLE_BUILDDEPLOY = false +INSTALL_STABLE_LAGOON = false +ifeq ($(INSTALL_STABLE_LAGOON), true) + INSTALL_STABLE_CORE = true + INSTALL_STABLE_REMOTE = true + INSTALL_STABLE_BUILDDEPLOY = true +endif +STABLE_CORE_CHART_VERSION = +STABLE_REMOTE_CHART_VERSION = +STABLE_STABLE_BUILDDEPLOY_CHART_VERSION = + +# the following can be used to selectively leave out the installation of certain +# dbaas provider types +INSTALL_MARIADB_PROVIDER = +INSTALL_POSTGRES_PROVIDER = +INSTALL_MONGODB_PROVIDER = +INSTALL_DBAAS_PROVIDERS = true +ifeq ($(INSTALL_DBAAS_PROVIDERS), false) + INSTALL_MARIADB_PROVIDER = false + INSTALL_POSTGRES_PROVIDER = false + INSTALL_MONGODB_PROVIDER = false +endif +# mongo currently doesn't work on arm based systems, so just disable the provider entirely for now +ifeq ($(ARCH), darwin) + INSTALL_MONGODB_PROVIDER = false +endif +ifeq ($(MACHINE), arm64) + INSTALL_MONGODB_PROVIDER = false +endif + # the name of the docker network to create DOCKER_NETWORK = k3d @@ -546,59 +587,75 @@ K3D_TOOLS = k3d helm kubectl jq stern # install lagoon charts and run lagoon test suites in a k3d cluster .PHONY: k3d/test -k3d/test: k3d/setup - export KUBECONFIG="$$(pwd)/kubeconfig.k3d.$(CI_BUILD_TAG)" \ - && cd lagoon-charts.k3d.lagoon \ - && export IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ - && $(MAKE) fill-test-ci-values DOCKER_NETWORK=$(DOCKER_NETWORK) TESTS=$(TESTS) IMAGE_TAG=$(SAFE_BRANCH_NAME) DISABLE_CORE_HARBOR=true \ - HELM=$(HELM) KUBECTL=$(KUBECTL) JQ=$(JQ) \ - OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:${BUILD_DEPLOY_IMAGE_TAG} \ - OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library/task-activestandby:$(SAFE_BRANCH_NAME)" \ - IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ - SKIP_ALL_DEPS=true \ - LAGOON_FEATURE_FLAG_DEFAULT_ISOLATION_NETWORK_POLICY=enabled \ - USE_CALICO_CNI=false \ - LAGOON_SSH_PORTAL_LOADBALANCER=$(LAGOON_SSH_PORTAL_LOADBALANCER) \ - LAGOON_FEATURE_FLAG_DEFAULT_ROOTLESS_WORKLOAD=enabled \ - && docker run --rm --network host --name ct-$(CI_BUILD_TAG) \ - --volume "$$(pwd)/test-suite-run.ct.yaml:/etc/ct/ct.yaml" \ - --volume "$$(pwd):/workdir" \ - --volume "$$(realpath ../kubeconfig.k3d.$(CI_BUILD_TAG)):/root/.kube/config" \ - --workdir /workdir \ - "quay.io/helmpack/chart-testing:$(CHART_TESTING_VERSION)" \ - ct install --helm-extra-args "--timeout 60m" +k3d/test: k3d/setup k3d/install-lagoon k3d/retest LOCAL_DEV_SERVICES = api auth-server actions-handler api-sidecar-handler logs2notifications webhook-handler webhooks2tasks + # install lagoon charts in a Kind cluster .PHONY: k3d/setup -k3d/setup: k3d/cluster helm/repos $(addprefix local-dev/,$(K3D_TOOLS)) build +k3d/setup: k3d/cluster helm/repos $(addprefix local-dev/,$(K3D_TOOLS)) k3d/checkout-charts + cd lagoon-charts.k3d.lagoon \ + && export KUBECONFIG="$$(realpath ../kubeconfig.k3d.$(CI_BUILD_TAG))" \ + && $$([ $(INSTALL_LAGOON_DEPS) = true ] && $(MAKE) install-lagoon-dependencies DOCKER_NETWORK=$(DOCKER_NETWORK) JQ=$(JQ) HELM=$(HELM) KUBECTL=$(KUBECTL) USE_CALICO_CNI=false) || true + +# k3d/dev can only be run once a cluster is up and running (run k3d/test or k3d/local-stack first) - it doesn't rebuild the cluster at all +# just checks out the repository and rebuilds and pushes the built images +# into the image registry and reinstalls lagoon charts +.PHONY: k3d/dev +k3d/dev: k3d/checkout-charts k3d/install-lagoon + @$(MAKE) k3d/get-lagoon-details + +# this is used to checkout the chart repo/branch again if required. otherwise will use the symbolic link +# that is created for subsequent commands +.PHONY: k3d/checkout-charts +k3d/checkout-charts: export CHARTSDIR=$$(mktemp -d ./lagoon-charts.XXX) \ && ln -sfn "$$CHARTSDIR" lagoon-charts.k3d.lagoon \ - && git clone https://github.com/uselagoon/lagoon-charts.git "$$CHARTSDIR" \ + && git clone $(CHARTS_REPOSITORY) "$$CHARTSDIR" \ && cd "$$CHARTSDIR" \ - && git checkout $(CHARTS_TREEISH) \ - && export KUBECONFIG="$$(realpath ../kubeconfig.k3d.$(CI_BUILD_TAG))" \ + && git checkout $(CHARTS_TREEISH) + +# this just installs lagoon-core, lagoon-remote, and lagoon-build-deploy +# doing this allows for lagoon to be installed with a known stable chart version with the INSTALL_STABLE_X overrides +# and then running just the install-lagoon target without the INSTALL_STABLE_X overrides to verify if an upgrade is likely to succeed +.PHONY: k3d/install-lagoon +k3d/install-lagoon: +ifneq ($(INSTALL_STABLE_CORE),true) + $(MAKE) build + export KUBECONFIG="$$(realpath kubeconfig.k3d.$(CI_BUILD_TAG))" \ && export IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ - && $(MAKE) install-registry DOCKER_NETWORK=$(DOCKER_NETWORK) JQ=$(JQ) HELM=$(HELM) KUBECTL=$(KUBECTL) USE_CALICO_CNI=false \ - && cd .. && $(MAKE) k3d/push-images JQ=$(JQ) HELM=$(HELM) KUBECTL=$(KUBECTL) && cd "$$CHARTSDIR" \ - && $(MAKE) fill-test-ci-values DOCKER_NETWORK=$(DOCKER_NETWORK) TESTS=$(TESTS) IMAGE_TAG=$(SAFE_BRANCH_NAME) DISABLE_CORE_HARBOR=true \ - HELM=$(HELM) KUBECTL=$(KUBECTL) JQ=$(JQ) \ - OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:${BUILD_DEPLOY_IMAGE_TAG} \ - $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG)') \ - $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY)') \ - OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library/task-activestandby:$(SAFE_BRANCH_NAME)" \ - IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ - SKIP_INSTALL_REGISTRY=true \ - LAGOON_FEATURE_FLAG_DEFAULT_ISOLATION_NETWORK_POLICY=enabled \ - USE_CALICO_CNI=false \ - LAGOON_SSH_PORTAL_LOADBALANCER=$(LAGOON_SSH_PORTAL_LOADBALANCER) \ - LAGOON_FEATURE_FLAG_DEFAULT_ROOTLESS_WORKLOAD=enabled + && $(MAKE) k3d/push-images JQ=$(JQ) HELM=$(HELM) KUBECTL=$(KUBECTL) +endif + export KUBECONFIG="$$(realpath kubeconfig.k3d.$(CI_BUILD_TAG))" \ + && export IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ + && cd lagoon-charts.k3d.lagoon \ + && $(MAKE) install-lagoon DOCKER_NETWORK=$(DOCKER_NETWORK) TESTS=$(TESTS) IMAGE_TAG=$(SAFE_BRANCH_NAME) DISABLE_CORE_HARBOR=true \ + HELM=$(HELM) KUBECTL=$(KUBECTL) JQ=$(JQ) \ + OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:${BUILD_DEPLOY_IMAGE_TAG} \ + $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG)') \ + $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY)') \ + OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library/task-activestandby:$(SAFE_BRANCH_NAME)" \ + IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ + SKIP_INSTALL_REGISTRY=true \ + LAGOON_FEATURE_FLAG_DEFAULT_ISOLATION_NETWORK_POLICY=enabled \ + USE_CALICO_CNI=false \ + LAGOON_SSH_PORTAL_LOADBALANCER=$(LAGOON_SSH_PORTAL_LOADBALANCER) \ + LAGOON_FEATURE_FLAG_DEFAULT_ROOTLESS_WORKLOAD=enabled \ + $$([ $(INSTALL_STABLE_CORE) ] && echo 'INSTALL_STABLE_CORE=$(INSTALL_STABLE_CORE)') \ + $$([ $(INSTALL_STABLE_REMOTE) ] && echo 'INSTALL_STABLE_REMOTE=$(INSTALL_STABLE_REMOTE)') \ + $$([ $(INSTALL_STABLE_BUILDDEPLOY) ] && echo 'INSTALL_STABLE_BUILDDEPLOY=$(INSTALL_STABLE_BUILDDEPLOY)') \ + $$([ $(STABLE_CORE_CHART_VERSION) ] && echo 'STABLE_CORE_CHART_VERSION=$(STABLE_CORE_CHART_VERSION)') \ + $$([ $(STABLE_REMOTE_CHART_VERSION) ] && echo 'STABLE_REMOTE_CHART_VERSION=$(STABLE_REMOTE_CHART_VERSION)') \ + $$([ $(STABLE_BUILDDEPLOY_CHART_VERSION) ] && echo 'STABLE_BUILDDEPLOY_CHART_VERSION=$(STABLE_BUILDDEPLOY_CHART_VERSION)') \ + $$([ $(INSTALL_MARIADB_PROVIDER) ] && echo 'INSTALL_MARIADB_PROVIDER=$(INSTALL_MARIADB_PROVIDER)') \ + $$([ $(INSTALL_POSTGRES_PROVIDER) ] && echo 'INSTALL_POSTGRES_PROVIDER=$(INSTALL_POSTGRES_PROVIDER)') \ + $$([ $(INSTALL_MONGODB_PROVIDER) ] && echo 'INSTALL_MONGODB_PROVIDER=$(INSTALL_MONGODB_PROVIDER)') # k3d/local-stack will deploy and seed a lagoon-core with a lagoon-remote and all basic services to get you going # and will provide some initial seed data for a user to jump right in and start using lagoon .PHONY: k3d/local-stack -k3d/local-stack: k3d/setup k3d/seed-data k3d/get-lagoon-details +k3d/local-stack: k3d/setup k3d/install-lagoon k3d/seed-data k3d/get-lagoon-details # k3d/local-dev-patch will build the services in LOCAL_DEV_SERVICES on your machine, and then use kubectl patch to mount the folders into Kubernetes # the deployments should be restarted to trigger any updated code changes @@ -639,23 +696,7 @@ k3d/local-dev-logging: && echo -e 'You will need to create a default index at http://0.0.0.0:5601/app/management/kibana/indexPatterns/create \n' \ && echo -e 'with a default `container-logs-*` pattern' -# k3d/dev can only be run once a cluster is up and running (run k3d/test first) - it doesn't rebuild the cluster at all, just pushes the built images -# into the image registry and reinstalls the lagoon-core helm chart. -.PHONY: k3d/dev -k3d/dev: build - @export KUBECONFIG="$$(realpath ./kubeconfig.k3d.$(CI_BUILD_TAG))" \ - && export IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ - && $(MAKE) k3d/push-images && cd lagoon-charts.k3d.lagoon \ - && $(MAKE) install-lagoon-core DOCKER_NETWORK=$(DOCKER_NETWORK) IMAGE_TAG=$(SAFE_BRANCH_NAME) DISABLE_CORE_HARBOR=true \ - HELM=$(HELM) KUBECTL=$(KUBECTL) \ - JQ=$(JQ) \ - OVERRIDE_BUILD_DEPLOY_DIND_IMAGE=uselagoon/build-deploy-image:${BUILD_DEPLOY_IMAGE_TAG} \ - $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGETAG)') \ - $$([ $(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY) ] && echo 'OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY=$(OVERRIDE_BUILD_DEPLOY_CONTROLLER_IMAGE_REPOSITORY)') \ - OVERRIDE_ACTIVE_STANDBY_TASK_IMAGE=$$IMAGE_REGISTRY/task-activestandby:$(SAFE_BRANCH_NAME) \ - LAGOON_SSH_PORTAL_LOADBALANCER=$(LAGOON_SSH_PORTAL_LOADBALANCER) \ - IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" - @$(MAKE) k3d/get-lagoon-details + # k3d/push-images pushes locally build images into the k3d cluster registry. IMAGES = $(K3D_SERVICES) $(LOCAL_DEV_SERVICES) $(TASK_IMAGES) @@ -749,6 +790,8 @@ k3d/port-forwards: .PHONY: k3d/retest k3d/retest: export KUBECONFIG="$$(pwd)/kubeconfig.k3d.$(CI_BUILD_TAG)" \ + && $(MAKE) build/tests \ + && $(MAKE) k3d/push-images JQ=$(JQ) HELM=$(HELM) KUBECTL=$(KUBECTL) IMAGES=[tests] \ && cd lagoon-charts.k3d.lagoon \ && export IMAGE_REGISTRY="registry.$$($(KUBECTL) -n ingress-nginx get services ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}').nip.io/library" \ && $(MAKE) fill-test-ci-values DOCKER_NETWORK=$(DOCKER_NETWORK) TESTS=$(TESTS) IMAGE_TAG=$(SAFE_BRANCH_NAME) DISABLE_CORE_HARBOR=true \ diff --git a/docs/contributing-to-lagoon/developing-lagoon.md b/docs/contributing-to-lagoon/developing-lagoon.md index 94b80167d4..d5afec9d78 100644 --- a/docs/contributing-to-lagoon/developing-lagoon.md +++ b/docs/contributing-to-lagoon/developing-lagoon.md @@ -73,20 +73,105 @@ make -j8 build The make file offers a command that allows you to spin up Lagoon inside of a k3d cluster locally and explore its functionality. -Using the following make command will create a k3d cluster, install Lagoon and all of the necessary components to get you up and running and ready to explore. +Using the following make command will create a k3d cluster and install any dependencies (ingress, harbor, s3 compatible storage, etc) that are required by Lagoon. It will then build any images required and push them to the registry, and install `lagoon-core`, `lagoon-remote`, and `lagoon-build-deploy` charts. ```bash title="Deploy local stack" make k3d/local-stack ``` +!!! warning + Once you have a running `make k3d/local-stack` you should not run it again. There are other targets that can be run safely after the initial stack is running. + +At the end of the process, the command will provide some useful information that will help to get you up and running and able to log in to the UI or using the API with tools like the Lagoon CLI. + !!! warning This can take some time to complete as it will install a lot of components necessary to make Lagoon work. This includes things like ingress-nginx, harbor, and all the additional services to make exploring Lagoon easy. -At the end of the process, the command will provide some useful information that will get you up and running and able to log in to the UI or using the API with tools like the Lagoon CLI. + +### Local stack setup options + +There are a number of variables that can be used with `make k3d/local-stack` that can enable or disable certain options when setting up the initial cluster. + +#### DBaaS providers + +There are some Database as a Service (DBaaS) providers that are installed by default, to speed up time with a local stack, or for compatability reasons, you can disable them individually. + +```bash title="Deploy local stack without specific provider" +# disable all of them +make k3d/local-stack INSTALL_DBAAS_PROVIDERS=false + +# just disable mongodb +make k3d/local-stack INSTALL_MONGODB_PROVIDER=false +# just disable mariadb +make k3d/local-stack INSTALL_MARIADB_PROVIDER=false +# just disable postgres +make k3d/local-stack INSTALL_POSTGRES_PROVIDER=false +# other combinations as needed +make k3d/local-stack INSTALL_POSTGRES_PROVIDER=false INSTALL_MONGODB_PROVIDER=false +``` + +!!! info + If you're using an arm64 based operating system (MacOS M* for example), then `INSTALL_MONGODB_PROVIDER` will always be set to `false`, this is because there are some issues due to MongoDB not working properly. + +#### Stable chart installation and upgrading chart versions + +It is possible to run the local-stack as it would be directly from a stable chart version. + +This can be useful if you want to get a Lagoon up and running without having to build all the service images. + +Using this feature also allows for upgrading from a stable chart version to a feature chart. + +##### All stable components + +This will install lagoon-core, lagoon-remote, and lagoon-build-deploy charts with their current stable versions + +```bash title="Deploy local stack with stable core, remote, build-deploy" +make k3d/local-stack INSTALL_STABLE_LAGOON=true +``` + +##### Specific stable components + +It's also possible to selectively install certain components with a stable version. Anything not set to `true` will install the version from the charts repository. + +```bash title="Deploy local stack with stable versions" +make k3d/local-stack INSTALL_STABLE_CORE=true +make k3d/local-stack INSTALL_STABLE_REMOTE=true +make k3d/local-stack INSTALL_STABLE_BUILDDEPLOY=true +``` + +### Upgrading Lagoon components only + +Once you have a `k3d/local-stack` running, if you need to re-run the Lagoon installation to test an upgrade you can use the following target. + +```bash title="Install or upgrade all Lagoon components" +make k3d/install-lagoon +``` + +This can be used if you started an initial `local-stack` with stable chart versions. Running this without any of the `INSTALL_STABLE_X` flags, will build and install Lagoon with the versions of images in the current `uselagoon/lagoon` branch, and install using the charts from the repository listed under `CHARTS_REPOSITORY` and `CHARTS_TREEISH`. + +You can also retain any stable versions of other components if you wish, for example only installing the bleeding edge lagoon-core. This can be used to verify an upgrade path from a stable chart + +```bash title="Install all stable then upgrade Lagoon core only" +# install a local stack with all stable components +make k3d/local-stack INSTALL_STABLE_LAGOON=true + +# optionally checkout a new version of the charts branch if there are changes made +make k3d/checkout-charts + +# make changes to a lagoon service or the lagoon-core charts and re-install lagoon +make k3d/install-lagoon INSTALL_STABLE_REMOTE=true INSTALL_STABLE_BUILDDEPLOY=true +``` + +!!! warning + The upstream charts `CHARTS_REPOSITORY` and `CHARTS_TREEISH` are only checked out when the cluster is first created and installed. + If you make changes to the charts branch, you can use `make k3d/dev` to clone and checkout the latest changes. Otherwise the existing checked out chart branch would be used. `make k3d/dev` is a short cut to `make k3d/checkout-charts` and `make k3d/install-lagoon`, which can also be used independently. + +!!! warning + Starting a `make k3d/local-stack` without any stable versions, then using `make k3d/install-lagoon` with `INSTALL_STABLE_X` flags may result in a broken Lagoon installation, however, this can be useful for verifying any downgrade or rollback paths. ### Run the Lagoon test-suite -If you're developing new functionality in Lagoon and want to make sure the tests complete, you can run the entire test suite using the following options +If you're developing new functionality in Lagoon and want to make sure the tests complete, you can run the entire test suite using the following options. 1. Start Lagoon test routine using the defaults in the Makefile \(all tests\). @@ -164,7 +249,7 @@ make k3d/get-lagoon-cli-details #### Rebuild Lagoon core and push images -This will re-push the images listed in `KIND_SERVICES` with the correct tag, and redeploy the lagoon-core chart. This is useful for testing small changes to Lagoon services, but does not support "live" development. You will need to rebuild these images locally first, e.g `rm build/api && make build/api`. +This will checkout `CHARTS_REPOSITORY` and `CHARTS_TREEISH` again, then build and re-push the images listed in `KIND_SERVICES` with the correct tag, and redeploy the lagoon charts. This is useful for testing small changes to Lagoon services, but does not support "live" development. You will need to rebuild these images locally first, e.g `rm build/api && make build/api`. ```bash title="Re-push images" make k3d/dev @@ -222,6 +307,21 @@ This will remove the K3D Lagoon cluster from your local Docker. make k3d/clean ``` +##### Additional cleanup commands + +There could be a number of old resources hanging around after you've run the stack a few times, you can use the following to clean up further. + +```bash title="Cleanup commands" +# remove any unused generated kubeconfigs +make k3d/clean-k3dconfigs + +# remove any unused cloned chart directories +make k3d/clean-charts + +# combination of tear down, remove any unused cloned chart directories, and unused generated kubeconfigs +make k3d/clean-all +``` + ### Ansible The Lagoon test uses Ansible to run the test suite. Each range of tests for a specific function has been split into its own routine. If you are performing development work locally, select which tests to run, and update the `$TESTS` variable in the Makefile to reduce the concurrent tests running. @@ -329,3 +429,19 @@ make k3d/push-images IMAGES=tests ```bash title="Re-run tests" make k3d/retest TESTS=[features-variables] ``` + +### k3d internal DNS cluster service resolution issues + +If you encounter an issue whe running a local-stack that seems to indicate that the cluster can't resolve an internal service within the cluster, you may need to run +```bash title="br_netfilter" +sudo modprobe br_netfilter +``` + +### k3d containers reporting too many open files + +You may need to bump `fs.inotify.max_user_instances` and `fs.inotify.max_user_watches` + +```bash title="sysctl" +sudo sysctl fs.inotify.max_user_instances=8192 +sudo sysctl fs.inotify.max_user_watches=524288 +``` diff --git a/k3d.config.yaml.tpl b/k3d.config.yaml.tpl index ef5cba805b..dfa4a9a511 100644 --- a/k3d.config.yaml.tpl +++ b/k3d.config.yaml.tpl @@ -8,11 +8,14 @@ volumes: - volume: services:/lagoon/services - volume: node_packages:/lagoon/node-packages registries: + create: # pass through for k3d node to share images with the host + image: ligfx/k3d-registry-dockerd:v0.5 + proxy: + remoteURL: "*" + volumes: + - /var/run/docker.sock:/var/run/docker.sock config: | mirrors: - docker.io: - endpoint: - - "https://imagecache.amazeeio.cloud" "registry.${LAGOON_K3D_NETWORK}.nip.io": endpoint: - https://registry.${LAGOON_K3D_NETWORK}.nip.io diff --git a/local-dev/k3d-seed-data/00-populate-kubernetes.gql b/local-dev/k3d-seed-data/00-populate-kubernetes.gql index 6eeeff0e47..59d9924f18 100644 --- a/local-dev/k3d-seed-data/00-populate-kubernetes.gql +++ b/local-dev/k3d-seed-data/00-populate-kubernetes.gql @@ -79,29 +79,6 @@ mutation PopulateApi { id } - LagoonDemoGroup: addGroup( - input: { - name: "lagoon-demo-group" - } - ) { - id - } - - LagoonDemoToGroup: addGroupsToProject( - input: { - project: { - name: "lagoon-demo" - } - groups: [ - { - name: "lagoon-demo-group" - } - ] - } - ) { - id - } - UserExampleGuestGroup: addUserToGroup( input: { user: { @@ -433,6 +410,29 @@ mutation PopulateApi { id } + LagoonDemoGroup: addGroup( + input: { + name: "lagoon-demo-group" + } + ) { + id + } + + LagoonDemoToGroup: addGroupsToProject( + input: { + project: { + name: "lagoon-demo" + } + groups: [ + { + name: "lagoon-demo-group" + } + ] + } + ) { + id + } + # Add mailhub service UIProject1Envvar: addOrUpdateEnvVariableByName( input: {