commit 4f9eb3ddf83c0346acbf2e125a9e3d9c7218f02e Author: Nicolas MASSE Date: Fri Apr 2 12:37:12 2021 +0200 initial commit diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..8d1e106 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,7 @@ +FROM registry.access.redhat.com/ubi8/nginx-118 + +# Add application sources +ADD index.html . + +# Run script uses standard ways to run the application +CMD nginx -g "daemon off;" diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..a2a0f6f --- /dev/null +++ b/build/README.md @@ -0,0 +1,6 @@ +# Build the application + +```sh +podman login quay.io +./build.sh +``` diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 0000000..bec776a --- /dev/null +++ b/build/build.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -Eeuo pipefail + +echo "Building the container image..." +podman build -t multi-cluster-app:latest . + +echo "Running it..." +podman run -d --rm --name multi-cluster-app -p 8080:8080 multi-cluster-app:latest +trap "podman stop multi-cluster-app" EXIT + +echo "Testing it..." +sleep 2 +curl -s -o /dev/null -w "HTTP status code: %{http_code}\n" http://localhost:8080/ + +echo "Pushing to Quay.io..." +podman tag multi-cluster-app:latest quay.io/nmasse_itix/multi-cluster-app:latest +podman push quay.io/nmasse_itix/multi-cluster-app:latest diff --git a/build/index.html b/build/index.html new file mode 100644 index 0000000..4d502c8 --- /dev/null +++ b/build/index.html @@ -0,0 +1,5 @@ + + +

DEFAULT

+ + diff --git a/deploy/base/config.yaml b/deploy/base/config.yaml new file mode 100644 index 0000000..66150a1 --- /dev/null +++ b/deploy/base/config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: multi-cluster-config +data: + index.html: | + + +

BASE

+ + diff --git a/deploy/base/deployment.yaml b/deploy/base/deployment.yaml new file mode 100644 index 0000000..1fab73d --- /dev/null +++ b/deploy/base/deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: multi-cluster-app +spec: + replicas: 1 + selector: + matchLabels: + app: multi-cluster-app + template: + metadata: + labels: + app: multi-cluster-app + spec: + containers: + - name: nginx + image: quay.io/nmasse_itix/multi-cluster-app:latest + ports: + - containerPort: 8080 + volumeMounts: + - name: config + mountPath: /opt/app-root/src + volumes: + - name: config + configMap: + name: multi-cluster-config diff --git a/deploy/base/kustomization.yaml b/deploy/base/kustomization.yaml new file mode 100644 index 0000000..1e4c3cc --- /dev/null +++ b/deploy/base/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- deployment.yaml +- service.yaml +- config.yaml +- route.yaml diff --git a/deploy/base/route.yaml b/deploy/base/route.yaml new file mode 100644 index 0000000..2f3df2a --- /dev/null +++ b/deploy/base/route.yaml @@ -0,0 +1,14 @@ +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: multi-cluster-app +spec: + port: + targetPort: 8080 + tls: + termination: edge + to: + kind: Service + name: multi-cluster-app + weight: 100 + wildcardPolicy: None diff --git a/deploy/base/service.yaml b/deploy/base/service.yaml new file mode 100644 index 0000000..1057532 --- /dev/null +++ b/deploy/base/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: multi-cluster-app + labels: + app: multi-cluster-app +spec: + ports: + - port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: multi-cluster-app diff --git a/deploy/overlays/prod-dc1/config.yaml b/deploy/overlays/prod-dc1/config.yaml new file mode 100644 index 0000000..872eafc --- /dev/null +++ b/deploy/overlays/prod-dc1/config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: multi-cluster-config +data: + index.html: | + + +

PROD-DC1

+ + diff --git a/deploy/overlays/prod-dc1/kustomization.yaml b/deploy/overlays/prod-dc1/kustomization.yaml new file mode 100644 index 0000000..d869ba2 --- /dev/null +++ b/deploy/overlays/prod-dc1/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +bases: +- ../../base + +patchesStrategicMerge: +- config.yaml diff --git a/deploy/overlays/prod-dc2/config.yaml b/deploy/overlays/prod-dc2/config.yaml new file mode 100644 index 0000000..2de0ee6 --- /dev/null +++ b/deploy/overlays/prod-dc2/config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: multi-cluster-config +data: + index.html: | + + +

PROD-DC2

+ + diff --git a/deploy/overlays/prod-dc2/kustomization.yaml b/deploy/overlays/prod-dc2/kustomization.yaml new file mode 100644 index 0000000..d869ba2 --- /dev/null +++ b/deploy/overlays/prod-dc2/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +bases: +- ../../base + +patchesStrategicMerge: +- config.yaml