Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ This repository aims to provide a ready-to-go [Tilt](https://docs.tilt.dev/) set
* [helm](https://helm.sh/docs/intro/install/) must be installed to generate the k8s from the helm charts in the gitops repo
* For Windows users:
* A bash program. By default git bash is used with an assumed installation directory of C:/Program Files/Git
* System Resource Usage
* For local development containers takee about 4GB with docker desktop on windows full k8s used 11GB

## Startup Services
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.
Expand Down
20 changes: 5 additions & 15 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,16 @@ if os.name == "nt":
if not os.path.exists(windows_bash_path):
fail("Windows users need to supply a valid path to a bash executable")

data_absolute_path = "//data/" + data_relative_path
if k8s_context() == "docker-desktop":
hostname = cfg.get("hostname", "host.docker.internal")
drive, path_without_drive = os.getcwd().split(":")
data_absolute_path = os.path.join("//run/desktop/mnt/host/", drive, path_without_drive, data_relative_path).replace("\\","/").lower()
use_named_volumes = ["mariadb"]
elif k8s_context() == "minikube" or k8s_context() == "kind-kind":
hostname = cfg.get("hostname", "")
data_absolute_path = "//data/" + data_relative_path
use_named_volumes = []
else:
fail("Cannot determine how to mount for windows host")

else:
faf_data_dir = cfg.get("faf-data-dir", "~/.faforever")
hostname = cfg.get("hostname", "")
data_absolute_path = os.path.join(os.getcwd(), data_relative_path)
use_named_volumes = []

host_details = ["hostIP="+host_ip, "hostname="+hostname]

Expand Down Expand Up @@ -169,15 +162,12 @@ def helm_with_build_cache(chart, namespace="", values=[], set=[], specifier = ""

return encode_yaml_stream(objects)

def to_hostpath_storage(yaml, use_named_volumes):
def to_hostpath_storage(yaml):
objects = decode_yaml_stream(yaml)
for object in objects:
if object["kind"] == "PersistentVolume":
object["spec"].pop("nodeAffinity", None)
localpath_spec = object["spec"].pop("local", {"path": ""})
if os.path.basename(localpath_spec["path"]) in use_named_volumes:
volume_name = os.path.basename(localpath_spec["path"])
localpath_spec["path"] = volume_name

object["spec"]["hostPath"] = localpath_spec
object["spec"]["hostPath"]["type"] = "DirectoryOrCreate"
Expand Down Expand Up @@ -267,7 +257,7 @@ if not is_ci:
k8s_resource(workload="release-name-reloader", new_name="reloader", objects=["release-name-reloader:serviceaccount", "release-name-reloader-metadata-role:role", "release-name-reloader-role:clusterrole", "release-name-reloader-metadata-role-binding:rolebinding", "release-name-reloader-role-binding:clusterrolebinding"], resource_deps=["namespaces"], labels=["core"])

storage_yaml = helm_with_build_cache("cluster/storage", values=["config/local.yaml"], set=["dataPath="+data_absolute_path])
storage_yaml = to_hostpath_storage(storage_yaml, use_named_volumes=use_named_volumes)
storage_yaml = to_hostpath_storage(storage_yaml)
k8s_yaml(storage_yaml)

volume_identifiers = []
Expand Down Expand Up @@ -316,7 +306,7 @@ k8s_resource(workload="mariadb", objects=["mariadb:configmap", "mariadb:secret",
mariadb_setup_resources = []
for object in decode_yaml_stream(mariadb_init_user_yaml):
mariadb_setup_resources.append(object["metadata"]["name"])
k8s_resource(workload=object["metadata"]["name"], resource_deps=["init-apps", "mariadb", "faf-api-config", "faf-user-service-config", "faf-lobby-server-config", "faf-replay-server-config", "faf-policy-server-config", "faf-league-service-config", "wordpress-config", "ergochat-config"], labels=["database"])
k8s_resource(workload=object["metadata"]["name"], resource_deps=["init-apps", "mariadb", "faf-api-config", "faf-user-service-config", "faf-lobby-server-config", "faf-replay-server-config", "faf-policy-server-config", "faf-league-service-config", "wordpress-config", "ergochat-config", "faf-icebreaker-config"], labels=["database"])

mongodb_yaml = helm_with_build_cache("infra/mongodb", namespace="faf-infra", values=["config/local.yaml"])
mongodb_init_user_yaml, mongodb_resource_yaml = filter_yaml(mongodb_yaml, {"app": "mongodb-sync-db-user"})
Expand All @@ -337,7 +327,7 @@ k8s_resource(workload="rabbitmq", objects=["rabbitmq:configmap", "rabbitmq:secre
rabbitmq_setup_resources = []
for object in decode_yaml_stream(rabbitmq_init_user_yaml):
rabbitmq_setup_resources.append(object["metadata"]["name"])
k8s_resource(workload=object["metadata"]["name"], resource_deps=["init-apps", "rabbitmq", "faf-api-config", "faf-icebreaker-config", "faf-lobby-server-config", "debezium-config", "faf-league-service-config"], labels=["rabbitmq"])
k8s_resource(workload=object["metadata"]["name"], resource_deps=["init-apps", "rabbitmq", "faf-api-config", "faf-icebreaker-config", "faf-lobby-server-config", "debezium-config", "faf-league-service-config", "faf-user-service-config"], labels=["rabbitmq"])

k8s_yaml(cronjob_to_job(helm_with_build_cache("apps/faf-db-migrations", namespace="faf-apps", values=["config/local.yaml"])))
k8s_resource(workload="faf-db-migrations", objects=["faf-db-migrations:secret"], resource_deps=mariadb_setup_resources, labels=["database"])
Expand Down
Loading
Loading