generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a duplicate of the kustomize deployment, and should be equivalent. This will be a first step towards enabling Helm adoption for deployment to non local k8s
- Loading branch information
1 parent
1b14365
commit e17e4ce
Showing
8 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v2 | ||
name: ftl | ||
description: A Helm chart for FTL | ||
|
||
type: application | ||
|
||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Apply Helm to K3D | ||
|
||
Create a K3D cluster: | ||
``` | ||
k3d registry create registry.localhost --port 5000 | ||
k3d cluster create --api-port 6550 -p "8892:80@loadbalancer" --agents 2 \ | ||
--registry-use k3d-registry.localhost:5000 \ | ||
--registry-config <(cat <<EOF | ||
mirrors: | ||
"localhost:5000": | ||
endpoint: | ||
- http://k3d-registry.localhost:5000 | ||
EOF | ||
) | ||
``` | ||
|
||
As kubegres does not have Helm Charts, for now the CRDs need to be added manually. | ||
|
||
```bash | ||
kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.16/kubegres.yaml | ||
``` | ||
|
||
Once that is done the Helm Charts can be installed | ||
```bash | ||
helm install ftl . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../backend/controller/internal/sql/schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ftl-db-migrate | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: ftl-db-migrate | ||
image: "ghcr.io/amacneil/dbmate:latest" | ||
command: ["dbmate", "up"] | ||
env: | ||
- name: DATABASE_URL | ||
value: "postgres://postgres:secret@ftl-pg-cluster/ftl?sslmode=disable" | ||
- name: DBMATE_MIGRATIONS_DIR | ||
value: /etc/ftl-migrations | ||
volumeMounts: | ||
- name: ftl-db-migrate-config | ||
mountPath: /etc/ftl-migrations | ||
restartPolicy: OnFailure | ||
volumes: | ||
- name: ftl-db-migrate-config | ||
configMap: | ||
name: ftl-db-migrate-config | ||
parallelism: 1 | ||
backoffLimit: 1000 | ||
ttlSecondsAfterFinished: 300 | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ftl-db-migrate-config | ||
data: | ||
{{- $files := .Files }} | ||
{{- range tuple "001_init.sql" }} | ||
{{ . }}: |- | ||
{{ $files.Get (printf "schema/%s" .) | nindent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ftl-controller | ||
labels: | ||
app: ftl-controller | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: ftl-controller | ||
template: | ||
metadata: | ||
labels: | ||
app: ftl-controller | ||
spec: | ||
containers: | ||
- name: app | ||
image: "{{ .Values.ftlController.image }}:{{ .Values.ftlController.tag }}" | ||
env: | ||
- name: MY_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
- name: FTL_CONTROLLER_DSN | ||
value: "postgres://ftl-pg-cluster/ftl?sslmode=disable&user=postgres&password=secret" | ||
- name: FTL_CONTROLLER_BIND | ||
value: "http://$(MY_POD_IP):8892" | ||
- name: FTL_CONTROLLER_ADVERTISE | ||
value: "" | ||
ports: | ||
- containerPort: 8892 | ||
readinessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8892 | ||
initialDelaySeconds: 1 | ||
periodSeconds: 2 | ||
timeoutSeconds: 2 | ||
successThreshold: 1 | ||
failureThreshold: 15 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: ftl-controller | ||
name: ftl-controller | ||
spec: | ||
ports: | ||
- name: 80-8892 | ||
port: 80 | ||
protocol: TCP | ||
targetPort: 8892 | ||
selector: | ||
app: ftl-controller | ||
type: ClusterIP | ||
#--- | ||
#apiVersion: autoscaling/v2 | ||
#kind: HorizontalPodAutoscaler | ||
#metadata: | ||
# name: ftl-controller | ||
#spec: | ||
# scaleTargetRef: | ||
# apiVersion: apps/v1 | ||
# kind: Deployment | ||
# name: ftl-controller | ||
# minReplicas: 1 | ||
# maxReplicas: 10 | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: ftl-controller | ||
annotations: | ||
ingress.kubernetes.io/ssl-redirect: "false" | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: ftl-controller | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ftl-runner | ||
labels: | ||
app: ftl-runner | ||
spec: | ||
replicas: 10 | ||
selector: | ||
matchLabels: | ||
app: ftl-runner | ||
template: | ||
metadata: | ||
labels: | ||
app: ftl-runner | ||
spec: | ||
containers: | ||
- name: app | ||
image: "{{ .Values.ftlRunner.image }}:{{ .Values.ftlRunner.tag }}" | ||
env: | ||
- name: MY_POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
- name: FTL_ENDPOINT | ||
value: http://ftl-controller | ||
- name: FTL_RUNNER_BIND | ||
value: "http://$(MY_POD_IP):8893" | ||
- name: FTL_RUNNER_ADVERTISE | ||
value: "" | ||
ports: | ||
- containerPort: 8893 | ||
readinessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8893 | ||
initialDelaySeconds: 1 | ||
periodSeconds: 2 | ||
timeoutSeconds: 2 | ||
successThreshold: 1 | ||
failureThreshold: 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: pg-secret | ||
namespace: default | ||
type: Opaque | ||
stringData: | ||
superUserPassword: "secret" | ||
replicationUserPassword: "postgresReplicaPsw" | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ftl-pg-cluster-conf | ||
namespace: default | ||
|
||
data: | ||
|
||
primary_init_script.sh: | | ||
#!/bin/bash | ||
set -e | ||
echo "Running init script the 1st time Primary PostgreSql container is created..."; | ||
echo "Running: psql -v ON_ERROR_STOP=1 --username $POSTGRES_USER --dbname $POSTGRES_DB ..."; | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
CREATE DATABASE ftl; | ||
CREATE USER ftl WITH PASSWORD 'secret'; | ||
GRANT ALL PRIVILEGES ON DATABASE "ftl" to ftl; | ||
EOSQL | ||
echo "Init script is completed"; | ||
--- | ||
apiVersion: kubegres.reactive-tech.io/v1 | ||
kind: Kubegres | ||
metadata: | ||
name: ftl-pg-cluster | ||
namespace: default | ||
spec: | ||
replicas: 1 | ||
image: postgres:14.1 | ||
|
||
database: | ||
size: 200Mi | ||
|
||
customConfig: ftl-pg-cluster-conf | ||
|
||
env: | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: pg-secret | ||
key: superUserPassword | ||
|
||
- name: POSTGRES_REPLICATION_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: pg-secret | ||
key: replicationUserPassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ftlController: | ||
image: ghcr.io/tbd54566975/ftl-controller | ||
tag: latest | ||
ftlRunner: | ||
image: ghcr.io/tbd54566975/ftl-runner | ||
tag: latest |