Compare commits

..
32 Commits
Author SHA1 Message Date
Adrien Bouvais 8e8ebce721 Moved back test bucket in image
Build and Push Docker Images / build-and-push (push) Successful in 1m6s
2026-08-16 13:52:05 +02:00
Adrien Bouvais 756a781524 Update notebook image path 2026-08-16 13:50:04 +02:00
Adrien Bouvais 0ffe89a881 Moved bucket test py
Build and Push Docker Images / build-and-push (push) Successful in 1m13s
2026-08-16 13:41:20 +02:00
Adrien Bouvais 5287ca66a1 Fix CI tests
Build and Push Docker Images / build-and-push (push) Successful in 1m7s
2026-08-16 13:24:03 +02:00
Adrien Bouvais cb63016421 Added tests for images building
Build and Push Docker Images / build-and-push (push) Failing after 27s
2026-08-16 10:34:32 +02:00
Adrien Bouvais 43802259ed Redo builded action to use only shell 2026-08-16 10:33:09 +02:00
Adrien Bouvais c8046eb98f Added tests to CI
Build and Push Docker Images / build-and-push (push) Failing after 58s
2026-08-15 23:21:26 +02:00
Adrien Bouvais 57d1335fba Fix
Build and Push Docker Images / build-and-push (push) Failing after 34s
2026-08-15 20:14:54 +02:00
Adrien Bouvais ea7ee88ce1 Removed unknow AI stuff 2026-08-15 20:13:43 +02:00
Adrien Bouvais a20c7e2c59 Fix
Build and Push Docker Images / build-and-push (push) Failing after 1m15s
2026-08-15 20:12:15 +02:00
Adrien Bouvais 6945db40e1 With last commit 2026-08-15 20:10:22 +02:00
Adrien Bouvais 1d8cfbfc07 Renamed test_buckets 2026-08-15 20:10:08 +02:00
Adrien Bouvais 74da180a07 Removed label
Build and Push Docker Images / build-and-push (push) Successful in 1m49s
2026-08-15 18:03:21 +02:00
Adrien Bouvais 0aa9488627 Fixs
Build and Push Docker Images / build-and-push (push) Failing after 1m34s
2026-08-15 17:19:35 +02:00
Adrien Bouvais 2782d6d43d Add base build name in jupyter step to build it
Build and Push Docker Images / build-and-push (push) Successful in 4m32s
2026-08-15 16:55:47 +02:00
Adrien Bouvais 82cf6bf7e6 Only on tag push
Build and Push Docker Images / build-and-push (push) Failing after 1m36s
2026-08-15 16:49:27 +02:00
Adrien Bouvais 7662463c7d Removed CI condition
Build and Push Docker Images / build-and-push (push) Failing after 2m58s
2026-08-15 16:45:26 +02:00
Adrien Bouvais 9ee2fd2837 Fix pipeline cred 2026-08-15 16:41:19 +02:00
Adrien Bouvais 2fef740a5f Added tenant-b + removed name in config to use path
Build and Push Docker Images / build-and-push (push) Failing after 29s
2026-08-15 16:38:02 +02:00
Adrien Bouvais 7abb8db1e4 Removed comments
Build and Push Docker Images / build-and-push (push) Failing after 4m51s
2026-08-15 16:26:41 +02:00
Adrien Bouvais 189a3c4e0c Added images build CI 2026-08-15 16:23:57 +02:00
Adrien Bouvais a5b006f728 Better script test + renamed AWS env var to MINIO 2026-08-15 16:23:02 +02:00
Adrien Bouvais e7b8102733 Fix 2026-08-15 16:18:25 +02:00
Adrien Bouvais 216b77c2ea Add hello file in ref bucket 2026-08-15 16:02:56 +02:00
Adrien Bouvais bae53cc0a4 Project can create namespace 2026-08-15 11:50:51 +02:00
Adrien Bouvais 714db6f03d Fix 2026-08-15 11:06:11 +02:00
Adrien Bouvais dcf9877fd0 Added tenant to minio policy name 2026-08-15 11:04:07 +02:00
Adrien Bouvais 3d3655a95e Prevent error if IAM already set 2026-08-15 11:03:01 +02:00
Adrien Bouvais 70c70ce756 Added a test script to notebook image 2026-08-15 10:04:27 +02:00
Adrien Bouvais ee2f211774 Added delay to deploy, to lets the passeword generate 2026-08-15 09:55:25 +02:00
Adrien Bouvais 4b3bb98bd5 Made minio setup more robustre 2026-08-15 09:54:43 +02:00
Adrien Bouvais 7e82888149 Added missing var 2026-08-15 09:27:40 +02:00
13 changed files with 166 additions and 37 deletions
+78
View File
@@ -0,0 +1,78 @@
name: Build and Push Docker Images
on:
push:
tags:
- '*.*.*'
env:
REGISTRY: registry.bouvais.lu
BASE_IMAGE_NAME: tenant/base
JUPYTER_IMAGE_NAME: tenant/jupyter
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
run: |
docker login ${{ env.REGISTRY }} \
--username adrien \
--password "${{ secrets.DOCKER_PASSWORD }}"
# --- 1. BUILD & TEST BASE IMAGE ---
- name: Build Base image
run: |
docker build \
-f ./images/base/dockerfile \
-t ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
./images/base
- name: Test Base image
run: |
cid=$(docker create -u root -w /tests ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} sleep 60)
docker start "$cid"
docker cp ${{ github.workspace }}/tests/. "$cid":/tests
docker exec "$cid" python3 /tests/base.py
docker rm -f "$cid"
- name: Tag Base image as latest
run: |
docker tag ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
- name: Push Base image
run: |
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }}
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
# --- 2. BUILD & TEST JUPYTER IMAGE ---
- name: Build Jupyter image
run: |
docker build \
-f ./images/jupyter/dockerfile \
--build-arg BASE_IMAGE=${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
-t ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} \
./images/jupyter
- name: Test Jupyter dependencies
run: |
cid=$(docker create -w /tests ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} sleep 60)
docker start "$cid"
docker cp ${{ github.workspace }}/tests/. "$cid":/tests
docker exec "$cid" python3 /tests/dependencies.py
docker rm -f "$cid"
- name: Tag Jupyter image as latest
run: |
docker tag ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} \
${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:latest
- name: Push Jupyter image
run: |
docker push ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }}
docker push ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:latest
+2
View File
@@ -6,6 +6,8 @@ metadata:
labels: labels:
app: jupyter app: jupyter
tenant: 'tenant-{{.Values.name}}' tenant: 'tenant-{{.Values.name}}'
annotations:
argocd.argoproj.io/sync-wave: "1"
spec: spec:
replicas: 1 replicas: 1
selector: selector:
+15 -9
View File
@@ -32,12 +32,12 @@ spec:
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: s3-credentials name: s3-credentials
key: AWS_ACCESS_KEY_ID key: MINIO_ACCESS_KEY_ID
- name: TENANT_PASS - name: TENANT_PASS
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: s3-credentials name: s3-credentials
key: AWS_SECRET_ACCESS_KEY key: MINIO_SECRET_ACCESS_KEY
- name: BUCKET_REF - name: BUCKET_REF
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
@@ -52,15 +52,20 @@ spec:
- /bin/sh - /bin/sh
- -c - -c
- | - |
# Connect to MinIO using admin secret from env # Fail immediately if any command fails
mc alias set minioadmin http://minio.minio.svc.cluster.local:9000 $MINIO_ADMIN_USER $MINIO_ADMIN_PASS set -e
# Connect to MinIO using quotes to protect special characters in passwords
mc alias set minioadmin http://minio.minio.svc.cluster.local:9000 "$MINIO_ADMIN_USER" "$MINIO_ADMIN_PASS"
# Create buckets # Create buckets
mc mb --ignore-existing minioadmin/$BUCKET_REF mc mb --ignore-existing minioadmin/$BUCKET_REF
mc mb --ignore-existing minioadmin/$BUCKET_WORK mc mb --ignore-existing minioadmin/$BUCKET_WORK
# Create tenant user using randomly generated password echo "hello tenant-{{ .Values.name }}" | mc pipe minioadmin/$BUCKET_REF/hello.txt
mc admin user add minioadmin $TENANT_USER $TENANT_PASS || true
# Create tenant user (REMOVED || true)
mc admin user add minioadmin "$TENANT_USER" "$TENANT_PASS"
# Apply IAM isolation policy # Apply IAM isolation policy
cat <<EOF > /tmp/policy.json cat <<EOF > /tmp/policy.json
@@ -89,6 +94,7 @@ spec:
} }
EOF EOF
mc admin policy create minioadmin {{ .Values.name }}-policy /tmp/policy.json || mc admin policy update minioadmin {{ .Values.name }}-policy /tmp/policy.json mc admin policy create minioadmin tenant-{{ .Values.name }}-policy /tmp/policy.json || mc admin policy update minioadmin tenant-{{ .Values.name }}-policy /tmp/policy.json
mc admin policy attach minioadmin {{ .Values.name }}-policy --user=$TENANT_USER # Good enough for now, would need better error handeling
echo "MinIO setup completed for {{ .Values.name }}" mc admin policy attach minioadmin tenant-{{ .Values.name }}-policy --user="$TENANT_USER" || echo "Policy already attached, skipping."
echo "MinIO setup completed for tenant-{{ .Values.name }}"
+3 -2
View File
@@ -1,3 +1,4 @@
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace "s3-credentials" -}}
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
@@ -7,9 +8,9 @@ metadata:
app.kubernetes.io/tenant: 'tenant-{{ .Values.name }}' app.kubernetes.io/tenant: 'tenant-{{ .Values.name }}'
type: Opaque type: Opaque
stringData: stringData:
AWS_ACCESS_KEY_ID: 'tenant-{{ .Values.name }}-user' MINIO_ACCESS_KEY_ID: 'tenant-{{ .Values.name }}-user'
# If the secret exist, keep. Otherwise create a new random one. (To prevent a new password at each sync). # If the secret exist, keep. Otherwise create a new random one. (To prevent a new password at each sync).
AWS_SECRET_ACCESS_KEY: {{ if and $existingSecret $existingSecret.data (hasKey $existingSecret.data "AWS_SECRET_ACCESS_KEY") }}{{ index $existingSecret.data "AWS_SECRET_ACCESS_KEY" | b64dec }}{{ else }}{{ randAlphaNum 24 }}{{ end }} MINIO_SECRET_ACCESS_KEY: {{ if and $existingSecret $existingSecret.data (hasKey $existingSecret.data "AWS_SECRET_ACCESS_KEY") }}{{ index $existingSecret.data "AWS_SECRET_ACCESS_KEY" | b64dec }}{{ else }}{{ randAlphaNum 24 }}{{ end }}
S3_ENDPOINT: "http://minio.minio.svc.cluster.local:9000" S3_ENDPOINT: "http://minio.minio.svc.cluster.local:9000"
BUCKET_REF: "ref-tenant-{{ .Values.name }}" BUCKET_REF: "ref-tenant-{{ .Values.name }}"
BUCKET_WORK: "work-tenant-{{ .Values.name }}" BUCKET_WORK: "work-tenant-{{ .Values.name }}"
+7 -3
View File
@@ -5,6 +5,7 @@ metadata:
namespace: argocd namespace: argocd
spec: spec:
goTemplate: true goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators: generators:
- git: - git:
repoURL: https://git.bouvais.lu/adrien/ctie-exercice repoURL: https://git.bouvais.lu/adrien/ctie-exercice
@@ -13,7 +14,7 @@ spec:
- path: "tenants/*/config.yaml" - path: "tenants/*/config.yaml"
template: template:
metadata: metadata:
name: 'tenant-{{.name}}' name: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
spec: spec:
project: tenants project: tenants
sources: sources:
@@ -22,13 +23,16 @@ spec:
path: charts/tenant path: charts/tenant
helm: helm:
valueFiles: valueFiles:
- '$values/tenants/tenant-{{.name}}/config.yaml' - '$values/{{.path.path}}/config.yaml'
parameters:
- name: name
value: '{{ trimPrefix "tenant-" .path.basename }}'
- repoURL: https://git.bouvais.lu/adrien/ctie-exercice - repoURL: https://git.bouvais.lu/adrien/ctie-exercice
targetRevision: main targetRevision: main
ref: values ref: values
destination: destination:
server: https://kubernetes.default.svc server: https://kubernetes.default.svc
namespace: 'tenant-{{.name}}' namespace: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
syncPolicy: syncPolicy:
automated: automated:
prune: true prune: true
+5 -1
View File
@@ -9,7 +9,11 @@ spec:
destinations: destinations:
- server: https://kubernetes.default.svc - server: https://kubernetes.default.svc
namespace: 'tenant-*' namespace: 'tenant-*'
clusterResourceWhitelist: [] # tenants can't touch cluster-scoped resources
clusterResourceWhitelist:
- group: ''
kind: Namespace
namespaceResourceWhitelist: namespaceResourceWhitelist:
- group: '*' - group: '*'
kind: '*' kind: '*'
-7
View File
@@ -1,17 +1,11 @@
FROM python:3.12-slim-bookworm AS base FROM python:3.12-slim-bookworm AS base
LABEL org.opencontainers.image.title="tenant-base" \
org.opencontainers.image.description="Hardened base image for tenant workspaces" \
org.opencontainers.image.source="https://git.bouvais.lu/adrien/"
# System deps only — keep this layer stable so it's rarely rebuilt
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \ ca-certificates \
curl \ curl \
tini \ tini \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Non-root user, fixed UID/GID for predictable K8s securityContext
RUN groupadd --gid 1000 appuser \ RUN groupadd --gid 1000 appuser \
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser && useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
@@ -19,4 +13,3 @@ WORKDIR /home/appuser
USER appuser USER appuser
ENTRYPOINT ["tini", "--"] ENTRYPOINT ["tini", "--"]
+2 -6
View File
@@ -1,16 +1,12 @@
ARG BASE_IMAGE=registry.bouvais.lu/tenant-base:1.0.0 ARG BASE_IMAGE
FROM ${BASE_IMAGE} FROM ${BASE_IMAGE}
LABEL org.opencontainers.image.title="tenant-jupyter" \
org.opencontainers.image.description="JupyterLab image built on tenant-base" \
org.opencontainers.image.base.name="${BASE_IMAGE}"
USER root USER root
COPY --chown=appuser:appuser test_buckets.py /home/appuser/work/test_buckets.py
COPY --chown=appuser:appuser requirements.txt /tmp/requirements.txt COPY --chown=appuser:appuser requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt \ RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& rm /tmp/requirements.txt && rm /tmp/requirements.txt
# No secrets baked in — S3 creds come from a mounted K8s Secret / env at runtime
USER appuser USER appuser
WORKDIR /home/appuser/work WORKDIR /home/appuser/work
+37
View File
@@ -0,0 +1,37 @@
import os
import boto3
s3 = boto3.client(
's3',
endpoint_url=os.environ['S3_ENDPOINT'],
aws_access_key_id=os.environ['MINIO_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['MINIO_SECRET_ACCESS_KEY']
)
ref_bucket = os.environ['BUCKET_REF']
work_bucket = os.environ['BUCKET_WORK']
# 1. READ FROM REFERENCE BUCKET (Should PASS)
response = s3.list_objects_v2(Bucket=ref_bucket)
data = s3.get_object(Bucket=ref_bucket, Key="hello.txt")['Body'].read()
print("SUCCESS: List items in ref bucket:", response['KeyCount'], data.decode())
# 2. WRITE TO REFERENCE BUCKET (Should FAIL with 403 Forbidden)
try:
s3.put_object(Bucket=ref_bucket, Key="test.txt", Body=b"forbidden write")
print("ERROR: Write succeeded when it should be forbidden!")
except Exception as e:
print("SUCCESS: Write to reference bucket blocked:", e)
# 3. WRITE & READ WORK BUCKET (Should PASS)
s3.put_object(Bucket=work_bucket, Key="data.txt", Body=b"hello tenant")
data = s3.get_object(Bucket=work_bucket, Key="data.txt")['Body'].read()
print("SUCCESS: Read back from work bucket:", data.decode())
# 4. ACCESS OTHER TENANT BUCKET (Should FAIL with Access Denied)
try:
s3.list_objects_v2(Bucket="work-tenant-b")
print("ERROR: Accessed tenant-b bucket!")
except Exception as e:
print("SUCCESS: Access to tenant-b blocked:", e)
+2 -9
View File
@@ -1,8 +1,6 @@
name: "a" # TODO: Remove this and use path instead
image: image:
repository: registry.bouvais.lu/tenant-jupyter repository: registry.bouvais.lu/tenant/jupyter
tag: "1.0.0" tag: "1.0.1"
resources: resources:
requests: requests:
@@ -12,8 +10,3 @@ resources:
cpu: "1" cpu: "1"
memory: 2Gi memory: 2Gi
gpu:
enabled: true
type: "t4" # one of: none | t4 | a100 | l4
count: 1
+11
View File
@@ -0,0 +1,11 @@
image:
repository: registry.bouvais.lu/tenant/jupyter
tag: "1.0.1"
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: "1"
memory: 2Gi
+1
View File
@@ -0,0 +1 @@
print("SUCCESS: Python works.")
+3
View File
@@ -0,0 +1,3 @@
import os
import boto3
print("SUCCESS: Import works.")