cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: cartosnap
---
# libcluster's Kubernetes strategy lists the pods to find its peers; this
# ServiceAccount and Role grant just that.
apiVersion: v1
kind: ServiceAccount
metadata:
name: cartosnap
namespace: cartosnap
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: cartosnap-cluster
namespace: cartosnap
rules:
- apiGroups: [""]
resources: ["pods", "endpoints"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: cartosnap-cluster
namespace: cartosnap
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cartosnap-cluster
subjects:
- kind: ServiceAccount
name: cartosnap
namespace: cartosnap
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cartosnap
namespace: cartosnap
labels:
name: "cartosnap"
keel.sh/policy: force
keel.sh/trigger: poll
spec:
replicas: 2
selector:
matchLabels:
name: cartosnap
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
# `name` is what the selector above and libcluster's pod lookup match
# (it was missing, so the selector matched no pods); `app` is what the
# Services select.
labels:
name: cartosnap
app: cartosnap
annotations:
spec:
serviceAccountName: cartosnap
# Migrations run before the app starts, as the sibling apps do. The
# release's runtime.exs reads DATABASE_URL and SECRET_KEY_BASE even for
# `eval`, so the init container needs both.
initContainers:
- name: migrate
image: r.g.gmp.io/gmorell/cartosnap-ex:latest
imagePullPolicy: Always
command: ["/app/bin/migrate"]
env:
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: elixir-args
key: secret_key_base
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-auth
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-auth
key: password
- name: DATABASE_URL
value: ecto://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@postgres/csnap
containers:
- image: r.g.gmp.io/gmorell/cartosnap-ex:latest
imagePullPolicy: Always
env:
# - name: RAVEN_DSN
# valueFrom:
# secretKeyRef:
# name: wed4u-secrets
# key: sentrydsn
- name: PORT
value: "8080"
- name: PHX_HOST
value: cs.neiam.org
# Cluster glue: each pod becomes cartosnap_app@<pod ip>
# (rel/env.sh.eex), and libcluster finds the others through
# the Kubernetes API, so PubSub and Presence span replicas.
- name: POD_IP
valueFrom: { fieldRef: { fieldPath: status.podIP } }
- name: POD_NAMESPACE
valueFrom: { fieldRef: { fieldPath: metadata.namespace } }
- name: RELEASE_COOKIE
valueFrom:
secretKeyRef:
name: elixir-args
key: release_cookie
# Both ingress hosts may open the LiveView socket.
- name: PHX_ORIGINS
value: "//cs.neiam.org"
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: elixir-args
key: secret_key_base
- name: POSTGRES_HOST
value: postgres
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-auth
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-auth
key: password
- name: BUCKET_ID
valueFrom:
secretKeyRef:
name: bb-creds
key: bbid
- name: BUCKET_SECRET
valueFrom:
secretKeyRef:
name: bb-creds
key: bbkey
- name: BUCKET_NAME
value: cartosnap
- name: DATABASE_URL
value: ecto://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@postgres/csnap
name: cartosnap
ports:
- containerPort: 8080
imagePullSecrets:
- name: gitlabgmp
---
# Headless Service for the cluster: documents the Erlang distribution
# ports (epmd 4369, dist 9100, pinned in rel/env.sh.eex) for any
# NetworkPolicy. Distribution traffic goes pod IP to pod IP.
apiVersion: v1
kind: Service
metadata:
name: cartosnap-headless
namespace: cartosnap
spec:
clusterIP: None
# Unready pods included, so a new replica is found during a rolling deploy.
publishNotReadyAddresses: true
selector:
name: cartosnap
ports:
- { name: http, port: 8080, targetPort: 8080, protocol: TCP }
- { name: epmd, port: 4369, targetPort: 4369, protocol: TCP }
- { name: dist, port: 9100, targetPort: 9100, protocol: TCP }
---
apiVersion: v1
kind: Service
metadata:
name: cartosnap-svc
namespace: cartosnap
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: cartosnap
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cartosnap-ingress
namespace: cartosnap
annotations:
kubernetes.io/tls-acme: "true"
kubernetes.io/ingress.class: "nginx"
# The Android app posts full-size photos to /api/v1/photos (the web
# uploads over the LiveView socket, in chunks, so never hit this).
nginx.ingress.kubernetes.io/proxy-body-size: "64m"
nginx.ingress.kubernetes.io/proxy-read-timeout: "120"
nginx.ingress.kubernetes.io/proxy-send-timeout: "120"
spec:
tls:
- hosts:
- cs.neiam.org
secretName: cartosnap-tls
rules:
- host: cs.neiam.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: cartosnap-svc
port:
number: 80
EOF
neiam
/cartosnap_ex
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
6.3 KiB · text
History
1ba5ec3