Skip to content

Commit c23481c

Browse files
committed
improvemt to manage namespace in dynamic way
1 parent 5beb19e commit c23481c

File tree

9 files changed

+58
-58
lines changed

9 files changed

+58
-58
lines changed

.github/workflows/.github-ci.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,18 @@ jobs:
155155
docker push "${{ secrets.CR_REGISTRY }}"/"${{ secrets.CR_REPO }}"/"${tag}"
156156
157157
# Step 10: Login Docker Hub
158-
- name: Login to Docker Hub
158+
- name: Login to GHCR
159159
uses: docker/login-action@v2
160160
with:
161-
username: ${{ secrets.DOCKER_USERNAME }}
162-
password: ${{ secrets.DOCKER_PASSWORD }}
161+
registry: ghcr.io
162+
username: ${{ github.actor }}
163+
password: ${{ secrets.GITHUB_TOKEN }}
163164

164165
# Step 11: Push to Docker Hub
165166
- name: push to Docker Hub
166167
run: |
167168
tag="${docker_image_application}:${docker_image_version}"
168-
docker tag "${tag}" "docker.io/${{ env.docker_tag }}"
169-
docker tag "${tag}" "docker.io/${{ env.docker_tag_latest }}"
170-
docker push "docker.io/${{ env.docker_tag }}"
171-
docker push "docker.io/${{ env.docker_tag_latest }}"
169+
docker tag "${tag}" "ghcr.io/EOEPCA/${{ env.docker_tag }}"
170+
docker tag "${tag}" "ghcr.io/EOEPCA/${{ env.docker_tag_latest }}"
171+
docker push "ghcr.io/EOEPCA/${{ env.docker_tag }}"
172+
docker push "ghcr.io/EOEPCA/${{ env.docker_tag_latest }}"

apphub-configurator/examples/generate_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
init_container = create_init_container(
9191
image=image,
9292
volume=workspace_volume,
93-
mount_path="/calrissian",
93+
mount_path="/workspace",
9494
)
9595

