diff --git a/internal/suites/example/compose/nginx/backend/Dockerfile b/internal/suites/example/compose/nginx/backend/Dockerfile deleted file mode 100644 index e119e442a..000000000 --- a/internal/suites/example/compose/nginx/backend/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM nginx:alpine - -ADD html /usr/share/nginx/html -ADD nginx.conf /etc/nginx/nginx.conf \ No newline at end of file diff --git a/internal/suites/example/compose/nginx/backend/docker-compose.yml b/internal/suites/example/compose/nginx/backend/docker-compose.yml index 42cf7a6ba..49af4cacb 100644 --- a/internal/suites/example/compose/nginx/backend/docker-compose.yml +++ b/internal/suites/example/compose/nginx/backend/docker-compose.yml @@ -1,8 +1,7 @@ version: '3' services: nginx-backend: - build: - context: ./example/compose/nginx/backend + image: nginx:alpine labels: - 'traefik.frontend.rule=Host:home.example.com,public.example.com,secure.example.com,admin.example.com,singlefactor.example.com' # Traefik 1.x - 'traefik.frontend.auth.forward.address=https://authelia-backend:9091/api/verify?rd=https://login.example.com:8080/' # Traefik 1.x @@ -17,5 +16,8 @@ services: - 'traefik.http.middlewares.authelia.forwardauth.tls.insecureSkipVerify=true' # Traefik 2.x - 'traefik.http.middlewares.authelia.forwardauth.trustForwardHeader=true' # Traefik 2.x - 'traefik.http.middlewares.authelia.forwardauth.authResponseHeaders=Remote-User, Remote-Groups' # Traefik 2.x + volumes: + - ./example/compose/nginx/backend/html:/usr/share/nginx/html + - ./example/compose/nginx/backend/nginx.conf:/etc/nginx/nginx.conf networks: - authelianet \ No newline at end of file diff --git a/internal/suites/example/compose/nginx/backend/html/admin/secret.html b/internal/suites/example/compose/nginx/backend/html/admin/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/dev/groups/admin/secret.html b/internal/suites/example/compose/nginx/backend/html/dev/groups/admin/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/dev/groups/dev/secret.html b/internal/suites/example/compose/nginx/backend/html/dev/groups/dev/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/dev/users/bob/secret.html b/internal/suites/example/compose/nginx/backend/html/dev/users/bob/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/dev/users/harry/secret.html b/internal/suites/example/compose/nginx/backend/html/dev/users/harry/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/dev/users/john/secret.html b/internal/suites/example/compose/nginx/backend/html/dev/users/john/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/home/index.html b/internal/suites/example/compose/nginx/backend/html/home/index.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/icon.png b/internal/suites/example/compose/nginx/backend/html/icon.png old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/mail/secret.html b/internal/suites/example/compose/nginx/backend/html/mail/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/public/index.html b/internal/suites/example/compose/nginx/backend/html/public/index.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/public/secret.html b/internal/suites/example/compose/nginx/backend/html/public/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/secure/index.html b/internal/suites/example/compose/nginx/backend/html/secure/index.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/secure/secret.html b/internal/suites/example/compose/nginx/backend/html/secure/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/compose/nginx/backend/html/singlefactor/secret.html b/internal/suites/example/compose/nginx/backend/html/singlefactor/secret.html old mode 100644 new mode 100755 diff --git a/internal/suites/example/kube/apps/apps.yml b/internal/suites/example/kube/apps/apps.yml index b0eb2ddf9..c1870b5c5 100644 --- a/internal/suites/example/kube/apps/apps.yml +++ b/internal/suites/example/kube/apps/apps.yml @@ -17,11 +17,33 @@ spec: app: test-app spec: containers: - - name: test-app - imagePullPolicy: Never - image: nginx-backend - ports: - - containerPort: 80 + - name: test-app + image: nginx:alpine + command: ["/entrypoint.sh"] + ports: + - containerPort: 80 + volumeMounts: + - name: config-volume + mountPath: /entrypoint.sh + subPath: entrypoint.sh + - name: config-volume + mountPath: /etc/nginx/nginx.conf + subPath: nginx.conf + - name: config-volume + mountPath: /tmp/html.tar.gz + subPath: html.tar.gz + volumes: + - name: config-volume + configMap: + name: nginx-config + items: + - key: entrypoint.sh + path: entrypoint.sh + mode: 0755 + - key: nginx.conf + path: nginx.conf + - key: html.tar.gz + path: html.tar.gz --- apiVersion: v1 diff --git a/internal/suites/example/kube/apps/configs/entrypoint.sh b/internal/suites/example/kube/apps/configs/entrypoint.sh new file mode 100644 index 000000000..971912ff2 --- /dev/null +++ b/internal/suites/example/kube/apps/configs/entrypoint.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +rm -rf /usr/share/nginx/html && \ +tar xfz /tmp/html.tar.gz -C /usr/share/nginx/ && \ +nginx "-g daemon off;" \ No newline at end of file diff --git a/internal/suites/example/kube/apps/configs/html.tar.gz b/internal/suites/example/kube/apps/configs/html.tar.gz new file mode 100644 index 000000000..d2622950f Binary files /dev/null and b/internal/suites/example/kube/apps/configs/html.tar.gz differ diff --git a/internal/suites/example/kube/apps/configs/nginx.conf b/internal/suites/example/kube/apps/configs/nginx.conf new file mode 100644 index 000000000..37d20fdae --- /dev/null +++ b/internal/suites/example/kube/apps/configs/nginx.conf @@ -0,0 +1,51 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + + +http { + server { + listen 80; + root /usr/share/nginx/html/home; + server_name home.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/public; + server_name public.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/secure; + server_name secure.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/admin; + server_name admin.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/dev; + server_name dev.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/mail; + server_name mx1.mail.example.com mx2.mail.example.com; + } + + server { + listen 80; + root /usr/share/nginx/html/singlefactor; + server_name singlefactor.example.com; + } +} + diff --git a/internal/suites/example/kube/bootstrap.sh b/internal/suites/example/kube/bootstrap.sh index 32a722869..bdc087e70 100755 --- a/internal/suites/example/kube/bootstrap.sh +++ b/internal/suites/example/kube/bootstrap.sh @@ -3,6 +3,7 @@ start_apps() { # Create TLS certificate and key for HTTPS termination kubectl create secret generic test-app-tls --namespace=authelia --from-file=apps/ssl/server.key --from-file=apps/ssl/server.cert + kubectl create configmap nginx-config --namespace=authelia --from-file=apps/configs/entrypoint.sh --from-file=apps/configs/nginx.conf --from-file=apps/configs/html.tar.gz # Spawn the applications kubectl apply -f apps diff --git a/internal/suites/suite_kubernetes.go b/internal/suites/suite_kubernetes.go index a7af84f36..b33769389 100644 --- a/internal/suites/suite_kubernetes.go +++ b/internal/suites/suite_kubernetes.go @@ -22,11 +22,6 @@ func init() { return err } - cmd = utils.Shell("docker build -t nginx-backend internal/suites/example/compose/nginx/backend") - if err := cmd.Run(); err != nil { - return err - } - exists, err := kind.ClusterExists() if err != nil { @@ -115,7 +110,7 @@ func init() { func loadDockerImages() error { kind := Kind{} - images := []string{"authelia:dist", "nginx-backend"} + images := []string{"authelia:dist"} for _, image := range images { err := kind.LoadImage(image)