From f97c8812fae5e8f6714e71f05c115c23e7b20ff6 Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Mon, 18 Nov 2024 12:00:49 +0100 Subject: [PATCH] Add K3D instructions --- README.md | 57 ++++++++++++++++++++++++++++--- Tiltfile | 11 ++---- k8s_config/k3d/kustomization.yaml | 12 +++++++ 3 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 k8s_config/k3d/kustomization.yaml diff --git a/README.md b/README.md index 81c56b1..16c5c6e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,41 @@ Tested with Rancher Desktop. 1. Install Rancher Dektop or K3D or any other local Kubernetes. Make your Kubernetes context point to this cluster +Later, we will be using port 80 to access the cluster Ingress controller. On Linux, you must probably allow this. + +``` +sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80 +``` + +To preserve this change across reboots as a custom kernel parameter setting, add the same command inside your /etc/sysctl.conf file (or a dedicated /etc/sysctl.d/xxxxx.conf). + +### Rancher Desktop + +See installation instructions here : https://docs.rancherdesktop.io/getting-started/installation + +### K3D + +Install K3D : + +``` +curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash +``` + +Create config for the internal K3D registry to mirror your default docker images registry, for example in `/tmp/k3d-registry.yaml` : + +``` +mirrors: + docker.io: + endpoint: + - "git.coopgo.io" +``` + +Create cluster : + +``` +k3d cluster create devcluster -p "80:80@loadbalancer" --registry-create devregistry:5000 --registry-config /tmp/k3d-registry.yaml +``` + 2. [Install Tilt](https://docs.tilt.dev/install.html) 3. Create a .env file and configure environment @@ -24,18 +59,32 @@ GROUPS_MANAGEMENT_DIR="../../coopgo-platform/groups-management" To avoid developing on another cluster than the one dedicated for dev, we whitelist the correct context. By default, the allowed context is 'rancher-desktop'. To change this, set ALLOWED_K8S_CONTEXT to the correct context name in .env : -``` +``` ALLOWED_K8S_CONTEXT="k3d-devcluster" ``` You might also want to set the default container images used if/while your local source code folder doesn't exist. -``` -PARCOURSMOB_IMAGE=my.own.registry/coopgo-platform/parcoursmob@v1.2 +``` +PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob@v1.2 MOBILITY_ACCOUNTS_IMAGE=my.own.registry/coopgo-platform/mobility-accounts ... ``` +If you're using K3D, remove the registry part. It should look something like this : + +``` +PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob +MOBILITY_ACCOUNTS_IMAGE=coopgo-platform/mobility-accounts +... +``` + +If using K3D again, set the K8S config to the dedicated overlay in k8s_config : + +``` +K8S_CONFIG="k8s_config/k3d" +``` + 4. Add `tilt-dev.svc.cluster.local parcoursmob.tilt-dev.svc.cluster.local mobility-accounts.tilt-dev.svc.cluster.local` to resolve `127.0.0.1` in your hosts config (`/etc/hosts` on Linux) 5. Run `tilt up` @@ -74,4 +123,4 @@ Tilt handles livereloading Kubernetes pods when something changes in the code. Y Access smtp4dev to check outgoing emails : 1. Forward smtp4dev service locally : kubectl port-forward svc/smtp4dev 9090:80 -2. Access UI : http://localhost:9090/ \ No newline at end of file +2. Access UI : http://localhost:9090/ diff --git a/Tiltfile b/Tiltfile index 32e7f57..86bdeb3 100644 --- a/Tiltfile +++ b/Tiltfile @@ -5,13 +5,6 @@ dotenv() allowed_k8s_context = os.environ.get('ALLOWED_K8S_CONTEXT', 'rancher-desktop') -# parcoursmob_dir = os.path.realpath(os.environ.get('PARCOURSMOB_DIR', 'src/parcoursmob')) -# parcoursmob_theme_dir = os.path.realpath(os.environ.get('PARCOURSMOB_THEME_DIR', 'src/parcoursmob/themes/default')) -# mobility_accounts_dir = os.path.realpath(os.environ.get('MOBILITY_ACCOUNTS_DIR', 'src/mobility-accounts')) -# agenda_dir = os.path.realpath(os.environ.get('AGENDA_DIR', 'src/agenda')) -# fleets_dir = os.path.realpath(os.environ.get('FLEETS_DIR', 'src/fleets')) -# groups_management_dir = os.path.realpath(os.environ.get('GROUPS_MANAGEMENT_DIR', 'src/groups-management')) - parcoursmob_dir = os.environ.get('PARCOURSMOB_DIR', 'src/parcoursmob') parcoursmob_theme_dir = os.environ.get('PARCOURSMOB_THEME_DIR', 'src/parcoursmob/themes/default') mobility_accounts_dir = os.environ.get('MOBILITY_ACCOUNTS_DIR', 'src/mobility-accounts') @@ -25,9 +18,9 @@ agenda_image = os.environ.get('AGENDA_IMAGE', 'git.coopgo.io/coopgo-platform/age fleets_image = os.environ.get('FLEETS_IMAGE', 'git.coopgo.io/coopgo-platform/fleets') groups_management_image = os.environ.get('GROUPS_MANAGEMENT_IMAGE', 'git.coopgo.io/coopgo-platform/groups-management') - allow_k8s_contexts(allowed_k8s_context) +k8s_config = os.environ.get('K8S_CONFIG', 'k8s_config/dev') if os.path.exists(parcoursmob_dir) and os.path.exists(parcoursmob_theme_dir): parcoursmob_dir = os.path.realpath(parcoursmob_dir) @@ -72,5 +65,5 @@ if os.path.exists(groups_management_dir): print("Directory : {dir}".format(dir=groups_management_dir)) deploy_go('groups-management', groups_management_dir, groups_management_image) -k8s_yaml(kustomize('k8s_config/dev')) +k8s_yaml(kustomize(k8s_config)) diff --git a/k8s_config/k3d/kustomization.yaml b/k8s_config/k3d/kustomization.yaml new file mode 100644 index 0000000..9674c54 --- /dev/null +++ b/k8s_config/k3d/kustomization.yaml @@ -0,0 +1,12 @@ +resources: + - ../dev/ + +images: + - name: git.coopgo.io/coopgo-apps/parcoursmob + newName: "coopgo-apps/parcoursmob" + - name: git.coopgo.io/coopgo-platform/mobility-accounts + newName: "coopgo-platform/mobility-accounts" + - name: git.coopgo.io/coopgo-platform/fleets + newName: "coopgo-platform/fleets" + - name: git.coopgo.io/coopgo-platform/agenda + newName: "coopgo-platform/agenda"