9696
profile_1 = Profile(

apphub-configurator/manifests/dask-gateway.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ apiVersion: helm.crossplane.io/v1beta1
22
kind: Release
33
metadata:
44
name: dask-gw-jupyter-{{ spawner.user.name }}
5-
namespace: jupyter-{{ spawner.user.name }}
5+
namespace: "{{ namespace }}"
66
spec:
77
forProvider:
88
chart:
99
name: dask-gateway
1010
version: "2024.1.0"
1111
repository: https://helm.dask.org
12-
namespace: jupyter-{{ spawner.user.name }}
12+
namespace: "{{ namespace }}"
1313
values:
1414
gateway:
1515
backend:
@@ -39,7 +39,7 @@ metadata:
3939
data:
4040
gateway: |
4141
gateway:
42-
address: http://traefik-dask-gw-jupyter-{{ spawner.user.name }}-dask-gateway.jupyter-{{ spawner.user.name }}.svc.cluster.local:80
42+
address: http://traefik-dask-gw-jupyter-{{ spawner.user.name }}-dask-gateway.{namespace}-{{ spawner.user.name }}.svc.cluster.local:80
4343
4444
cluster:
4545
options:
@@ -55,7 +55,7 @@ metadata:
5555
data:
5656
gateway: |
5757
gateway:
58-
address: http://traefik-dask-gw-jupyter-{{ spawner.user.name }}-dask-gateway.jupyter-{{ spawner.user.name }}.svc.cluster.local:80
58+
address: http://traefik-dask-gw-jupyter-{{ spawner.user.name }}-dask-gateway.{namespace}-{{ spawner.user.name }}.svc.cluster.local:80
5959
6060
cluster:
6161
options:
@@ -68,7 +68,7 @@ apiVersion: rbac.authorization.k8s.io/v1
6868
kind: Role
6969
metadata:
7070
name: access-services
71-
namespace: jupyter-{{ spawner.user.name }}
71+
#namespace: jupyter-{{ spawner.user.name }}
7272
rules:
7373
- verbs:
7474
- get
@@ -98,11 +98,11 @@ apiVersion: rbac.authorization.k8s.io/v1
9898
kind: RoleBinding
9999
metadata:
100100
name: bind-default-to-services
101-
namespace: jupyter-{{ spawner.user.name }}
101+
#namespace: jupyter-{{ spawner.user.name }}
102102
subjects:
103103
- kind: ServiceAccount
104104
name: default
105-
namespace: jupyter-{{ spawner.user.name }}
105+
#namespace: jupyter-{{ spawner.user.name }}
106106
roleRef:
107107
apiGroup: rbac.authorization.k8s.io
108108
kind: Role

apphub-configurator/manifests/kaniko.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
kind: Pod
33
metadata:
44
name: kaniko-build
5-
namespace: jupyter-{{ spawner.user.name }}
5+
namespace: "{{ namespace }}"
66
spec:
77
containers:
88
- name: kaniko
@@ -32,7 +32,7 @@ apiVersion: rbac.authorization.k8s.io/v1
3232
kind: Role
3333
metadata:
3434
name: pod-exec
35-
namespace: jupyter-{{ spawner.user.name }}
35+
namespace: "{{ namespace }}"
3636
rules:
3737
- verbs:
3838
- get
@@ -47,11 +47,11 @@ apiVersion: rbac.authorization.k8s.io/v1
4747
kind: RoleBinding
4848
metadata:
4949
name: bind-default-to-opd-exec
50-
namespace: jupyter-{{ spawner.user.name }}
50+
namespace: "{{ namespace }}"
5151
subjects:
5252
- kind: ServiceAccount
5353
name: default
54-
namespace: jupyter-{{ spawner.user.name }}
54+
namespace: "{{ namespace }}"
5555
roleRef:
5656
apiGroup: rbac.authorization.k8s.io
5757
kind: Role

apphub-configurator/manifests/manifest.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,15 @@ data:
449449
# apiVersion: helm.crossplane.io/v1beta1
450450
# kind: Release
451451
# metadata:
452-
# name: wordpress-jupyter-{{ spawner.user.name }}
453-
# namespace: jupyter-{{ spawner.user.name }}
452+
# name: wordpress-{namespace}-{{ spawner.user.name }}
453+
# namespace: {namespace}-{{ spawner.user.name }}
454454
# spec:
455455
# forProvider:
456456
# chart:
457457
# name: wordpress
458458
# version: "24.1.4"
459459
# repository: oci://registry-1.docker.io/bitnamicharts/
460-
# namespace: jupyter-{{ spawner.user.name }}
460+
# namespace: {namespace}-{{ spawner.user.name }}
461461
# values:
462462
# service:
463463
# type: ClusterIP
@@ -468,7 +468,7 @@ apiVersion: external-secrets.io/v1beta1
468468
kind: ExternalSecret
469469
metadata:
470470
name: data-by-name
471-
namespace: jupyter-{{ spawner.user.name }}
471+
namespace: "{{ namespace }}"
472472
spec:
473473
refreshInterval: 15s
474474
secretStoreRef:
@@ -488,7 +488,7 @@ apiVersion: external-secrets.io/v1beta1
488488
kind: ExternalSecret
489489
metadata:
490490
name: eoepca-plus-secret-ro
491-
namespace: jupyter-{{ spawner.user.name }}
491+
namespace: "{{ namespace }}"
492492
spec:
493493
refreshInterval: 15s
494494
secretStoreRef:

application_hub_context/app_hub_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050

5151
# loads config
5252
self.config_parser = ConfigParser.read_file(
53-
config_path=config_path, user_groups=self.user_groups, spawner=self.spawner
53+
config_path=config_path, user_groups=self.user_groups, spawner=self.spawner, namespace=self.namespace
5454
)
5555

5656
# update class dict with kwargs
@@ -546,7 +546,8 @@ def patch_service_account(self, secret_name: str):
546546
def apply_manifest(self, manifest):
547547

548548
template = Template(yaml.dump(manifest))
549-
rendered_manifest = template.render(spawner=self.spawner)
549+
rendered_manifest = template.render(spawner=self.spawner,
550+
namespace=self.namespace)
550551

551552
self.spawner.log.info(f"Applying manifest name: {yaml.safe_load(rendered_manifest).get('metadata').get('name')}")
552553

application_hub_context/parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, config_data, user_groups):
1212
self.user_groups = user_groups
1313

1414
@classmethod
15-
def read_file(cls, config_path, user_groups, spawner):
15+
def read_file(cls, config_path, user_groups, spawner, namespace):
1616
"""reads a config file encoded in YAML"""
1717
with open(config_path, "r") as stream:
1818
try:
@@ -21,7 +21,8 @@ def read_file(cls, config_path, user_groups, spawner):
2121

2222
# Render the content as a Jinja2 template
2323
template = Template(raw_content)
24-
rendered_content = template.render(spawner=spawner)
24+
rendered_content = template.render(spawner=spawner,
25+
namespace=namespace)
2526

2627
# Parse the rendered content as YAML
2728
config_data = yaml.safe_load(rendered_content)

build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
docker_image_name: eoepca/application-hub
2-
docker_image_version: 1.4.1
2+
docker_image_version: 1.4.2

0 commit comments

Comments
 (0)