add sendgrid
This commit is contained in:
parent
d6a9bb11d7
commit
80cc5e937e
5 changed files with 80 additions and 21 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -38,3 +38,7 @@ npm-debug.log
|
|||
# Dialyzer PLT files
|
||||
/priv/plts/
|
||||
|
||||
# Environment variables (used by direnv and Kustomize secretGenerator)
|
||||
.envrc
|
||||
k8s/.envrc
|
||||
|
||||
|
|
|
|||
|
|
@ -59,27 +59,6 @@ if config_env() == :prod do
|
|||
]
|
||||
]
|
||||
|
||||
config :towerops, Towerops.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
# For machines with several cores, consider starting multiple pools of `pool_size`
|
||||
# pool_count: 4,
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
config :towerops, ToweropsWeb.Endpoint,
|
||||
url: [host: host, port: 443, scheme: "https"],
|
||||
http: [
|
||||
# Enable IPv6 and bind on all interfaces.
|
||||
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
|
||||
# See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
|
||||
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
|
||||
config :towerops, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
|
||||
# ## SSL Support
|
||||
#
|
||||
# To get SSL working, you will need to add the `https` key
|
||||
|
|
@ -129,4 +108,30 @@ if config_env() == :prod do
|
|||
# config :swoosh, :api_client, Swoosh.ApiClient.Req
|
||||
#
|
||||
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
|
||||
|
||||
# Configure SendGrid for production email
|
||||
config :towerops, Towerops.Mailer,
|
||||
adapter: Swoosh.Adapters.Sendgrid,
|
||||
api_key: System.get_env("SENDGRID_API_KEY")
|
||||
|
||||
config :towerops, Towerops.Repo,
|
||||
# ssl: true,
|
||||
url: database_url,
|
||||
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
|
||||
# For machines with several cores, consider starting multiple pools of `pool_size`
|
||||
# pool_count: 4,
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
config :towerops, ToweropsWeb.Endpoint,
|
||||
url: [host: host, port: 443, scheme: "https"],
|
||||
http: [
|
||||
# Enable IPv6 and bind on all interfaces.
|
||||
# Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
|
||||
# See the documentation on https://hexdocs.pm/bandit/Bandit.html#t:options/0
|
||||
# for details about using IPv6 vs IPv4 and loopback vs public addresses.
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
|
||||
config :towerops, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
end
|
||||
|
|
|
|||
38
k8s/README.md
Normal file
38
k8s/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Kubernetes Deployment
|
||||
|
||||
## Secrets Management
|
||||
|
||||
Secrets are stored in `.envrc` files (gitignored):
|
||||
- Project root `.envrc` - Used by direnv for local development
|
||||
- `k8s/.envrc` - Used by Kustomize for secret generation
|
||||
|
||||
Kustomize automatically generates the `towerops-sendgrid` Secret from `k8s/.envrc` using the `secretGenerator` in `kustomization.yaml`.
|
||||
|
||||
Both `.envrc` files should contain:
|
||||
```bash
|
||||
# SendGrid Configuration
|
||||
SENDGRID_API_KEY=your-api-key-here
|
||||
export SENDGRID_API_KEY
|
||||
```
|
||||
|
||||
The KEY=VALUE format works for both Kustomize and direnv.
|
||||
|
||||
## Deploying
|
||||
|
||||
Apply all resources using kustomize:
|
||||
|
||||
```bash
|
||||
kubectl apply -k k8s/
|
||||
```
|
||||
|
||||
Or individually:
|
||||
|
||||
```bash
|
||||
kubectl apply -f k8s/namespace.yaml
|
||||
kubectl apply -f k8s/secret.yaml
|
||||
kubectl apply -f k8s/deployment.yaml
|
||||
kubectl apply -f k8s/service.yaml
|
||||
kubectl apply -f k8s/service-headless.yaml
|
||||
kubectl apply -f k8s/certificate.yaml
|
||||
kubectl apply -f k8s/ingressroute.yaml
|
||||
```
|
||||
|
|
@ -60,6 +60,11 @@ spec:
|
|||
secretKeyRef:
|
||||
name: towerops-secrets
|
||||
key: SECRET_KEY_BASE
|
||||
- name: SENDGRID_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: towerops-sendgrid
|
||||
key: SENDGRID_API_KEY
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: towerops-db
|
||||
|
|
|
|||
|
|
@ -8,3 +8,10 @@ resources:
|
|||
- service-headless.yaml
|
||||
- certificate.yaml
|
||||
- ingressroute.yaml
|
||||
|
||||
secretGenerator:
|
||||
- name: towerops-sendgrid
|
||||
envs:
|
||||
- .envrc
|
||||
options:
|
||||
disableNameSuffixHash: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue