From 1728b774461438da43cc023caa954378ce48b99d Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Tue, 19 Nov 2024 17:21:02 +0100 Subject: [PATCH] redirect smtp4dev port to localhost --- README.md | 25 ++++++++++++++----------- Tiltfile | 5 ++++- k8s_config/dev/mongodb/create_db.js | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 821dd1b..e95fe99 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Install Rancher Dektop or K3D or any other local Kubernetes. Make your Kubernete 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 +$ 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). @@ -27,12 +27,12 @@ See installation instructions here : https://docs.rancherdesktop.io/getting-star Install K3D : ``` -curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash +$ 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` : -``` +```/tmp/k3d.registry mirrors: docker.io: endpoint: @@ -42,7 +42,7 @@ mirrors: Create cluster : ``` -k3d cluster create devcluster -p "80:80@loadbalancer" --registry-create devregistry:5000 --registry-config /tmp/k3d-registry.yaml +$ k3d cluster create devcluster -p "80:80@loadbalancer" --registry-create devregistry:5000 --registry-config /tmp/k3d-registry.yaml ``` ### Install Tilt @@ -55,7 +55,7 @@ Create a .env file and configure environment For example, to set the source code directories (see default values in Tiltfile) : -``` +```.env PARCOURSMOB_DIR="../../coopgo-apps/parcoursmob" MOBILITY_ACCOUNTS_DIR="../../coopgo-platform/mobility-accounts" AGENDA_DIR="../../coopgo-platform/agenda" @@ -65,13 +65,13 @@ 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 : -``` +```.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. -``` +```.env PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob@v1.2 MOBILITY_ACCOUNTS_IMAGE=my.own.registry/coopgo-platform/mobility-accounts ... @@ -81,7 +81,7 @@ MOBILITY_ACCOUNTS_IMAGE=my.own.registry/coopgo-platform/mobility-accounts If you're using K3D, remove the registry part in the images (we'll use K3D local registry instead). It should look something like this : -``` +```.env PARCOURSMOB_IMAGE=coopgo-apps/parcoursmob MOBILITY_ACCOUNTS_IMAGE=coopgo-platform/mobility-accounts ... @@ -89,7 +89,7 @@ MOBILITY_ACCOUNTS_IMAGE=coopgo-platform/mobility-accounts Then, set the K8S config to the dedicated overlay in k8s_config : -``` +```.env K8S_CONFIG="k8s_config/k3d" ``` @@ -132,5 +132,8 @@ 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/ +By default, smtp4dev HTTP port is redirected to localhost:12345. You can change this with the dedicated environment variable in `.env` + +```.env +SMTP4DEV_LOCAL_PORT=12345 +``` diff --git a/Tiltfile b/Tiltfile index 86bdeb3..08fc0c5 100644 --- a/Tiltfile +++ b/Tiltfile @@ -18,9 +18,11 @@ 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') +k8s_config = os.environ.get('K8S_CONFIG', 'k8s_config/dev') +smtp4dev_local_port = os.environ.get("SMTP4DEV_LOCAL_PORT", '12345') + 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) @@ -66,4 +68,5 @@ if os.path.exists(groups_management_dir): deploy_go('groups-management', groups_management_dir, groups_management_image) k8s_yaml(kustomize(k8s_config)) +k8s_resource(workload='smtp4dev', port_forwards=smtp4dev_local_port+":80") diff --git a/k8s_config/dev/mongodb/create_db.js b/k8s_config/dev/mongodb/create_db.js index 17daddd..c9d2818 100644 --- a/k8s_config/dev/mongodb/create_db.js +++ b/k8s_config/dev/mongodb/create_db.js @@ -24,7 +24,7 @@ db.users.insert({ "first_name" : "Admin", "last_name" : "Parcoursmob", "phone_number" : "+33600000000", - "email" : "noreply@parcoursmob.fr", + "email" : "admin@parcoursmob.fr", "groups" : [ "483280d0-db2d-4f06-b361-02e4be5012d2", "483280d0-db2d-4f06-b361-02e4be5012d2:admin", @@ -54,4 +54,4 @@ db.groups.insert({ }, "name" : "COOPGO" } -}) \ No newline at end of file +})