simplify deployment tooling
This commit is contained in:
+24
-11
@@ -8,19 +8,13 @@ generate:
|
||||
test:
|
||||
go test -json ./... | docker run -i ghcr.io/gotesttools/gotestfmt:latest
|
||||
|
||||
.PHONY: migrate-dev
|
||||
migrate-dev:
|
||||
./migrate_dev.sh
|
||||
|
||||
.PHONY: migrate-prod
|
||||
migrate-prod:
|
||||
./migrate_prod.sh
|
||||
|
||||
# ex: make create-migration ARG="create_users_table"
|
||||
create-migration:
|
||||
echo "Creating migration with name $(ARG)"
|
||||
docker run -v ./migrations:/migrations --network host migrate/migrate create -ext sql -seq -dir /migrations $(ARG)
|
||||
|
||||
# ---- Database access ----
|
||||
|
||||
dev-database:
|
||||
kubectl run postgres-client \
|
||||
--rm -it --image=postgres:latest \
|
||||
@@ -35,11 +29,30 @@ prod-database:
|
||||
--context prod \
|
||||
--command -- /bin/bash -c "psql \$$LLINK_POSTGRES_CONNECTION_URL"
|
||||
|
||||
# ---- Migrations ----
|
||||
# NOTE: if you run into issues with 'dirty' migrations: https://github.com/golang-migrate/migrate/issues/282#issuecomment-530743258
|
||||
|
||||
DEV_REPO := us-west2-docker.pkg.dev/flowy-dev-440017/deployments
|
||||
PROD_REPO := us-west2-docker.pkg.dev/flowy-prod-440017/deployments
|
||||
|
||||
.PHONY: migrate-dev
|
||||
migrate-dev:
|
||||
kubectl delete job migrations --ignore-not-found --context=dev
|
||||
SKAFFOLD_DEFAULT_REPO=$(DEV_REPO) skaffold run -p migrations --kube-context dev
|
||||
|
||||
.PHONY: migrate-prod
|
||||
migrate-prod:
|
||||
kubectl delete job migrations --ignore-not-found --context=prod
|
||||
SKAFFOLD_DEFAULT_REPO=$(PROD_REPO) skaffold run -p migrations --kube-context prod --tail
|
||||
|
||||
# ---- Deploy ----
|
||||
# Use MODULE=orion or MODULE=worker to deploy a single service, e.g.:
|
||||
# make deploy-dev MODULE=orion
|
||||
|
||||
.PHONY: deploy-dev
|
||||
deploy-dev: generate test
|
||||
./deploy_dev.sh
|
||||
SKAFFOLD_DEFAULT_REPO=$(DEV_REPO) skaffold run -p dev $(if $(MODULE),-m $(MODULE)) --kube-context dev --port-forward --tail
|
||||
|
||||
.PHONY: deploy-prod
|
||||
deploy-prod: generate test
|
||||
./deploy_prod.sh
|
||||
|
||||
SKAFFOLD_DEFAULT_REPO=$(PROD_REPO) skaffold run -p prod $(if $(MODULE),-m $(MODULE)) --kube-context prod --port-forward --tail
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Orion
|
||||
|
||||
API server and worker services for llink.
|
||||
|
||||
## Deploy
|
||||
|
||||
```bash
|
||||
# Deploy all services
|
||||
make deploy-dev
|
||||
make deploy-prod
|
||||
|
||||
# Deploy a single service
|
||||
make deploy-dev MODULE=orion
|
||||
make deploy-dev MODULE=worker
|
||||
```
|
||||
|
||||
## Migrations
|
||||
|
||||
```bash
|
||||
make migrate-dev
|
||||
make migrate-prod
|
||||
|
||||
# Create a new migration
|
||||
make create-migration ARG="create_users_table"
|
||||
```
|
||||
|
||||
## Database Access
|
||||
|
||||
```bash
|
||||
make dev-database
|
||||
make prod-database
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export KUBE_CONTEXT=dev
|
||||
export SKAFFOLD_DEFAULT_REPO=us-west2-docker.pkg.dev/flowy-dev-440017/deployments
|
||||
skaffold run -p dev --kube-context $KUBE_CONTEXT --port-forward --tail
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export KUBE_CONTEXT=prod
|
||||
export SKAFFOLD_DEFAULT_REPO=us-west2-docker.pkg.dev/flowy-prod-440017/deployments
|
||||
skaffold run -p prod --kube-context $KUBE_CONTEXT --port-forward --tail
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "# NOTE: if you run into issues with 'dirty' migrations: https://github.com/golang-migrate/migrate/issues/282#issuecomment-530743258"
|
||||
|
||||
export KUBE_CONTEXT=dev
|
||||
export SKAFFOLD_DEFAULT_REPO=us-west2-docker.pkg.dev/flowy-dev-440017/deployments
|
||||
kubectl delete job migrations --ignore-not-found --context=$KUBE_CONTEXT
|
||||
skaffold run -p migrations --kube-context $KUBE_CONTEXT
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "# NOTE: if you run into issues with 'dirty' migrations: https://github.com/golang-migrate/migrate/issues/282#issuecomment-530743258"
|
||||
|
||||
export KUBE_CONTEXT=prod
|
||||
export SKAFFOLD_DEFAULT_REPO=us-west2-docker.pkg.dev/flowy-prod-440017/deployments
|
||||
kubectl delete job migrations --ignore-not-found --context=$KUBE_CONTEXT
|
||||
skaffold run -p migrations --kube-context $KUBE_CONTEXT --tail
|
||||
|
||||
+45
-19
@@ -1,14 +1,12 @@
|
||||
apiVersion: skaffold/v4beta11
|
||||
kind: Config
|
||||
metadata:
|
||||
name: llink-services
|
||||
name: migrations
|
||||
build:
|
||||
local: {}
|
||||
tagPolicy:
|
||||
gitCommit:
|
||||
variant: AbbrevCommitSha
|
||||
|
||||
# NOTE: we use different profiles for a simpler mental model
|
||||
profiles:
|
||||
- name: migrations
|
||||
build:
|
||||
@@ -22,45 +20,73 @@ profiles:
|
||||
- k8s/migrations.yaml
|
||||
deploy:
|
||||
kubectl: {}
|
||||
|
||||
---
|
||||
apiVersion: skaffold/v4beta11
|
||||
kind: Config
|
||||
metadata:
|
||||
name: orion
|
||||
build:
|
||||
local: {}
|
||||
tagPolicy:
|
||||
gitCommit:
|
||||
variant: AbbrevCommitSha
|
||||
profiles:
|
||||
- name: dev
|
||||
build:
|
||||
hooks:
|
||||
before:
|
||||
# already run in make test
|
||||
# - command: ["go", "test", "./..."]
|
||||
artifacts:
|
||||
- image: orion
|
||||
context: .
|
||||
docker:
|
||||
dockerfile: Dockerfile
|
||||
- image: particleprocessorworker
|
||||
context: .
|
||||
docker:
|
||||
dockerfile: Dockerfile.particleprocessorworker
|
||||
manifests:
|
||||
rawYaml:
|
||||
- k8s/dev/*
|
||||
- k8s/dev/orion.yaml
|
||||
deploy:
|
||||
kubectl: {}
|
||||
|
||||
- name: prod
|
||||
build:
|
||||
hooks:
|
||||
before:
|
||||
# already run in make test
|
||||
# - command: ["go", "test", "./..."]
|
||||
artifacts:
|
||||
- image: orion
|
||||
context: .
|
||||
docker:
|
||||
dockerfile: Dockerfile
|
||||
manifests:
|
||||
rawYaml:
|
||||
- k8s/prod/orion.yaml
|
||||
deploy:
|
||||
kubectl: {}
|
||||
---
|
||||
apiVersion: skaffold/v4beta11
|
||||
kind: Config
|
||||
metadata:
|
||||
name: worker
|
||||
build:
|
||||
local: {}
|
||||
tagPolicy:
|
||||
gitCommit:
|
||||
variant: AbbrevCommitSha
|
||||
profiles:
|
||||
- name: dev
|
||||
build:
|
||||
artifacts:
|
||||
- image: particleprocessorworker
|
||||
context: .
|
||||
docker:
|
||||
dockerfile: Dockerfile.particleprocessorworker
|
||||
manifests:
|
||||
rawYaml:
|
||||
- k8s/prod/*
|
||||
- k8s/dev/particleprocessorworker.yaml
|
||||
deploy:
|
||||
kubectl: {}
|
||||
- name: prod
|
||||
build:
|
||||
artifacts:
|
||||
- image: particleprocessorworker
|
||||
context: .
|
||||
docker:
|
||||
dockerfile: Dockerfile.particleprocessorworker
|
||||
manifests:
|
||||
rawYaml:
|
||||
- k8s/prod/particleprocessorworker.yaml
|
||||
deploy:
|
||||
kubectl: {}
|
||||
|
||||
Reference in New Issue
Block a user