Skip to content

Commit d64890e

Browse files
authored
Move tilt configuration into gitops-stack (#267)
* Move tilt confiiguration into gitops-stack * Implement rabbit suggestion * Fix rabbitmq comments * Use .local-data for local data * Remove double slash * Rename variables * Address comments * Default pull policy to if not present for development * Remove unused parameter * Include cron job in default pull policy * Fix variables
1 parent bb4d41f commit d64890e

File tree

11 files changed

+438
-2
lines changed

11 files changed

+438
-2
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ spicy-secrets/**
77
**/Chart.lock
88

99
# Ignore Helm chart tarballs in any charts/ directory at any depth
10-
**/charts/*.tgz
10+
**/charts/*.tgz
11+
12+
tilt_config.json
13+
.local-data/
14+
.helm-cache/

README.MD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,23 @@ kubectl create secret generic "infisical-service-token" \
6161
--from-literal=infisicalToken=<your-token-here>
6262
done
6363
```
64+
65+
# Local Development Using Tilt
66+
67+
This repository aims to provide a ready-to-go [Tilt](https://docs.tilt.dev/) setup for ephemeral FAF infrastructure local development on kubernetes.
68+
69+
## Prerequisites
70+
* [Tilt](https://docs.tilt.dev/install.html)
71+
* Kubernetes ([Docker Desktop](https://docs.docker.com/desktop/kubernetes/) or [Minikube](https://minikube.sigs.k8s.io/docs/) are recommended for those new to kubernetes) [Tilt cluster setup](https://docs.tilt.dev/choosing_clusters)
72+
* For Windows users a bash program. By default git bash is used with an assumed installation directory of C:/Program Files/Git
73+
* [helm](https://helm.sh/docs/intro/install/) must be installed to generate the k8s from the helm charts in the gitops repo
74+
75+
## Startup Services
76+
In the root directory of the repository run `tilt up`. This will start all the faf services in the correct order. The status of each service can be viewed in the tilt UI by visiting <http://localhost:10350>. This is the control server for tilt where you can restart services or disable them for substitution by services you would like to run from source code as you actively develop them.
77+
78+
## Development
79+
To develop against the FAF infrastructure you should disable the service in tilt that you are actively developing. Once disabled you can start up your developed version. Some tweaks may need to be made to the default configuration parameters in the source code. The proper values can be found in the configMaps in each of the services kubernetes deploy yaml files.
80+
81+
## Test Data
82+
The default test data that is loaded can be found in /sql/test-data.sql. This can be overridden by providing a new path with the tilt configuration key test-data-path when running tilt up or in the tilt_config.json file in the repository root directory.
83+

Tiltfile

Lines changed: 321 additions & 0 deletions
Large diffs are not rendered by default.

apps/ory-hydra/templates/local-secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ stringData:
99
DB_PASSWORD: "banana"
1010
DSN: "postgres://hydra:banana@postgres:5432/ory-hydra"
1111
FAF_QAI_SECRET: "banana"
12+
WIKIJS_SECRET: "banana"
1213
SECRETS_SYSTEM: "bananabananabananabanana"
1314
{{- end}}

apps/wikijs/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
port: 3000
4040
path: /healthz
4141
failureThreshold: 10
42-
periodSeconds: 3
42+
periodSeconds: 5
4343
livenessProbe:
4444
httpGet:
4545
port: 3000

cluster/namespaces.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: faf-infra
5+
6+
---
7+
apiVersion: v1
8+
kind: Namespace
9+
metadata:
10+
name: faf-apps
11+
12+
---
13+
apiVersion: v1
14+
kind: Namespace
15+
metadata:
16+
name: faf-ops

config/local.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ baseDomain: "localhost"
44
infisical-secret:
55
enabled: false
66
traefik: {}
7+
zfs:
8+
nodeId: ""

config/prod.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ infisical-secret:
77
baseDomain: "faforever.com"
88
traefik:
99
tlsStoreSecret: "cloudflare-faf-com"
10+
zfs:
11+
nodeId: "fafprod3"

config/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ infisical-secret:
1010
baseDomain: "faforever.xyz"
1111
traefik:
1212
tlsStoreSecret: "cloudflare-faf-xyz"
13+
zfs:
14+
nodeId: "faftest2"

tilt/scripts/helm-with-cache.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
cache_dir=$1
4+
shift
5+
6+
chart=$1
7+
chart_cache_dir="$cache_dir/$chart"
8+
9+
mkdir -p "$chart_cache_dir"
10+
11+
if [ -s "$chart_cache_dir/args" ] && cmp -s -- "$chart_cache_dir/args" <(echo -n "$@") && [ -s "$chart_cache_dir/files" ] && cmp -s -- "$chart_cache_dir/files" <(find "$chart" -type f -name "*.yaml" | sort) && [ -s "$chart_cache_dir/md5sum" ] && md5sum --status -c "$chart_cache_dir/md5sum" && [ -s "$chart_cache_dir/yaml" ]; then
12+
echo "$chart matches cached yaml"
13+
exit 0
14+
fi
15+
16+
if helm dependency list "$chart" | grep -qE '.*missing\s*$'; then
17+
helm dependency update "$chart"
18+
fi
19+
20+
echo "Generating yaml from helm in $chart"
21+
helm template "$@" > "$chart_cache_dir/yaml"
22+
23+
echo "Saving template files"
24+
template_files=$(find "$chart" -type f -name "*.yaml" | sort)
25+
echo "$template_files" > "$chart_cache_dir/files"
26+
27+
echo "Saving template sums"
28+
find "$chart" -type f -name "*.yaml" -exec md5sum {} + > "$chart_cache_dir/md5sum"
29+
30+
for ARGUMENT in "$@"
31+
do
32+
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
33+
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
34+
35+
if [[ "$KEY" == "--values" ]] && [[ "$VALUE" != "--values" ]]; then
36+
md5sum "$VALUE" >> "$chart_cache_dir/md5sum"
37+
fi
38+
39+
if [[ $PREVIOUS_KEY == "--values" ]] && [[ "$PREVIOUS_VALUE" == "--values" ]]; then
40+
md5sum "$VALUE" >> "$chart_cache_dir/md5sum"
41+
fi
42+
43+
PREVIOUS_KEY="$KEY"
44+
PREVIOUS_VALUE="$VALUE"
45+
done
46+
47+
echo "Saving args"
48+
echo -n "$@" > "$chart_cache_dir/args"

0 commit comments

Comments
 (0)