diff --git a/Tiltfile b/Tiltfile index 88eba56a..38fb413f 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', 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/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..b942f7b1 --- /dev/null +++ b/deploy/kubernetes/dev/postfix/cm_postfix-mail_patch.yaml @@ -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 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 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`) 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