Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
d9791b2
wip
punkwalker Jun 3, 2025
401b45e
wip
punkwalker Jun 3, 2025
1dda815
add external-dns addon
punkwalker Jun 3, 2025
48a0e73
add cert-manager and argocd ingress
punkwalker Jun 3, 2025
74af5b7
disable redis for argocd
punkwalker Jun 3, 2025
ce0fb32
enable redis for argocd
punkwalker Jun 3, 2025
5e4d49b
add letsencrypt ClusterIssuer for cert-manager
punkwalker Jun 3, 2025
12d47d4
specify ingress specific values for argocd
punkwalker Jun 3, 2025
7818dbe
add keycloak addon
punkwalker Jun 4, 2025
ce22be5
refactor hub addons from Apps to AppSet
punkwalker Jun 5, 2025
2a61636
move github token externalsecret to argocd manifests
punkwalker Jun 6, 2025
0303b01
match ServerSideApply on github-token external secret
punkwalker Jun 6, 2025
2e29ed2
match argocd and external secret to AppSets
punkwalker Jun 6, 2025
63fcf4c
add keycloak addon
punkwalker Jun 6, 2025
a5e42cd
update ExternalSecrets to avoid Diffs
punkwalker Jun 6, 2025
f64bd3e
add keycloak config job to create users
punkwalker Jun 7, 2025
14ed10e
add argocd keycloak sso config job
punkwalker Jun 8, 2025
884d6cb
add backstage addon
punkwalker Jun 10, 2025
6a0fe7d
fix dataFromn extraction of backstage postres password
punkwalker Jun 10, 2025
37b0adf
fix dataFromn extraction of backstage postres password
punkwalker Jun 10, 2025
e472ed5
fix dataFromn extraction of backstage postres password
punkwalker Jun 10, 2025
9d75d97
fix backstage postgres sts
punkwalker Jun 10, 2025
6a9245c
fix backstage app config
punkwalker Jun 10, 2025
12cc78c
fix backstage env vars secret
punkwalker Jun 10, 2025
0d230d6
fix backstage db config
punkwalker Jun 10, 2025
d05a342
fix backstage argo workflow URL
punkwalker Jun 10, 2025
5f9661c
fix backstage rback template
punkwalker Jun 10, 2025
c23141a
add backstage ingress
punkwalker Jun 10, 2025
5604b73
add backstage ingress
punkwalker Jun 10, 2025
41f754f
update uninstall.sh
punkwalker Jun 10, 2025
f25effc
move backstage PVC to sts
punkwalker Jun 10, 2025
7beeda4
move backstage PVC to sts
punkwalker Jun 10, 2025
81dd746
restucture directories
punkwalker Jun 10, 2025
960ba6f
add keycloak password generation using eso
punkwalker Jun 11, 2025
ca65b91
fix keycloak external secret
punkwalker Jun 11, 2025
6249c1e
fix keycloak external secret
punkwalker Jun 11, 2025
b8a4859
fix keycloak external secret
punkwalker Jun 11, 2025
777f128
fix keycloak external secret
punkwalker Jun 11, 2025
f310e41
fix keycloak external secret
punkwalker Jun 11, 2025
d852a27
fix keycloak external secret
punkwalker Jun 11, 2025
c834184
fix backstage github integration secret
punkwalker Jun 11, 2025
e1c4fe3
fix backstage github integration secret
punkwalker Jun 11, 2025
c326f9b
disable argocd dex server
punkwalker Jun 11, 2025
18b873a
refactor install and uninstall script
punkwalker Jun 11, 2025
6ff47de
fix keycloak user password
punkwalker Jun 11, 2025
d0ea903
add argo workflows addon
punkwalker Jun 12, 2025
65859cd
fix cluster secret annotations
punkwalker Jun 12, 2025
863d407
fix cluster secret annotations
punkwalker Jun 12, 2025
09f8e21
fix argo workflow ingress
punkwalker Jun 12, 2025
6602ab4
fix argo workflow oidc config
punkwalker Jun 12, 2025
a79b6db
fix argo workflow oidc config
punkwalker Jun 12, 2025
7327591
add argo workflows admin rbac
punkwalker Jun 12, 2025
7005956
fix argo workflow external secret
punkwalker Jun 12, 2025
964d4c6
enable keycloak backchannel
punkwalker Jun 12, 2025
0bcc0e5
disable keycloak backchannel
punkwalker Jun 12, 2025
fbbfb47
set up order in keycloak resources
punkwalker Jun 12, 2025
e34141b
refactor appset chart deployment logic
punkwalker Jun 12, 2025
f5ea639
remove namespace resource from backstage chart
punkwalker Jun 12, 2025
c2aa344
enable preserveResourcesOnDeletion on AppSets
punkwalker Jun 12, 2025
a82cb2c
enable pathRouting option
punkwalker Jun 13, 2025
635b606
fix addon values file
punkwalker Jun 13, 2025
511704c
fix appset chart indent and addons values
punkwalker Jun 13, 2025
3fcf81a
fix ingress-nginx values
punkwalker Jun 13, 2025
86bb32f
fix ingress-nginx values
punkwalker Jun 13, 2025
1e4eb0c
fix ingress-nginx values
punkwalker Jun 13, 2025
d1759ce
fix annotations map for ingresses
punkwalker Jun 13, 2025
a06f7b3
add external-dns service annotation on ingress-nginx
punkwalker Jun 13, 2025
df7aa16
refactor bootstrapping logic
punkwalker Jun 16, 2025
b873cd4
refactor bootstrapping logic
punkwalker Jun 16, 2025
052269a
support path-routing on argocd
punkwalker Jun 17, 2025
f92b374
support path-routing on argocd
punkwalker Jun 17, 2025
2ce1768
support path-routing on argocd
punkwalker Jun 17, 2025
9893cba
support path-routing on argocd
punkwalker Jun 17, 2025
d9c8beb
fix appset chart
punkwalker Jun 17, 2025
29e459e
fix appset chart
punkwalker Jun 17, 2025
a62c12b
fix appset chart
punkwalker Jun 17, 2025
7c10ef7
fix appset chart
punkwalker Jun 17, 2025
01d3200
fix argo-cd-path-routing
punkwalker Jun 17, 2025
cf18ba8
fix cert-manager addon for path routing
punkwalker Jun 17, 2025
31b15d8
delay ingress creation for argocd until default cert is provisioned
punkwalker Jun 17, 2025
e8c3d31
fix argocd valuesObject
punkwalker Jun 17, 2025
1529c52
fix argocd valuesObject
punkwalker Jun 17, 2025
f0fa842
fix argocd valuesObject
punkwalker Jun 17, 2025
ae09b3a
fix argocd valuesObject
punkwalker Jun 17, 2025
c9149f0
refactor bootstrapping logic
punkwalker Jun 17, 2025
db900e0
refactor keycloak addon for path routing
punkwalker Jun 17, 2025
34cfc9d
fix keyloak internal url
punkwalker Jun 17, 2025
0345b02
fix keyloak internal url
punkwalker Jun 17, 2025
968ac4e
fix keyloak sso config job
punkwalker Jun 17, 2025
02a304a
fix argocd internal url in keycloak sso job
punkwalker Jun 17, 2025
be12896
refactor argocd oidc config
punkwalker Jun 17, 2025
0009741
refactor backstage addon for path routing
punkwalker Jun 17, 2025
42196f1
add sync wave to nginx service
punkwalker Jun 18, 2025
d7ca8ec
fix backstage ingress values
punkwalker Jun 18, 2025
173d031
fix backstage chart
punkwalker Jun 18, 2025
2b57258
support relative path on backstage
punkwalker Jun 18, 2025
037988a
support relative path on backstage
punkwalker Jun 18, 2025
0bdee0a
support relative path on backstage
punkwalker Jun 18, 2025
2ebe7f0
support relative path on backstage
punkwalker Jun 18, 2025
c399c2b
support relative path on backstage
punkwalker Jun 18, 2025
3306b88
support relative path on backstage
punkwalker Jun 18, 2025
4e07b83
update backstage image
punkwalker Jun 18, 2025
f865030
update backstage image
punkwalker Jun 18, 2025
622df4c
fix backstage keycloak integration
punkwalker Jun 18, 2025
dbeba30
fix backstage argocd integration
punkwalker Jun 18, 2025
4e42f47
fix backstage frontend URL
punkwalker Jun 18, 2025
ed23c5b
fix keycloak redirect url for backstage
punkwalker Jun 18, 2025
2363468
support relative path on argo workflows
punkwalker Jun 18, 2025
699238a
change external dns policy to sync to ensure it can add/remove records
punkwalker Jun 19, 2025
ca61e44
add crossplane addon
punkwalker Jun 19, 2025
7a4a322
fix keycloak cert namespace
punkwalker Jun 19, 2025
3160b94
remove enable-environment-configs flag from crossplane
punkwalker Jun 19, 2025
4478d54
restructure crossplane directory
punkwalker Jun 19, 2025
c8cddb9
add commonAnnotations to kustomization for xrd in crossplane addon
punkwalker Jun 19, 2025
d82890e
remove reduntant directories
punkwalker Jun 19, 2025
d58b989
fix backstage app config keycloak config
punkwalker Jun 19, 2025
4787635
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
4f7b128
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
4e45233
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
f628b81
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
4b2fef0
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
51cfc72
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
96a874f
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
8b5e79b
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
ae58d30
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
5847a2d
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
febbc4b
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
6bc18f9
fix argo workflows ingress for path routing
punkwalker Jun 19, 2025
142a6b3
make argocd install all resources from packages/crossplane/manifests …
punkwalker Jun 19, 2025
39337f7
make argocd install all resources from packages/crossplane/manifests …
punkwalker Jun 19, 2025
9a9e5a3
fix crossplane aws DeploymentRuntimeConfig
punkwalker Jun 19, 2025
856144d
fix crossplane aws DeploymentRuntimeConfig selector
punkwalker Jun 19, 2025
11a5c99
fix crossplane aws DeploymentRuntimeConfig selector
punkwalker Jun 19, 2025
88adb0d
fix provider-aws-s3 runtimeConfigRef
punkwalker Jun 19, 2025
1c62a50
specify serviceAccountName in DeploymentRuntimeConfig for crossplane …
punkwalker Jun 19, 2025
0415849
add generic ServiceAccount for provider-aws
punkwalker Jun 19, 2025
36f2085
fix generic ServiceAccount for provider-aws
punkwalker Jun 20, 2025
564420a
remove sync wave from crossplane custom manifests
punkwalker Jun 20, 2025
b83ba60
add sync wave from crossplane custom manifests
punkwalker Jun 20, 2025
c877806
remove crossplane custom manifests
punkwalker Jun 20, 2025
7d2a0a4
change password constraints for keycloak user
punkwalker Jun 20, 2025
dc9a555
add crossplane provider chart and refactor crossplane compositions
punkwalker Jun 23, 2025
e143d44
move cluster issuer to cert-manager extraObjects in helm values file
punkwalker Jun 23, 2025
1f46ccb
clean values.yamls of addons
punkwalker Jun 23, 2025
2a9a060
clean values.yamls of addons
punkwalker Jun 23, 2025
09940f0
remove selectors from addons
punkwalker Jun 23, 2025
4d520ac
fix AWS LBC Cluster name substitution
punkwalker Jun 23, 2025
89f8cf6
fix Argo Workflow values in AppSet
punkwalker Jun 23, 2025
d8bcd4c
fix crossplane registry url
punkwalker Jun 24, 2025
f8a02c5
refactor addons
punkwalker Jun 24, 2025
5af8122
add webhook url to backstage GH app
punkwalker Jun 24, 2025
ece6c2b
add backstage templates
punkwalker Jun 24, 2025
6a4e88a
fix backstage template location
punkwalker Jun 24, 2025
61e257e
add ARGOCD Password to backstage
punkwalker Jun 24, 2025
285a5af
add GH app for org and fix backstage skeleton
punkwalker Jun 24, 2025
391eeb6
add eksctl cluster creation
punkwalker Jun 24, 2025
a9181de
add eksctl cluster creation for auto mode
punkwalker Jun 24, 2025
bf11489
disable aws lbc for auto mode
punkwalker Jun 24, 2025
1eb4e70
remove reduntant directories
punkwalker Jun 24, 2025
1e2ca5f
remove sync wave from argocd ingress
punkwalker Jun 25, 2025
12a3aea
specify storageclass for keycloak pvc
punkwalker Jun 25, 2025
c6a9e35
specify storageclass for backstage pvc
punkwalker Jun 25, 2025
4cb016f
enable ServerSideDiff for crossplane-compositions
punkwalker Jun 25, 2025
4739bce
enable ServerSideDiff for crossplane-compositions
punkwalker Jun 25, 2025
d3dadb3
add sync wave for argocd ingress
punkwalker Jun 25, 2025
eb74c04
add sync wave for argocd ingress
punkwalker Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move backstage PVC to sts
Signed-off-by: Pankaj Walke <[email protected]>
  • Loading branch information
