Skip to content

Commit 1103fb3

Browse files
committed
Make base domain configurable for local setup with tilt
1 parent a1a4686 commit 1103fb3

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

README.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ The default test data that is loaded can be found in [faf-db](https://github.com
8484
You can load the data at anytime by manually triggering the popualte-db resource under the Database label. This needs to be done the first time for data to exist.
8585

8686
## Endpoints
87-
Locally traefik uses the same ingress routes as we do in production just with a default base domain of localhost. So accessible domains will be api.localhost, hydra.localhost etc. By default these should resolve to 127.0.0.1. If they do not you can manually modify your hosts file to add the local dns records. For convenience the resource create-hosts-file-content
87+
Locally traefik uses the same ingress routes as we do in production just with a default base domain of faforever.localhost. So accessible domains will be api.faforever.localhost, hydra.faforever.localhost etc. By default these should resolve to 127.0.0.1. If they do not you can manually modify your hosts file to add the local dns records. For convenience the resource create-hosts-file-content
8888
will output the necessary lines for the hosts file when run after every service has started.
8989

Tiltfile

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ config.define_string("default-pull-policy", args=False, usage="Pull policy to us
55
config.define_string("host-ip", args=False, usage="IP Address of the host to enable redirection to local services")
66
config.define_string("hostname", args=False, usage="Accessible name of the host to enable redirection to local services")
77
config.define_string("faf-data-dir", args=False, usage="Directory where the FAF Data lives normally C:/ProgramData/FAForever on Windows or ~/.faforever on Linux")
8+
config.define_string("base-domain", args=False, usage="Base Domain to use for all faf services. Defaults to faforever.localhost")
89
config.define_string_list("local-services", args=False, usage="Names of services that you intend to run locally")
910
cfg = config.parse()
1011
windows_bash_path = cfg.get("windows-bash-path", "C:\\Program Files\\Git\\bin\\bash.exe")
1112
host_ip = cfg.get("host-ip", "")
1213
local_services = cfg.get("local-services", [])
14+
base_domain = cfg.get("base-domain", "faforever.localhost")
1315

1416
data_relative_path = ".local-data"
1517
if os.name == "nt":
@@ -99,6 +101,7 @@ def helm_with_build_cache(chart, namespace="", values=[], set=[], specifier = ""
99101
command.extend(["--namespace", namespace])
100102
command.extend(value_flags)
101103
command.extend(set_flags)
104+
command.extend(["--set", "baseDomain=" + base_domain])
102105

103106
deps = [chart]
104107
deps.extend(values)
@@ -215,7 +218,7 @@ def proxy_local_service_if_set(service_name, service_chart, service_namespace, a
215218
k8s_yaml(service_proxy_yaml)
216219
for object in decode_yaml_stream(service_proxy_yaml):
217220
service_objects.append(object["metadata"]["name"] + ":" + object["kind"].lower())
218-
k8s_resource(new_name=service_name, objects=service_objects, resource_deps=all_service_deps, labels=user_service_labels, links=user_service_links, pod_readiness="ignore")
221+
k8s_resource(new_name=service_name, objects=service_objects, resource_deps=all_service_deps, labels=service_labels, links=user_service_links, pod_readiness="ignore")
219222
else:
220223
if service_name == "faf-icebreaker":
221224
service_yaml = remove_init_container(service_yaml)
@@ -257,7 +260,7 @@ for object in decode_yaml_stream(storage_yaml):
257260

258261
k8s_resource(new_name="volumes", objects=volume_identifiers, labels=["core"], trigger_mode=TRIGGER_MODE_MANUAL)
259262

260-
traefik_yaml = helm_with_build_cache("cluster/traefik", values=["config/local.yaml", "cluster/traefik/values-local.yaml"], namespace="traefik")
263+
traefik_yaml = helm_with_build_cache("cluster/traefik", values=["config/local.yaml", "cluster/traefik/values-local.yaml"], set=["traefik.ingressRoute.dashboard.matchRule='Host(`traefik.{}`)'".format(base_domain)], namespace="traefik")
261264
k8s_yaml(traefik_yaml)
262265

263266
traefik_identifiers = []
@@ -325,23 +328,23 @@ k8s_resource(workload="ergochat", objects=["ergochat-webirc:ingressroute"], reso
325328

326329
k8s_yaml(helm_with_build_cache("apps/wordpress", namespace="faf-apps", values=["config/local.yaml"]))
327330
k8s_resource(new_name="wordpress-config", objects=["wordpress:configmap", "wordpress:secret"], labels=["website"])
328-
k8s_resource(workload="wordpress", objects=["wordpress:ingressroute"], resource_deps=["traefik"], labels=["website"], links=[link("http://direct.localhost", "FAF Wordpress")])
331+
k8s_resource(workload="wordpress", objects=["wordpress:ingressroute"], resource_deps=["traefik"], labels=["website"], links=[link("http://direct.{}".format(base_domain), "FAF Wordpress")])
329332

330333
k8s_yaml(helm_with_build_cache("apps/wikijs", namespace="faf-apps", values=["config/local.yaml"]))
331334
k8s_resource(new_name="wikijs-config", objects=["wikijs:configmap", "wikijs:secret", "wikijs-sso:configmap"], labels=["wiki"])
332-
k8s_resource(workload="wikijs", objects=["wikijs:ingressroute"], resource_deps=["traefik"] + postgres_setup_resources, labels=["wiki"], links=[link("http://wiki.localhost", "FAF Wiki")])
335+
k8s_resource(workload="wikijs", objects=["wikijs:ingressroute"], resource_deps=["traefik"] + postgres_setup_resources, labels=["wiki"], links=[link("http://wiki.{}".format(base_domain), "FAF Wiki")])
333336

334337
k8s_yaml(helm_with_build_cache("apps/nodebb", namespace="faf-apps", values=["config/local.yaml"]))
335338
k8s_resource(new_name="nodebb-config", objects=["nodebb:configmap", "nodebb:secret"], labels=["forum"])
336-
k8s_resource(workload="nodebb", objects=["nodebb:ingressroute"], resource_deps=["traefik"] + mongodb_setup_resources, labels=["forum"], links=[link("http://forum.localhost", "FAF Forum")])
339+
k8s_resource(workload="nodebb", objects=["nodebb:ingressroute"], resource_deps=["traefik"] + mongodb_setup_resources, labels=["forum"], links=[link("http://forum.{}".format(base_domain), "FAF Forum")])
337340

338341
k8s_yaml(keep_objects_of_kind(helm_with_build_cache("apps/debezium", namespace="faf-apps", values=["config/local.yaml"]), kinds=["ConfigMap", "Secret"]))
339342
k8s_resource(new_name="debezium-config", objects=["debezium:configmap", "debezium:secret"], labels=["database"])
340343

341344
hydra_yaml = helm_with_build_cache("apps/ory-hydra", namespace="faf-apps", values=["config/local.yaml"])
342345
hydra_client_create_yaml, hydra_resources_yaml = filter_yaml(hydra_yaml, {"app": "ory-hydra-create-clients"})
343346
_, hydra_resources_yaml = filter_yaml(hydra_resources_yaml, {"app": "ory-hydra-janitor"})
344-
hydra_resources_yaml = patch_config(hydra_resources_yaml, "ory-hydra", {"URLS_SELF_ISSUER": "http://ory-hydra:4444", "URLS_SELF_PUBLIC": "http://hydra.localhost", "URLS_LOGIN": "http://user.localhost/oauth2/login", "URLS_CONSENT": "http://user.localhost/oauth2/consent", "DEV": "true"})
347+
hydra_resources_yaml = patch_config(hydra_resources_yaml, "ory-hydra", {"URLS_SELF_ISSUER": "http://ory-hydra:4444", "URLS_SELF_PUBLIC": "http://hydra.{}".format(base_domain), "URLS_LOGIN": "http://user.{}/oauth2/login".format(base_domain), "URLS_CONSENT": "http://user.{}/oauth2/consent".format(base_domain), "DEV": "true"})
345348
k8s_yaml(hydra_resources_yaml)
346349
k8s_yaml(hydra_client_create_yaml)
347350
k8s_resource(new_name="ory-hydra-config", objects=["ory-hydra:configmap", "ory-hydra:secret"], labels=["hydra"])
@@ -358,24 +361,24 @@ k8s_resource(new_name="faf-policy-server-config", objects=["faf-policy-server:co
358361

359362
# k8s_yaml(helm_with_build_cache("apps/faf-content", namespace="faf-apps", values=["config/local.yaml"]))
360363
# k8s_resource(new_name="faf-content-config", objects=["faf-content:configmap"], labels=["content"])
361-
# k8s_resource(workload="faf-content", objects=["faf-content:ingressroute", "cors:middleware", "redirect-replay-subdomain:middleware"], resource_deps=["traefik"], labels=["content"], links=[link("http://content.localhost", "FAForever Content")])
364+
# k8s_resource(workload="faf-content", objects=["faf-content:ingressroute", "cors:middleware", "redirect-replay-subdomain:middleware"], resource_deps=["traefik"], labels=["content"], links=[link("http://content.{}".format(base_domain), "FAForever Content")])
362365

363366
user_service_deps = ["faf-db-migrations", "ory-hydra"]
364367
user_service_labels = ["user"]
365-
user_service_links = [link("http://user.localhost/register", "User Service Registration")]
366-
user_service_patch = {"HYDRA_TOKEN_ISSUER": "http://ory-hydra:4444", "HYDRA_JWKS_URL": "http://ory-hydra:4444/.well-known/jwks.json", "LOBBY_URL":"ws://ws.localhost", "REPLAY_URL":"ws://replay-ws.localhost"}
368+
user_service_links = [link("http://user.{}/register".format(base_domain), "User Service Registration")]
369+
user_service_patch = {"HYDRA_TOKEN_ISSUER": "http://ory-hydra:4444", "HYDRA_JWKS_URL": "http://ory-hydra:4444/.well-known/jwks.json", "LOBBY_URL":"ws://ws.{}".format(base_domain), "REPLAY_URL":"ws://replay-ws.{}".format(base_domain)}
367370
proxy_local_service_if_set(service_name="faf-user-service", service_chart="apps/faf-user-service", service_namespace="faf-apps", service_deps=user_service_deps, service_labels=user_service_labels, service_links=user_service_links, config_patch=user_service_patch)
368371

369372
website_deps = ["wordpress"]
370373
website_labels = ["website"]
371-
website_links = [link("http://www.localhost", "FAForever Website")]
372-
website_patch = {"OAUTH_URL": "http://ory-hydra:4444", "OAUTH_PUBLIC_URL": "http://hydra.localhost", "API_URL": "http://faf-api:8010", "WP_URL": "http://wordpress:80"}
374+
website_links = [link("http://www.{}".format(base_domain), "FAForever Website")]
375+
website_patch = {"OAUTH_URL": "http://ory-hydra:4444", "OAUTH_PUBLIC_URL": "http://hydra.{}".format(base_domain), "API_URL": "http://faf-api:8010", "WP_URL": "http://wordpress:80"}
373376
proxy_local_service_if_set(service_name="faf-website", service_chart="apps/faf-website", service_namespace="faf-apps", service_deps=website_deps, service_labels=website_labels, service_links=website_links, additional_values=["apps/faf-website/values-prod.yaml"], config_patch=website_patch)
374377

375378
api_deps = ["faf-db-migrations", "ory-hydra"] + rabbitmq_setup_resources
376379
api_labels = ["api"]
377-
api_links = [link("http://api.localhost", "FAF API")]
378-
api_patch = {"JWT_FAF_HYDRA_ISSUER": "http://ory-hydra:4444", "REPLAY_DOWNLOAD_URL_FORMAT": "http://replays.localhost/%s", "MOD_DOWNLOAD_URL_FORMAT": "http://content.localhost/mods/%s", "MAP_DOWNLOAD_URL_FORMAT": "http://content.localhost/maps/%s", "FEATURED_MOD_URL_FORMAT":"http://content.localhost/legacy-featured-mod-files/%s/%s", "AVATAR_DOWNLOAD_URL_FORMAT":"http://content.localhost/faf/avatars/%s"}
380+
api_links = [link("http://api.{}".format(base_domain), "FAF API")]
381+
api_patch = {"JWT_FAF_HYDRA_ISSUER": "http://ory-hydra:4444", "REPLAY_DOWNLOAD_URL_FORMAT": "http://replays.{}/%s".format(base_domain), "MOD_DOWNLOAD_URL_FORMAT": "http://content.{}/mods/%s".format(base_domain), "MAP_DOWNLOAD_URL_FORMAT": "http://content.{}/maps/%s".format(base_domain), "FEATURED_MOD_URL_FORMAT":"http://content.{}/legacy-featured-mod-files/%s/%s".format(base_domain), "AVATAR_DOWNLOAD_URL_FORMAT":"http://content.{}/faf/avatars/%s".format(base_domain)}
379382
proxy_local_service_if_set(service_name="faf-api", service_chart="apps/faf-api", service_namespace="faf-apps", service_deps=api_deps, service_labels=api_labels, service_links=api_links, config_patch=api_patch)
380383

381384
league_service_deps = mariadb_setup_resources + rabbitmq_setup_resources
@@ -392,7 +395,7 @@ replay_server_labels = ["replay"]
392395
proxy_local_service_if_set(service_name="faf-replay-server", service_chart="apps/faf-replay-server", service_namespace="faf-apps", service_deps=replay_server_deps, service_labels=replay_server_labels)
393396

394397
unitdb_labels = ["unitdb"]
395-
unitdb_links = [link("http://unitdb.localhost", "Rackover UnitDB")]
398+
unitdb_links = [link("http://unitdb.{}".format(base_domain), "Rackover UnitDB")]
396399
proxy_local_service_if_set(service_name="faf-unitdb", service_chart="apps/faf-unitdb", service_namespace="faf-apps", service_labels=unitdb_labels, service_links=unitdb_links)
397400

398401
ws_bridge_deps = ["faf-lobby-server"]

apps/nodebb/templates/local-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ stringData:
99
OAUTH_SECRET: "banana"
1010
"config.json": |
1111
{
12-
"url": "https://forum.localhost",
12+
"url": "https://forum.{{ .Values.baseDomain }}",
1313
"secret": "banana",
1414
"database": "mongo",
1515
"port": 4567,

cluster/traefik/values-local.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ traefik:
55
ingressRoute:
66
dashboard:
77
enabled: true
8-
matchRule: Host(`traefik.localhost`)
8+
matchRule: Host(`traefik.faforever.localhost`)
99
entryPoints: ["websecure", "web"]
1010

1111
additionalArguments:

config/local.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
hostName: "localhost"
22
environment: "local"
3-
baseDomain: "localhost"
3+
baseDomain: "faforever.localhost"
44
infisical-secret:
55
enabled: false
66
traefik: {}

0 commit comments

Comments
 (0)