Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Mailhog for local email testing #219

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -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', 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')
10 changes: 7 additions & 3 deletions deploy/kubernetes/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions deploy/kubernetes/dev/postfix/README.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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/RELAYHOST
value: mailhog.default.svc.cluster.local:1025
36 changes: 36 additions & 0 deletions deploy/kubernetes/dev/postfix/mailhog.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion docs/howto-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
4 changes: 0 additions & 4 deletions tilt_options.json

This file was deleted.