punkwalker committed Jun 10, 2025
commit f25effc256878da32b84ada8e73abbc2bf86d2e3
29 changes: 9 additions & 20 deletions packages/backstage/chart/templates/postgresql.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
{{- if .Values.postgresql.enabled -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "postgresql.fullname" . }}
namespace: {{ .Values.namespace }}
labels:
app: {{ include "postgresql.fullname" . }}
{{- include "backstage.labels" . | nindent 4 }}
spec:
storageClassName: {{ .Values.postgresql.persistence.storageClass }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.postgresql.persistence.size }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -50,10 +34,15 @@ spec:
- name: data
mountPath: /var/lib/postgresql/data
subPath: postgress
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ include "postgresql.fullname" . }}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.postgresql.persistence.size }}
---
apiVersion: v1
kind: Service
Expand Down
197 changes: 111 additions & 86 deletions packages/keycloak/manifests/user-sso-config-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,128 +257,153 @@ spec:
set -ex -o pipefail
apt -qq update && apt -qq install curl jq gettext-base -y

# Get Keycloak token for intial Admin user
# Define helper functions
keycloak_post() {
local endpoint=$1
local payload=$2
local resource_name=$3

HTTP_STATUS=$(curl -sS -w "%{http_code}" -o /tmp/response.txt -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @${payload} \
${KEYCLOAK_URL}${endpoint})

if [ "$HTTP_STATUS" -eq 409 ]; then
echo "${resource_name} already exists, continuing..."
elif [ "$HTTP_STATUS" -ne 201 ] && [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error creating ${resource_name}: HTTP status $HTTP_STATUS"
cat /tmp/response.txt
fi
}

keycloak_put() {
local endpoint=$1
local resource_name=$2

HTTP_STATUS=$(curl -sS -w "%{http_code}" -o /tmp/response.txt -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT ${KEYCLOAK_URL}${endpoint})

if [ "$HTTP_STATUS" -ne 204 ] && [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error updating ${resource_name}: HTTP status $HTTP_STATUS"
cat /tmp/response.txt
fi
}

keycloak_get() {
local endpoint=$1
local jq_filter=$2

curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}${endpoint} | jq -e -r "${jq_filter}"
}

# Get Keycloak token for initial Admin user
ADMIN_PASSWORD=$(cat /var/secrets/KEYCLOAK_ADMIN_PASSWORD)
KEYCLOAK_URL=http://keycloak.keycloak.svc.cluster.local:80
USER1_PASSWORD=$(cat /var/secrets/USER1_PASSWORD)
KEYCLOAK_TOKEN=$(curl -sS --fail-with-body -X POST -H "Content-Type: application/x-www-form-urlencoded" \
HTTP_STATUS=$(curl -sS -w "%{http_code}" -o /tmp/response.txt -X POST -H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "username=cnoe-admin" \
--data-urlencode "password=${ADMIN_PASSWORD}" \
--data-urlencode "grant_type=password" \
--data-urlencode "client_id=admin-cli" \
${KEYCLOAK_URL}/realms/cnoe/protocol/openid-connect/token | jq -e -r '.access_token')

set +e
${KEYCLOAK_URL}/realms/cnoe/protocol/openid-connect/token)
if [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error getting Keycloak token: HTTP status $HTTP_STATUS"
cat /tmp/response.txt
exit 1
fi
KEYCLOAK_TOKEN=$(cat /tmp/response.txt | jq -e -r '.access_token')

curl --fail-with-body -H "Authorization: bearer ${KEYCLOAK_TOKEN}" "${KEYCLOAK_URL}/admin/realms/cnoe" &> /dev/null
if [ $? -ne 0 ]; then
HTTP_STATUS=$(curl -sS -w "%{http_code}" -o /tmp/response.txt -H "Authorization: bearer ${KEYCLOAK_TOKEN}" "${KEYCLOAK_URL}/admin/realms/cnoe")
if [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error validating Keycloak token: HTTP status $HTTP_STATUS"
cat /tmp/response.txt
exit 1
fi
set -e

# Download kubectl
curl -sS -LO "https://dl.k8s.io/release/v1.28.3//bin/linux/amd64/kubectl"
chmod +x kubectl

echo "creating client scopes"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/client-scope-groups-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes
keycloak_post "/admin/realms/cnoe/client-scopes" "/var/config/client-scope-groups-payload.json" "Client scope"

echo "creating admin group"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/group-admin-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/groups
keycloak_post "/admin/realms/cnoe/groups" "/var/config/group-admin-payload.json" "Admin group"

echo "creating base-user group"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/group-base-user-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/groups
keycloak_post "/admin/realms/cnoe/groups" "/var/config/group-base-user-payload.json" "Base-user group"

echo "adding group claim to tokens"
CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')

curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/group-mapper-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes/${CLIENT_SCOPE_GROUPS_ID}/protocol-mappers/models

echo "creating user1"
jq --arg pwd "$USER1_PASSWORD" '.credentials[0].value = $pwd' /var/config/user1-payload.json > user1-payload-with-password.json
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @user1-payload-with-password.json \
${KEYCLOAK_URL}/admin/realms/cnoe/users
CLIENT_SCOPE_GROUPS_ID=$(keycloak_get "/admin/realms/cnoe/client-scopes" '.[] | select(.name == "groups") | .id')

keycloak_post "/admin/realms/cnoe/client-scopes/${CLIENT_SCOPE_GROUPS_ID}/protocol-mappers/models" \
"/var/config/group-mapper-payload.json" "Protocol mapper"

echo "creating user2"
jq --arg pwd "$USER1_PASSWORD" '.credentials[0].value = $pwd' /var/config/user2-payload.json > user2-payload-with-password.json
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @user2-payload-with-password.json \
${KEYCLOAK_URL}/admin/realms/cnoe/users
# Create users function
create_user() {
local user_num=$1
local payload_file=$2

echo "creating user${user_num}"
jq --arg pwd "$USER1_PASSWORD" '.credentials[0].value = $pwd' ${payload_file} > user${user_num}-payload-with-password.json
keycloak_post "/admin/realms/cnoe/users" "user${user_num}-payload-with-password.json" "User${user_num}"
}

create_user "1" "/var/config/user1-payload.json"
create_user "2" "/var/config/user2-payload.json"

USER1ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" "${KEYCLOAK_URL}/admin/realms/cnoe/users?lastName=one" | jq -r '.[0].id')
USER2ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" "${KEYCLOAK_URL}/admin/realms/cnoe/users?lastName=two" | jq -r '.[0].id')
USER1ID=$(keycloak_get "/admin/realms/cnoe/users?lastName=one" ".[0].id")
USER2ID=$(keycloak_get "/admin/realms/cnoe/users?lastName=two" ".[0].id")

echo "USER1 ID: ${USER1ID}"
echo "USER1 ID: ${USER1ID}"

echo "creating ArgoCD client"
curl -sS --fail-with-body -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/argocd-client-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/clients
echo "USER2 ID: ${USER2ID}"

CLIENT_ID=$(curl -sS --fail-with-body -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients | jq -e -r '.[] | select(.clientId == "argocd") | .id')
# Create client function
create_client() {
local client_name=$1
local payload_file=$2

echo "creating ${client_name} client"
keycloak_post "/admin/realms/cnoe/clients" "${payload_file}" "${client_name} client"
}

CLIENT_SCOPE_GROUPS_ID=$(curl -sS --fail-with-body -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
create_client "ArgoCD" "/var/config/argocd-client-payload.json"

echo "creating Backstage client"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/backstage-client-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/clients
# Add client scope function
add_client_scope() {
local client_id_name=$1
local client_name=$2

CLIENT_ID=$(keycloak_get "/admin/realms/cnoe/clients" ".[] | select(.clientId == \"${client_id_name}\") | .id")
CLIENT_SCOPE_GROUPS_ID=$(keycloak_get "/admin/realms/cnoe/client-scopes" '.[] | select(.name == "groups") | .id')
keycloak_put "/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}" "${client_name} client scope"
}

CLIENT_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients | jq -e -r '.[] | select(.clientId == "backstage") | .id')
add_client_scope "argocd" "ArgoCD"

CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
curl -sS -H "Content-Type: application/json" -H "Authorization: bearer ${KEYCLOAK_TOKEN}" -X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
create_client "Backstage" "/var/config/backstage-client-payload.json"

BACKSTAGE_CLIENT_SECRET=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID} | jq -e -r '.secret')

echo "creating Argo Workflows client"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/argo-client-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/clients
add_client_scope "backstage" "Backstage"

CLIENT_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients | jq -e -r '.[] | select(.clientId == "argo-workflows") | .id')
# Get client secret function
get_client_secret() {
local client_id_name=$1
local var_name=$2

CLIENT_ID=$(keycloak_get "/admin/realms/cnoe/clients" ".[] | select(.clientId == \"${client_id_name}\") | .id")
local secret=$(keycloak_get "/admin/realms/cnoe/clients/${CLIENT_ID}" ".secret")
eval "${var_name}=${secret}"
}

