-
Notifications
You must be signed in to change notification settings - Fork 56
Metrics deployment #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vishnoianil
merged 7 commits into
instructlab:main
from
Gregory-Pereira:umami-metrics-deployment
Dec 11, 2024
Merged
Metrics deployment #391
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
446130d
kind docs, umami manifests, argocd app-of-apps plus umami app
Gregory-Pereira 3f15cb7
kind makefile changes, better labels in base manifests, md linting
Gregory-Pereira ee35f3f
makefile implementations, static secret to dynamic creation from env,…
Gregory-Pereira 6230ff3
updating conversion script, docs and deployment
Gregory-Pereira 5c7ecc1
allias oc back to kubectl if it doesn't exist
Gregory-Pereira f130f4c
more general db names and have default as kind with openshift overlays
Gregory-Pereira ac980b2
linting
Gregory-Pereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.