Skip to content

Commit bb175e7

Browse files
authored
Add AIMMO_DJANGO_BASE_URL to settings (#310)
* Add AIMMO_DJANGO_BASE_URL to settings * Merge branch 'master' into add_aimmo_base_url_new * Merge branch 'master' into add_aimmo_base_url_new * Remove game creator step
1 parent 31ba10c commit bb175e7

File tree

3 files changed

+17
-120
lines changed

3 files changed

+17
-120
lines changed

clusters_setup/deploy.py

+2-62
Original file line numberDiff line numberDiff line change
@@ -86,67 +86,14 @@ def create_fleet_yaml(module_name, aimmo_version):
8686
return content
8787

8888

89-
def create_creator_yaml(module_name, aimmo_version):
90-
"""
91-
Loads an aimmo-game-creator yaml into a dictionary.
92-
93-
Replaces the GAME_API_URL environment variable with the correct url for the
94-
deployment environment we are in
95-
96-
:param module_name: The name of the environment we're in (ie. staging, dev).
97-
:param aimmo_version: The game version we want to deploy.
98-
:return: python object containing yaml with modified values.
99-
"""
100-
101-
def _replace_game_api_url(content):
102-
game_api_url = (
103-
"https://"
104-
+ module_name
105-
+ "-dot-decent-digit-629.appspot.com/kurono/api/games/"
106-
)
107-
env_variables = content["spec"]["template"]["spec"]["containers"][0]["env"]
108-
game_api_url_index = env_variables.index(
109-
{"name": "GAME_API_URL", "value": "REPLACE_ME"}
110-
)
111-
env_variables[game_api_url_index]["value"] = game_api_url
112-
113-
def _replace_image_version(content):
114-
env_variables = content["spec"]["template"]["spec"]["containers"][0]["env"]
115-
image_suffix_index = env_variables.index(
116-
{"name": "IMAGE_SUFFIX", "value": "latest"}
117-
)
118-
env_variables[image_suffix_index]["value"] = aimmo_version
119-
120-
def _replace_image_tag(content):
121-
content["spec"]["template"]["spec"]["containers"][0][
122-
"image"
123-
] = "ocadotechnology/aimmo-game-creator:{}".format(aimmo_version)
124-
125-
path = os.path.join(CURR_DIR, "rs_aimmo_game_creator.yaml")
126-
with open(path) as yaml_file:
127-
content = yaml.safe_load(yaml_file.read())
128-
_replace_game_api_url(content)
129-
_replace_image_version(content)
130-
_replace_image_tag(content)
131-
return content
132-
133-
134-
def restart_pods(game_creator_yaml, ingress_yaml, fleet_yaml):
89+
def restart_pods(ingress_yaml, fleet_yaml):
13590
"""
13691
Restarts the kubernetes replication controllers, pods, services and ingresses
13792
in the 'default' namespace
13893
139-
:param game_creator_yaml: The dict to create the aimmo game creator rc
14094
:param ingress_yaml: The dict to create the ingress
14195
:param fleet_yaml: The dict to create the fleet
14296
"""
143-
for rs in apps_api_instance.list_namespaced_replica_set("default").items:
144-
if rs.metadata.name == game_creator_yaml["metadata"]["name"]:
145-
apps_api_instance.delete_namespaced_replica_set(
146-
body=kubernetes.client.V1DeleteOptions(),
147-
name=rs.metadata.name,
148-
namespace="default",
149-
)
15097
for service in api_instance.list_namespaced_service("default").items:
15198
if service.metadata.name.startswith("game-"):
15299
api_instance.delete_namespaced_service(
@@ -193,10 +140,6 @@ def restart_pods(game_creator_yaml, ingress_yaml, fleet_yaml):
193140

194141
networking_api_instance.create_namespaced_ingress("default", ingress_yaml)
195142

196-
apps_api_instance.create_namespaced_replica_set(
197-
body=game_creator_yaml, namespace="default"
198-
)
199-
200143
custom_objects_api_instance.create_namespaced_custom_object(
201144
group="agones.dev",
202145
version="v1",
@@ -225,12 +168,9 @@ def main(module_name):
225168
aimmo_version = get_aimmo_version()
226169

227170
ingress = create_ingress_yaml(module_name=module_name)
228-
game_creator_rs = create_creator_yaml(
229-
module_name=module_name, aimmo_version=aimmo_version
230-
)
231171
fleet = create_fleet_yaml(module_name=module_name, aimmo_version=aimmo_version)
232172

233-
restart_pods(game_creator_rs, ingress, fleet)
173+
restart_pods(ingress, fleet)
234174

235175

236176
if __name__ == "__main__":

clusters_setup/rs_aimmo_game_creator.yaml

-34
This file was deleted.

django_site/settings.py

+15-24
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
https://docs.djangoproject.com/en/3.2/ref/settings/
99
"""
1010

11+
import json
1112
# Build paths inside the project like this: rel(rel_path)
1213
import os
13-
import json
1414

1515
from .permissions import is_cloud_scheduler
1616

@@ -29,25 +29,18 @@
2929
DOTMAILER_MAIN_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_MAIN_ADDRESS_BOOK_URL", "")
3030
DOTMAILER_TEACHER_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_TEACHER_ADDRESS_BOOK_URL", "")
3131
DOTMAILER_STUDENT_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_STUDENT_ADDRESS_BOOK_URL", "")
32-
DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL = os.getenv(
33-
"DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL", ""
34-
)
32+
DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL = os.getenv("DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL", "")
3533
DOTMAILER_GET_USER_BY_EMAIL_URL = os.getenv("DOTMAILER_GET_USER_BY_EMAIL_URL", "")
3634
DOTMAILER_DELETE_USER_BY_ID_URL = os.getenv("DOTMAILER_DELETE_USER_BY_ID_URL", "")
3735
DOTMAILER_PUT_CONSENT_DATA_URL = os.getenv("DOTMAILER_PUT_CONSENT_DATA_URL", "")
3836
DOTMAILER_SEND_CAMPAIGN_URL = os.getenv("DOTMAILER_SEND_CAMPAIGN_URL", "")
39-
DOTMAILER_THANKS_FOR_STAYING_CAMPAIGN_ID = os.getenv(
40-
"DOTMAILER_THANKS_FOR_STAYING_CAMPAIGN_ID", ""
41-
)
37+
DOTMAILER_THANKS_FOR_STAYING_CAMPAIGN_ID = os.getenv("DOTMAILER_THANKS_FOR_STAYING_CAMPAIGN_ID", "")
4238
DOTMAILER_USER = os.getenv("DOTMAILER_USER", "")
4339
DOTMAILER_PASSWORD = os.getenv("DOTMAILER_PASSWORD", "")
44-
DOTMAILER_DEFAULT_PREFERENCES = json.loads(
45-
os.getenv("DOTMAILER_DEFAULT_PREFERENCES", "[]") or "[]"
46-
)
40+
DOTMAILER_DEFAULT_PREFERENCES = json.loads(os.getenv("DOTMAILER_DEFAULT_PREFERENCES", "[]") or "[]")
4741

4842
REACT_APP_KURONO_BADGES_URL = os.getenv(
49-
"REACT_APP_KURONO_BADGES_URL",
50-
"https://development-kurono-badges-dot-decent-digit-629.appspot.com"
43+
"REACT_APP_KURONO_BADGES_URL", "https://development-kurono-badges-dot-decent-digit-629.appspot.com"
5144
)
5245

5346
SECURE_HSTS_SECONDS = 31536000 # One year
@@ -223,6 +216,16 @@
223216
SESSION_COOKIE_SECURE = True
224217
CSRF_COOKIE_SECURE = True
225218

219+
AIMMO_DJANGO_BASE_URL = f"https://{os.getenv('GAE_SERVICE')}-dot-decent-digit-629.appspot.com"
220+
221+
AIMMO_GAME_SERVER_URL_FUNCTION = lambda game: (
222+
f"{os.getenv('GAE_SERVICE')}-aimmo.codeforlife.education",
223+
f"/game-{game}/socket.io",
224+
)
225+
226+
AIMMO_GAME_SERVER_PORT_FUNCTION = lambda game: 0
227+
AIMMO_GAME_SERVER_SSL_FLAG = True
228+
226229
EMAIL_ADDRESS = "[email protected]"
227230

228231
LOCALE_PATHS = ("conf/locale",)
@@ -261,18 +264,6 @@
261264

262265
CMS_TEMPLATES = (("portal/base.html", "Template One"),)
263266

264-
265-
AIMMO_GAME_SERVER_URL_FUNCTION = lambda game: (
266-
f"{os.getenv('GAE_SERVICE')}-aimmo.codeforlife.education",
267-
f"/game-{game}/socket.io",
268-
)
269-
270-
271-
AIMMO_GAME_SERVER_PORT_FUNCTION = lambda game: 0
272-
273-
274-
AIMMO_GAME_SERVER_SSL_FLAG = True
275-
276267
IS_CLOUD_SCHEDULER_FUNCTION = is_cloud_scheduler
277268
CLOUD_STORAGE_PREFIX = "https://storage.googleapis.com/codeforlife-assets/"
278269

0 commit comments

Comments
 (0)