CLIENT_SCOPE_GROUPS_ID=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/client-scopes | jq -e -r '.[] | select(.name == "groups") | .id')
get_client_secret "backstage" "BACKSTAGE_CLIENT_SECRET"

curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X PUT ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID}/default-client-scopes/${CLIENT_SCOPE_GROUPS_ID}
create_client "Argo Workflows" "/var/config/argo-client-payload.json"

ARGO_WORKFLOWS_CLIENT_SECRET=$(curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X GET ${KEYCLOAK_URL}/admin/realms/cnoe/clients/${CLIENT_ID} | jq -e -r '.secret')
add_client_scope "argo-workflows" "Argo Workflows"
get_client_secret "argo-workflows" "ARGO_WORKFLOWS_CLIENT_SECRET"

echo "Creating ArgoCD session token for backstage"
ARGOCD_PASSWORD=$(./kubectl -n argocd get secret argocd-initial-admin-secret -o go-template='{{.data.password | base64decode }}')
Expand Down
1 change: 1 addition & 0 deletions packages/keycloak/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ ingress:
##
annotations:
cert-manager.io/cluster-issuer: 'letsencrypt-prod'
argocd.argoproj.io/sync-wave: "60"
## @param ingress.labels Additional labels for the Ingress resource.
## e.g:
## labels:
Expand Down
9 changes: 6 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AWS_REGION=$(yq '.region' config.yaml)


