-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #391 from Gregory-Pereira/umami-metrics-deployment
Metrics deployment
- Loading branch information
Showing
20 changed files
with
570 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: app-of-apps-ilab | ||
spec: | ||
destination: | ||
namespace: openshift-gitpos | ||
name: in-cluster | ||
project: default | ||
source: | ||
path: argocd/overlays/applicaitons | ||
repoURL: https://github.com/instructlab/ui.git | ||
targetRevision: HEAD | ||
syncPolicy: | ||
syncOptions: | ||
- Validate=false | ||
- ApplyOutOfSyncOnly=true | ||
# automated: | ||
# selfHeal: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
namespace: openshift-gitops | ||
resources: | ||
# - prod.yaml # currently not deployed via argo | ||
- qa.yaml | ||
- umami.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Application | ||
metadata: | ||
name: umami | ||
spec: | ||
project: default | ||
source: | ||
repoURL: https://github.com/instructlab/ui.git | ||
path: deploy/k8s/overlays/openshift/umami | ||
targetRevision: main | ||
destination: | ||
namespace: umami | ||
name: in-cluster | ||
syncPolicy: | ||
automated: | ||
selfHeal: true | ||
|
78 changes: 78 additions & 0 deletions
78
deploy/k8s/base/umami/deploy-umami-openshift-env-secret-conversion.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
# -*- indent-tabs-mode: nil; tab-width: 2; sh-indentation: 2; -*- | ||
|
||
# Helper script to filter out `.env`` values related to umami deployment, and generate the secret manifest from that | ||
|
||
# Requires: kubectl, yq | ||
|
||
if [ -f ".env" ]; then | ||
source .env | ||
fi | ||
|
||
if [ "$#" -ne 2 ]; then | ||
echo "USAGE: $0 TARGET NAMESPACE | ||
TARGET: The deployment target. Options: [\"OPENSHIFT\", \"KIND\"] | ||
NAMESPACE: The namespace where you want to deploy the umami-secret." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
TARGET="$1" | ||
NAMESPACE="$2" | ||
|
||
if [ "${TARGET}" == "OPENSHIFT" ]; then | ||
UMAMI_SECRET_FILE_PATH="deploy/k8s/overlays/openshift/umami/umami-secret.yaml" | ||
UMAMI_DATABASE_NAME_KEY_NAME=POSTGRESQL_DATABASE | ||
UMAMI_DATABASE_USER_KEY_NAME=POSTGRESQL_USER | ||
UMAMI_DATABASE_PASSWORD_KEY_NAME=POSTGRESQL_PASSWORD | ||
elif [ "${TARGET}" == "KIND" ]; then | ||
UMAMI_SECRET_FILE_PATH="deploy/k8s/overlays/kind/umami/umami-secret.yaml" | ||
UMAMI_DATABASE_NAME_KEY_NAME=POSTGRES_DB | ||
UMAMI_DATABASE_USER_KEY_NAME=POSTGRES_USER | ||
UMAMI_DATABASE_PASSWORD_KEY_NAME=POSTGRES_PASSWORD | ||
else | ||
echo "Error, \$TARGET ${TARGET} not recongnized. | ||
TARGET options: [\"OPENSHIFT\", \"KIND\"]" | ||
exit 1 | ||
fi | ||
|
||
required_vars=("DATABASE_TYPE" "UMAMI_DATABASE_NAME" "UMAMI_DATABASE_USER" "UMAMI_DATABASE_PASSWORD" "UMAMI_APP_SECRET" "DATABASE_URL") | ||
|
||
missing_vars=() | ||
|
||
for var in "${required_vars[@]}"; do | ||
if [[ -z "${!var}" ]]; then | ||
missing_vars+=("$var") | ||
fi | ||
done | ||
|
||
if [[ ${#missing_vars[@]} -gt 0 ]]; then | ||
echo "The following environment variables are missing:" | ||
for var in "${missing_vars[@]}"; do | ||
echo " - $var" | ||
done | ||
echo "Please add these variables to your .env file." | ||
exit 1 | ||
fi | ||
|
||
cluster_domain=$(kubectl cluster-info | grep 'Kubernetes control plane' | awk -F// '{print $2}' | awk -F: '{print $1}') | ||
|
||
# Note: `.env` values get rerouted to their correct image target | ||
# Prod uses: `POSTGRESQL_DATABASE`,`POSTGRESQL_USER`, and `POSTGRESQL_PASSWORD` | ||
# Stage uses: `POSTGRES_DB`, `POSTGRES_USER` and `POSTGRES_PASSWORD` | ||
# This different is due to the differences in the `postgresql:15-alpine` image and the `registry.redhat.io/rhel9/postgresql-15:9.5-1733127512` image | ||
# Both map `UMAMI_APP_SECRET` to `APP_SECRET` | ||
|
||
kubectl create secret generic umami-secret \ | ||
--from-literal "DATABASE_TYPE=${DATABASE_TYPE}" \ | ||
--from-literal "${UMAMI_DATABASE_NAME_KEY_NAME}=${UMAMI_DATABASE_NAME}" \ | ||
--from-literal "${UMAMI_DATABASE_USER_KEY_NAME}=${UMAMI_DATABASE_USER}" \ | ||
--from-literal "${UMAMI_DATABASE_PASSWORD_KEY_NAME}=${UMAMI_DATABASE_PASSWORD}" \ | ||
--from-literal "APP_SECRET=${UMAMI_APP_SECRET}" \ | ||
--from-literal "DATABASE_URL=${DATABASE_URL}" \ | ||
--namespace "${NAMESPACE}" \ | ||
--dry-run=client \ | ||
-o yaml > ${UMAMI_SECRET_FILE_PATH} | ||
|
||
yq eval ".metadata.labels.cluster_domain = \"${cluster_domain}\"" -i ${UMAMI_SECRET_FILE_PATH} | ||
|
||
echo "Secret manifest has been created: ${UMAMI_SECRET_FILE_PATH}." |
Oops, something went wrong.