diff --git a/crates/collab/k8s b/crates/collab/k8s new file mode 120000 index 0000000000..21ce7e2abd --- /dev/null +++ b/crates/collab/k8s @@ -0,0 +1 @@ +../collab2/k8s \ No newline at end of file diff --git a/crates/collab/k8s/environments/production.sh b/crates/collab/k8s/environments/production.sh deleted file mode 100644 index cb1d4b4de7..0000000000 --- a/crates/collab/k8s/environments/production.sh +++ /dev/null @@ -1,4 +0,0 @@ -ZED_ENVIRONMENT=production -RUST_LOG=info -INVITE_LINK_PREFIX=https://zed.dev/invites/ -DATABASE_MAX_CONNECTIONS=85 diff --git a/crates/collab/k8s/environments/staging.sh b/crates/collab/k8s/environments/staging.sh deleted file mode 100644 index b9689ccb19..0000000000 --- a/crates/collab/k8s/environments/staging.sh +++ /dev/null @@ -1,4 +0,0 @@ -ZED_ENVIRONMENT=staging -RUST_LOG=info -INVITE_LINK_PREFIX=https://staging.zed.dev/invites/ -DATABASE_MAX_CONNECTIONS=5 diff --git a/crates/collab/k8s/manifest.template.yml b/crates/collab/k8s/manifest.template.yml deleted file mode 100644 index d4a7a7033e..0000000000 --- a/crates/collab/k8s/manifest.template.yml +++ /dev/null @@ -1,177 +0,0 @@ ---- -apiVersion: v1 -kind: Namespace -metadata: - name: ${ZED_KUBE_NAMESPACE} - ---- -kind: Service -apiVersion: v1 -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: collab - annotations: - service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443" - service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID} -spec: - type: LoadBalancer - selector: - app: collab - ports: - - name: web - protocol: TCP - port: 443 - targetPort: 8080 - ---- -kind: Service -apiVersion: v1 -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: pgadmin - annotations: - service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443" - service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID} -spec: - type: LoadBalancer - selector: - app: postgrest - ports: - - name: web - protocol: TCP - port: 443 - targetPort: 8080 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: collab - -spec: - replicas: 1 - selector: - matchLabels: - app: collab - template: - metadata: - labels: - app: collab - annotations: - ad.datadoghq.com/collab.check_names: | - ["openmetrics"] - ad.datadoghq.com/collab.init_configs: | - [{}] - ad.datadoghq.com/collab.instances: | - [ - { - "openmetrics_endpoint": "http://%%host%%:%%port%%/metrics", - "namespace": "collab_${ZED_KUBE_NAMESPACE}", - "metrics": [".*"] - } - ] - spec: - containers: - - name: collab - image: "${ZED_IMAGE_ID}" - args: - - serve - ports: - - containerPort: 8080 - protocol: TCP - livenessProbe: - httpGet: - path: /healthz - port: 8080 - initialDelaySeconds: 5 - periodSeconds: 5 - timeoutSeconds: 5 - readinessProbe: - httpGet: - path: / - port: 8080 - initialDelaySeconds: 1 - periodSeconds: 1 - env: - - name: HTTP_PORT - value: "8080" - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: database - key: url - - name: DATABASE_MAX_CONNECTIONS - value: "${DATABASE_MAX_CONNECTIONS}" - - name: API_TOKEN - valueFrom: - secretKeyRef: - name: api - key: token - - name: LIVE_KIT_SERVER - valueFrom: - secretKeyRef: - name: livekit - key: server - - name: LIVE_KIT_KEY - valueFrom: - secretKeyRef: - name: livekit - key: key - - name: LIVE_KIT_SECRET - valueFrom: - secretKeyRef: - name: livekit - key: secret - - name: INVITE_LINK_PREFIX - value: ${INVITE_LINK_PREFIX} - - name: RUST_BACKTRACE - value: "1" - - name: RUST_LOG - value: ${RUST_LOG} - - name: LOG_JSON - value: "true" - - name: ZED_ENVIRONMENT - value: ${ZED_ENVIRONMENT} - securityContext: - capabilities: - # FIXME - Switch to the more restrictive `PERFMON` capability. - # This capability isn't yet available in a stable version of Debian. - add: ["SYS_ADMIN"] - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: postgrest - -spec: - replicas: 1 - selector: - matchLabels: - app: postgrest - template: - metadata: - labels: - app: postgrest - spec: - containers: - - name: postgrest - image: "postgrest/postgrest" - ports: - - containerPort: 8080 - protocol: TCP - env: - - name: PGRST_SERVER_PORT - value: "8080" - - name: PGRST_DB_URI - valueFrom: - secretKeyRef: - name: database - key: url - - name: PGRST_JWT_SECRET - valueFrom: - secretKeyRef: - name: postgrest - key: jwt_secret diff --git a/crates/collab/k8s/migrate.template.yml b/crates/collab/k8s/migrate.template.yml deleted file mode 100644 index c890d7b330..0000000000 --- a/crates/collab/k8s/migrate.template.yml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: ${ZED_MIGRATE_JOB_NAME} -spec: - template: - spec: - restartPolicy: Never - containers: - - name: migrator - imagePullPolicy: Always - image: ${ZED_IMAGE_ID} - args: - - migrate - env: - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: database - key: url diff --git a/crates/collab2/k8s/manifest.template.yml b/crates/collab2/k8s/collab.template.yml similarity index 72% rename from crates/collab2/k8s/manifest.template.yml rename to crates/collab2/k8s/collab.template.yml index d4a7a7033e..e406bf4630 100644 --- a/crates/collab2/k8s/manifest.template.yml +++ b/crates/collab2/k8s/collab.template.yml @@ -23,25 +23,6 @@ spec: port: 443 targetPort: 8080 ---- -kind: Service -apiVersion: v1 -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: pgadmin - annotations: - service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443" - service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID} -spec: - type: LoadBalancer - selector: - app: postgrest - ports: - - name: web - protocol: TCP - port: 443 - targetPort: 8080 - --- apiVersion: apps/v1 kind: Deployment @@ -138,40 +119,3 @@ spec: # FIXME - Switch to the more restrictive `PERFMON` capability. # This capability isn't yet available in a stable version of Debian. add: ["SYS_ADMIN"] - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: ${ZED_KUBE_NAMESPACE} - name: postgrest - -spec: - replicas: 1 - selector: - matchLabels: - app: postgrest - template: - metadata: - labels: - app: postgrest - spec: - containers: - - name: postgrest - image: "postgrest/postgrest" - ports: - - containerPort: 8080 - protocol: TCP - env: - - name: PGRST_SERVER_PORT - value: "8080" - - name: PGRST_DB_URI - valueFrom: - secretKeyRef: - name: database - key: url - - name: PGRST_JWT_SECRET - valueFrom: - secretKeyRef: - name: postgrest - key: jwt_secret diff --git a/crates/collab/k8s/environments/preview.sh b/crates/collab2/k8s/environments/nightly.sh similarity index 78% rename from crates/collab/k8s/environments/preview.sh rename to crates/collab2/k8s/environments/nightly.sh index 132a1ef53c..49c562437b 100644 --- a/crates/collab/k8s/environments/preview.sh +++ b/crates/collab2/k8s/environments/nightly.sh @@ -1,4 +1,4 @@ -ZED_ENVIRONMENT=preview +ZED_ENVIRONMENT=nightly RUST_LOG=info INVITE_LINK_PREFIX=https://zed.dev/invites/ DATABASE_MAX_CONNECTIONS=10 diff --git a/crates/collab2/k8s/postgrest.template.yml b/crates/collab2/k8s/postgrest.template.yml new file mode 100644 index 0000000000..e2d11a2cd2 --- /dev/null +++ b/crates/collab2/k8s/postgrest.template.yml @@ -0,0 +1,55 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: ${ZED_KUBE_NAMESPACE} + name: postgrest + annotations: + service.beta.kubernetes.io/do-loadbalancer-tls-ports: "443" + service.beta.kubernetes.io/do-loadbalancer-certificate-id: ${ZED_DO_CERTIFICATE_ID} +spec: + type: LoadBalancer + selector: + app: postgrest + ports: + - name: web + protocol: TCP + port: 443 + targetPort: 8080 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: ${ZED_KUBE_NAMESPACE} + name: postgrest + +spec: + replicas: 1 + selector: + matchLabels: + app: postgrest + template: + metadata: + labels: + app: postgrest + spec: + containers: + - name: postgrest + image: "postgrest/postgrest" + ports: + - containerPort: 8080 + protocol: TCP + env: + - name: PGRST_SERVER_PORT + value: "8080" + - name: PGRST_DB_URI + valueFrom: + secretKeyRef: + name: database + key: url + - name: PGRST_JWT_SECRET + valueFrom: + secretKeyRef: + name: postgrest + key: jwt_secret diff --git a/script/deploy b/script/deploy-collab similarity index 76% rename from script/deploy rename to script/deploy-collab index b6da3f8f84..c5386298fa 100755 --- a/script/deploy +++ b/script/deploy-collab @@ -10,11 +10,6 @@ fi environment=$1 version=$2 -if [[ ${environment} == "nightly" ]]; then - echo "nightly is not yet supported" - exit 1 -fi - export_vars_for_environment ${environment} image_id=$(image_id_for_version ${version}) @@ -23,6 +18,6 @@ export ZED_KUBE_NAMESPACE=${environment} export ZED_IMAGE_ID=${image_id} target_zed_kube_cluster -envsubst < crates/collab/k8s/manifest.template.yml | kubectl apply -f - +envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f - echo "deployed collab v${version} to ${environment}" diff --git a/script/deploy-postgrest b/script/deploy-postgrest new file mode 100755 index 0000000000..f94a140274 --- /dev/null +++ b/script/deploy-postgrest @@ -0,0 +1,25 @@ +#!/bin/bash + +set -eu +source script/lib/deploy-helpers.sh + +if [[ $# < 1 ]]; then + echo "Usage: $0 (postgrest not needed on preview or nightly)" + exit 1 +fi +environment=$1 + +if [[ ${environment} == "preview" || ${environment} == "nightly" ]]; then + echo "website does not exist in preview or nightly" + exit 1 +fi + +export_vars_for_environment ${environment} + +export ZED_DO_CERTIFICATE_ID=$(doctl compute certificate list --format ID --no-header) +export ZED_KUBE_NAMESPACE=${environment} + +target_zed_kube_cluster +envsubst < crates/collab/k8s/postgrest.template.yml | kubectl apply -f - + +echo "deployed postgrest"