KUBECONFIG_FILE=$(mktemp)
aws eks update-kubeconfig --region $AWS_REGION --name $CLUSTER_NAME --kubeconfig $KUBECONFIG_FILE
aws eks update-kubeconfig --region $AWS_REGION --name $CLUSTER_NAME --kubeconfig $KUBECONFIG_FILE > /dev/null 2>&1
KUBECONFIG=$(kubectl config --kubeconfig $KUBECONFIG_FILE view --raw -o json)
SERVER_URL=$(echo $KUBECONFIG | jq -r '.clusters[0].cluster.server')
CA_DATA=$(echo $KUBECONFIG | jq -r '.clusters[0].cluster."certificate-authority-data"')
Expand Down Expand Up @@ -63,9 +63,12 @@ EOF
# Run idpbuilder for applying packages
idpbuilder create --use-path-routing --protocol http --package "$REPO_ROOT/packages/" -c "argocd:${CLUSTER_SECRET_FILE}"

# Apply remote cluster secret
# kubectl apply -f "$CLUSTER_SECRET_FILE"
# Wait for hub-addons to be healthy
kubectl wait --for=jsonpath=.status.health.status=Healthy -n argocd application/hub-addons --timeout=5m
sleep 30

# Finally wait for ArgoCD on the hub Cluster to be Healthy
kubectl wait --for=jsonpath=.status.health.status=Healthy -n argocd application/argocd-hub --kubeconfig $KUBECONFIG_FILE --timeout=-15m

