Skip to content

Commit

Permalink
Set workshop image cache to public hostname when ingress enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamDumpleton committed Jul 25, 2023
1 parent f0cc489 commit 1be55b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
29 changes: 12 additions & 17 deletions session-manager/handlers/workshopenvironment.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,15 @@ def workshop_environment_create(

workshop_image_pull_policy = image_pull_policy(workshop_image)

workshop_image_cache = f"image-cache.{workshop_namespace}.svc.{CLUSTER_DOMAIN}"

if xget(workshop_spec, "environment.images.ingress.enabled", False):
workshop_image_cache = f"images-{workshop_namespace}.{INGRESS_DOMAIN}"

environment_downloads_variables = dict(
platform_arch=PLATFORM_ARCH,
image_repository=image_repository,
workshop_image_cache=f"image-cache.{workshop_namespace}.svc.{CLUSTER_DOMAIN}",
workshop_image_cache=workshop_image_cache,
assets_repository=f"assets-server.{workshop_namespace}.svc.{CLUSTER_DOMAIN}",
workshop_name=workshop_name,
environment_name=environment_name,
Expand Down Expand Up @@ -929,7 +934,7 @@ def workshop_environment_create(
environment_variables = dict(
platform_arch=PLATFORM_ARCH,
image_repository=image_repository,
workshop_image_cache=f"image-cache.{workshop_namespace}.svc.{CLUSTER_DOMAIN}",
workshop_image_cache=workshop_image_cache,
assets_repository=f"assets-server.{workshop_namespace}.svc.{CLUSTER_DOMAIN}",
service_account=f"{OPERATOR_NAME_PREFIX}-services",
workshop_name=workshop_name,
Expand Down Expand Up @@ -1274,9 +1279,7 @@ def workshop_environment_create(
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {"deployment": "image-cache"}
},
"selector": {"matchLabels": {"deployment": "image-cache"}},
"strategy": {"type": "Recreate"},
"template": {
"metadata": {
Expand Down Expand Up @@ -1328,9 +1331,7 @@ def workshop_environment_create(
"volumes": [
{
"name": "config",
"configMap": {
"name": "image-cache"
},
"configMap": {"name": "image-cache"},
},
],
},
Expand Down Expand Up @@ -1397,9 +1398,7 @@ def workshop_environment_create(
artifacts_deployment_body["spec"]["template"]["spec"]["volumes"].append(
{
"name": "data",
"persistentVolumeClaim": {
"claimName": "image-cache"
},
"persistentVolumeClaim": {"claimName": "image-cache"},
}
)

Expand Down Expand Up @@ -1580,9 +1579,7 @@ def workshop_environment_create(
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {"deployment": "assets-server"}
},
"selector": {"matchLabels": {"deployment": "assets-server"}},
"strategy": {"type": "Recreate"},
"template": {
"metadata": {
Expand Down Expand Up @@ -1723,9 +1720,7 @@ def workshop_environment_create(
nginx_deployment_body["spec"]["template"]["spec"]["volumes"].append(
{
"name": "data",
"persistentVolumeClaim": {
"claimName": "assets-server"
},
"persistentVolumeClaim": {"claimName": "assets-server"},
}
)

Expand Down
5 changes: 5 additions & 0 deletions session-manager/handlers/workshopsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,12 @@ def resolve_security_policy(name):
# in those before add them to the final set of session variables.

image_repository = IMAGE_REPOSITORY

workshop_image_cache = f"image-cache.{workshop_namespace}.svc.{CLUSTER_DOMAIN}"

if xget(workshop_spec, "environment.images.ingress.enabled", False):
workshop_image_cache = f"images-{workshop_namespace}.{INGRESS_DOMAIN}"

assets_repository = f"assets-server.{workshop_namespace}.svc.{CLUSTER_DOMAIN}"

image_registry_host = xget(environment_instance.obj, "spec.registry.host")
Expand Down

0 comments on commit 1be55b8

Please sign in to comment.