From c7b8d4b9965cb0dfb82e15f4568cb589977e8ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20Lex-Hammarskj=C3=B6ld?= <33381901+JustinLex@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:12:25 +0200 Subject: [PATCH 1/3] docs: Fix invalid command in docs --- docs/howto-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/howto-dev.md b/docs/howto-dev.md index c6695d79..6522f40b 100644 --- a/docs/howto-dev.md +++ b/docs/howto-dev.md @@ -84,7 +84,7 @@ Tilt is made by Docker, inc. and is very useful for doing development in contain 3. [Kubectl install instructions](https://kubernetes.io/docs/tasks/tools/) 4. [Kind install instructions](https://kind.sigs.k8s.io/docs/user/quick-start) 2. Start your Kubernetes cluster - 1. Run `kind create-cluster --wait 5m` to create your Kubernetes cluster. It should take a minute or two to download everything and start the cluster. + 1. Run `kind create cluster --wait 5m` to create your Kubernetes cluster. It should take a minute or two to download everything and start the cluster. 2. Verify that your cluster is working by running `kubectl version`. You can also run `kubectl get pods -A` to see all containers running in Kubernetes. (Note that all of Kubernetes and its running containers are all running in a Docker container named kindest/node) 3. Start your development environment 1. cd into the root directory for this git repo (e.g. `cd ~/IdeaProjects/tmeit-website`) From 5fcc1655cc0bfb8932edb5013199a2ab95399a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20Lex-Hammarskj=C3=B6ld?= <33381901+JustinLex@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:13:26 +0200 Subject: [PATCH 2/3] feat: Send all mail to dummy inbox in dev environent --- Tiltfile | 1 + deploy/kubernetes/dev/postfix/README.md | 6 ++++ .../dev/postfix/cm_postfix-mail_patch.yaml | 8 +++++ .../kubernetes/dev/postfix/kustomization.yaml | 12 +++++++ deploy/kubernetes/dev/postfix/mailhog.yaml | 36 +++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 deploy/kubernetes/dev/postfix/README.md create mode 100644 deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml create mode 100644 deploy/kubernetes/dev/postfix/kustomization.yaml create mode 100644 deploy/kubernetes/dev/postfix/mailhog.yaml diff --git a/Tiltfile b/Tiltfile index 88eba56a..80caf15a 100644 --- a/Tiltfile +++ b/Tiltfile @@ -28,5 +28,6 @@ k8s_yaml(kustomize('deploy/kubernetes/dev')) k8s_resource('tmeit-app', port_forwards="8080:8080") k8s_resource('tmeit-app-test') k8s_resource('tmeit-worker') +k8s_resource('mailhog') k8s_resource(new_name='tmeit-db', objects=['tmeit-db:Kubegres'], extra_pod_selectors={'app': 'tmeit-db'}) local_resource('db-port-forward', serve_cmd='kubectl port-forward svc/tmeit-db 5432:5432') diff --git a/deploy/kubernetes/dev/postfix/README.md b/deploy/kubernetes/dev/postfix/README.md new file mode 100644 index 00000000..3808168e --- /dev/null +++ b/deploy/kubernetes/dev/postfix/README.md @@ -0,0 +1,6 @@ +# deploy/dev/postfix/ + +This directory contains an override for postfix in the dev environment to divert all outgoing email to Mailhog. + +All email sent in the dev environment ends up in mailhog instead of actually getting sent. +Mailhog allows you to debug what the email looks like after it's sent. diff --git a/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml b/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml new file mode 100644 index 00000000..9fc8cbc9 --- /dev/null +++ b/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml @@ -0,0 +1,8 @@ +# Patches the Postfix config so that it redirects all outgoing mail to mailhog. +# https://xy2z.io/posts/2018-setup-mailhog-inside-docker-through-postfix/ +# https://hub.docker.com/r/boky/postfix/ +# https://kubectl.docs.kubernetes.io/guides/config_management/components/ +- op: add + path: /data + value: + RELAYHOST: mailhog:1025 diff --git a/deploy/kubernetes/dev/postfix/kustomization.yaml b/deploy/kubernetes/dev/postfix/kustomization.yaml new file mode 100644 index 00000000..6c7f5991 --- /dev/null +++ b/deploy/kubernetes/dev/postfix/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - mailhog.yaml + +patchesJson6902: + - target: + version: v1 + kind: ConfigMap + name: postfix-mail + path: cm_postfix-mail_patch.yaml diff --git a/deploy/kubernetes/dev/postfix/mailhog.yaml b/deploy/kubernetes/dev/postfix/mailhog.yaml new file mode 100644 index 00000000..4585505a --- /dev/null +++ b/deploy/kubernetes/dev/postfix/mailhog.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mailhog + labels: + app: mailhog +spec: + replicas: 1 + selector: + matchLabels: + app: mailhog + template: + metadata: + labels: + app: mailhog + spec: + containers: + - name: mailhog + image: "docker.io/mailhog/mailhog:latest" + ports: + - name: http + containerPort: 8025 + - name: smtp + containerPort: 1025 +--- +apiVersion: v1 +kind: Service +metadata: + name: mailhog + labels: + app: mailhog +spec: + ports: + - port: 1025 + selector: + app: mailhog From e895ab6ec9f1c1d20dc012777ff8c5dfbe6db1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Justin=20Lex-Hammarskj=C3=B6ld?= <33381901+JustinLex@users.noreply.github.com> Date: Fri, 4 Aug 2023 19:08:43 +0200 Subject: [PATCH 3/3] fix: mailhog connection --- Tiltfile | 2 +- deploy/kubernetes/dev/kustomization.yaml | 10 +++++++--- .../dev/postfix/cm_postfix-mail_patch.yaml | 5 ++--- deploy/kubernetes/dev/postfix/kustomization.yaml | 12 ------------ tilt_options.json | 4 ---- 5 files changed, 10 insertions(+), 23 deletions(-) delete mode 100644 deploy/kubernetes/dev/postfix/kustomization.yaml delete mode 100644 tilt_options.json diff --git a/Tiltfile b/Tiltfile index 80caf15a..38fb413f 100644 --- a/Tiltfile +++ b/Tiltfile @@ -28,6 +28,6 @@ k8s_yaml(kustomize('deploy/kubernetes/dev')) k8s_resource('tmeit-app', port_forwards="8080:8080") k8s_resource('tmeit-app-test') k8s_resource('tmeit-worker') -k8s_resource('mailhog') +k8s_resource('mailhog', port_forwards="8025:8025") k8s_resource(new_name='tmeit-db', objects=['tmeit-db:Kubegres'], extra_pod_selectors={'app': 'tmeit-db'}) local_resource('db-port-forward', serve_cmd='kubectl port-forward svc/tmeit-db 5432:5432') diff --git a/deploy/kubernetes/dev/kustomization.yaml b/deploy/kubernetes/dev/kustomization.yaml index cebe5c39..b8cc56cf 100644 --- a/deploy/kubernetes/dev/kustomization.yaml +++ b/deploy/kubernetes/dev/kustomization.yaml @@ -1,14 +1,18 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -bases: - - ../base - resources: +- ../base - tmeit-app/test-job.yaml - create-test-db/job.yaml +- postfix/mailhog.yaml patchesJson6902: + - target: + version: v1 + kind: ConfigMap + name: postfix-mail + path: postfix/cm_postfix-mail_patch.yaml - target: group: apps version: v1 diff --git a/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml b/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml index 9fc8cbc9..b942f7b1 100644 --- a/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml +++ b/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml @@ -3,6 +3,5 @@ # https://hub.docker.com/r/boky/postfix/ # https://kubectl.docs.kubernetes.io/guides/config_management/components/ - op: add - path: /data - value: - RELAYHOST: mailhog:1025 + path: /data/RELAYHOST + value: mailhog.default.svc.cluster.local:1025 diff --git a/deploy/kubernetes/dev/postfix/kustomization.yaml b/deploy/kubernetes/dev/postfix/kustomization.yaml deleted file mode 100644 index 6c7f5991..00000000 --- a/deploy/kubernetes/dev/postfix/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - mailhog.yaml - -patchesJson6902: - - target: - version: v1 - kind: ConfigMap - name: postfix-mail - path: cm_postfix-mail_patch.yaml diff --git a/tilt_options.json b/tilt_options.json deleted file mode 100644 index f0f27d98..00000000 --- a/tilt_options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "default_registry": "registry.jlh.name/tmeit-app", - "allow_k8s_contexts": "tmeit-dev/jlh-home-remote" -} \ No newline at end of file