# REPO_ROOT=$(git rev-parse --show-toplevel)

Expand Down
35 changes: 19 additions & 16 deletions scripts/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ fi
# Delete idpbuilder local kind cluster instance
idpbuilder delete cluster --name localdev

# Get EKS kubeconfig
CLUSTER_NAME=$(yq '.cluster_name' config.yaml)
AWS_REGION=$(yq '.region' config.yaml)
KUBECONFIG_FILE=$(mktemp)
aws eks update-kubeconfig --region $AWS_REGION --name $CLUSTER_NAME --kubeconfig $KUBECONFIG_FILE > /dev/null 2>&1

# Addons to be deleted
ADDONS=(
backstage
Expand All @@ -35,30 +41,27 @@ ADDONS=(
)

# Delete all application sets except argocd
for app in "${ADDONS[@]}"; do
kubectl delete applicationsets.argoproj.io -n argocd $app
for app in "${ADDONS[@]}"; do
echo "Deleting $app AppSet..."
kubectl delete applicationsets.argoproj.io -n argocd $app --kubeconfig $KUBECONFIG_FILE > /dev/null 2>&1 || true
# Wait for AppSet deletion to complete before moving to next AppSet
while kubectl get applications.argoproj.io -n argocd -l addonName=$app &>/dev/null; do
while [ $(kubectl get applications.argoproj.io -n argocd -l addonName=$app --no-headers --kubeconfig $KUBECONFIG_FILE 2>/dev/null | wc -l) -ne 0 ]; do
echo "Waiting for $app AppSet to be deleted..."
sleep 5
sleep 10
done
done

# Patch ArgoCD AppSet to remove finalizer and Delete it
# kubectl patch applicationsets.argoproj.io -n argocd argocd --type json -p '[{"op": "remove", "path": "/metadata/finalizers"}]'
# kubectl delete applicationsets.argoproj.io -n argocd argocd

# Delete ArgoCD App
kubectl delete applicationsets.argoproj.io -n argocd argocd
echo "Deleting argocd AppSet..."
kubectl delete applicationsets.argoproj.io -n argocd argocd --kubeconfig $KUBECONFIG_FILE > /dev/null 2>&1

# Wait for 3mins for ArgoCD to be deleted
while kubectl get applications.argoproj.io -n argocd -l addonName=argocd &>/dev/null; do
echo "Waiting for argocd AppSet to be deleted..."
sleep 5
done
# Wait for 2mins for ArgoCD to be deleted
echo "Waiting for argocd AppSet to be deleted..."
sleep 120

# Patch ArgoCD App to remove finalizer for completing deletion of ArgoCD App.
# kubectl patch applications.argoproj.io -n argocd argocd --type json -p '[{"op": "remove", "path": "/metadata/finalizers"}]'
# Remove PVCs for keycloak
# echo "Deleting PVCs for keycloak..."
# kubectl delete pvc -n keycloak data-keycloak-postgresql-0 --kubeconfig $KUBECONFIG_FILE > /dev/null 2>&1

# kubectl delete applications.argoproj.io argocd-hub -n argocd
# cd "${TF_DIR}"
Expand Down
Loading