Compare commits

...

31 commits

Author SHA1 Message Date
364a65a6be alloy configuration added 2025-03-11 13:08:15 +01:00
303d7b3a7e Update template/stacks/ref-implementation/backstage-templates/entities/spring-petclinic/skeleton/.github/workflows/maven-build.yml 2025-03-08 12:50:23 +00:00
1ab8119063 Fixed kubectl download on Linux ARM64 VMs 2025-03-07 20:28:39 +00:00
f81a550064 Merge pull request 'IPCEICIS-764_grafana_sso' (#10) from IPCEICIS-764_grafana_sso into development
Reviewed-on: DevFW-CICD/stacks#10
2025-03-06 09:24:13 +00:00
Richard Robert Reitz
a9c69d6c24 adjusted retry backoff time 2025-03-04 19:23:19 +01:00
Richard Robert Reitz
c2cb410af8 Merge branch 'development' into IPCEICIS-764_grafana_sso 2025-03-04 19:21:48 +01:00
2698432809 Merge pull request 'faster_backstage_start' (#11) from faster_backstage_start into development
Reviewed-on: DevFW-CICD/stacks#11
2025-03-04 18:20:52 +00:00
Richard Robert Reitz
d0cce6916d fixed argocd version 2025-03-04 19:06:11 +01:00
Richard Robert Reitz
aba4a4a088 shortened retry backoff 2025-03-04 19:03:36 +01:00
Richard Robert Reitz
4ae8f6fd15 shortened retry backoff 2025-03-04 18:49:55 +01:00
Your Name
1198250861 Merge branch 'development' into IPCEICIS-764_grafana_sso 2025-03-04 11:55:17 +01:00
9bbf171980 Merge pull request 'Make PetClinic Great Again' (#9) from runner-tags into development
Reviewed-on: DevFW-CICD/stacks#9
2025-03-03 17:18:10 +00:00
d95ba7c12c
chore(petclinic): Removed unused workflow
Disabled tests in maven workflow as there are currently dind problems
2025-03-03 16:37:18 +01:00
8a38aee529
feat(runner): Added ubuntu-latest runner tag 2025-03-03 15:21:46 +01:00
Richard Robert Reitz
1ef1029e1f Added Grafana admin account 2025-03-02 17:26:29 +01:00
Richard Robert Reitz
63a694d17c Removed Grafana admin account 2025-03-02 17:09:02 +01:00
Richard Robert Reitz
6eb52e654c Refactored external secret for grafana keycloak client secret 2025-03-02 15:46:06 +01:00
Richard Robert Reitz
ec31f98889 Added external secret for grafana keycloak client secret 2025-03-02 15:28:48 +01:00
Richard Robert Reitz
2d3ebadd50 Simplified Keycloaks Grafana config 2025-03-02 14:52:08 +01:00
Richard Robert Reitz
b58e373da9 Added email to Keycloak users and upgraded ArgoCD again as it requires more work 2025-03-02 14:19:07 +01:00
Richard Robert Reitz
688795ffad Added more Grafana client config to Keycloak 2025-03-02 13:46:20 +01:00
Richard Robert Reitz
e02d4bb272 Added more Grafana client config to Keycloak 2025-03-02 13:27:51 +01:00
Richard Robert Reitz
efa3a6e4dc Added ArgoCD sync retry to Grafana 2025-03-02 13:18:04 +01:00
Richard Robert Reitz
65c5321ce6 Added Grafana client config to Keycloak 2025-03-02 13:11:38 +01:00
Richard Robert Reitz
ce6c51eea9 Enhanced grafana yaml 2025-03-02 10:47:25 +01:00
0f8282ead6 Update template/stacks/monitoring/kube-prometheus/values.yaml 2025-02-28 14:08:07 +00:00
88d599a691 Update template/stacks/monitoring/kube-prometheus/values.yaml 2025-02-28 13:30:29 +00:00
9016831286 Update template/stacks/core/argocd.yaml 2025-02-28 11:15:56 +00:00
168286cfce Update template/stacks/core/argocd.yaml 2025-02-28 11:07:21 +00:00
9cc9b864a2 Update template/stacks/core/argocd.yaml 2025-02-28 11:04:21 +00:00
265af3acff Update template/stacks/core/argocd.yaml 2025-02-28 11:01:07 +00:00
14 changed files with 212 additions and 41 deletions

View file

@ -18,6 +18,9 @@ spec:
sources:
- repoURL: https://github.com/argoproj/argo-helm
path: charts/argo-cd
# TODO: RIRE Can be updated when https://github.com/argoproj/argo-cd/issues/20790 is fixed and merged
# As logout make problems, it is suggested to switch from path based routing to an own argocd domain,
# similar to the CNOE amazon reference implementation and in our case, Forgejo
targetRevision: argo-cd-7.7.5
helm:
valueFiles:

View file

@ -29,7 +29,18 @@ spec:
initContainers:
- name: runner-register
image: code.forgejo.org/forgejo/runner:6.0.1
command: ["forgejo-runner", "register", "--no-interactive", "--token", $(RUNNER_SECRET), "--name", $(RUNNER_NAME), "--instance", $(FORGEJO_INSTANCE_URL), "--labels", "docker:docker://node:20-bookworm,ubuntu-22.04:docker://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/catthehackerubuntu:act-22.04"]
command:
- "forgejo-runner"
- "register"
- "--no-interactive"
- "--token"
- $(RUNNER_SECRET)
- "--name"
- $(RUNNER_NAME)
- "--instance"
- $(FORGEJO_INSTANCE_URL)
- "--labels"
- "docker:docker://node:20-bookworm,ubuntu-22.04:docker://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/catthehackerubuntu:act-22.04,ubuntu-latest:docker://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/devfw-cicd/catthehackerubuntu:act-22.04"
env:
- name: RUNNER_NAME
valueFrom:

View file

@ -53,3 +53,4 @@ forgejo:
- docker:docker://node:16-bullseye
- self-hosted:docker://ghcr.io/catthehacker/ubuntu:act-22.04
- ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-22.04
- ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-22.04

View file

@ -0,0 +1,29 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: alloy
namespace: argocd
labels:
env: dev
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
syncPolicy:
automated:
selfHeal: true
syncOptions:
- CreateNamespace=true
destination:
name: in-cluster
namespace: monitoring
sources:
- repoURL: https://github.com/grafana/alloy.git
path: operations/helm/charts/alloy
targetRevision: HEAD
helm:
valueFiles:
- $values/stacks/monitoring/alloy/values.yaml
- repoURL: https://{{{ .Env.DOMAIN_GITEA }}}/giteaAdmin/edfbuilder
targetRevision: HEAD
ref: values

View file

@ -0,0 +1,4 @@
alloy:
create: false
name: alloy-config
key: config.alloy

View file

@ -0,0 +1,29 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kube-prometheus-sso
namespace: argocd
labels:
env: dev
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: https://{{{ .Env.DOMAIN_GITEA }}}/giteaAdmin/edfbuilder
targetRevision: HEAD
path: "stacks/monitoring/kube-prometheus-sso"
destination:
server: "https://kubernetes.default.svc"
namespace: monitoring
syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
selfHeal: true
retry:
limit: -1
backoff:
duration: 15s
factor: 1
maxDuration: 15s

View file

@ -0,0 +1,21 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: auth-generic-oauth-secret
namespace: monitoring
spec:
secretStoreRef:
name: keycloak
kind: ClusterSecretStore
refreshInterval: "0"
target:
name: auth-generic-oauth-secret
template:
engineVersion: v2
data:
client_secret: "{{.GRAFANA_CLIENT_SECRET}}"
data:
- secretKey: GRAFANA_CLIENT_SECRET
remoteRef:
key: keycloak-clients
property: GRAFANA_CLIENT_SECRET

View file

@ -15,6 +15,12 @@ spec:
syncOptions:
- CreateNamespace=true
- ServerSideApply=true # do not copy metdata, since (because of its large size) it can lead to sync failure
retry:
limit: -1
backoff:
duration: 15s
factor: 1
maxDuration: 15s
destination:
name: in-cluster
namespace: monitoring

View file

@ -33,7 +33,33 @@ grafana:
domain: {{{ .Env.DOMAIN }}}
root_url: "%(protocol)s://%(domain)s/grafana"
serve_from_sub_path: true
auth:
disable_login: true
disable_login_form: true
auth.generic_oauth:
enabled: true
name: Keycloak-OAuth
allow_sign_up: true
use_refresh_token: true
client_id: grafana
client_secret: $__file{/etc/secrets/auth_generic_oauth/client_secret}
scopes: openid email profile offline_access roles
email_attribute_path: email
login_attribute_path: username
name_attribute_path: full_name
auth_url: https://{{{ .Env.DOMAIN }}}/keycloak/realms/cnoe/protocol/openid-connect/auth
token_url: https://{{{ .Env.DOMAIN }}}/keycloak/realms/cnoe/protocol/openid-connect/token
api_url: https://{{{ .Env.DOMAIN }}}/keycloak/realms/cnoe/protocol/openid-connect/userinfo
redirect_uri: http://{{{ .Env.DOMAIN }}}/grafana/login/generic_oauth
role_attribute_path: "contains(groups[*], 'admin') && 'Admin' || contains(groups[*], 'editor') && 'Editor' || 'Viewer'"
extraSecretMounts:
- name: auth-generic-oauth-secret-mount
secretName: auth-generic-oauth-secret
defaultMode: 0440
mountPath: /etc/secrets/auth_generic_oauth
readOnly: true
serviceMonitor:
# If true, a ServiceMonitor CRD is created for a prometheus operator https://github.com/coreos/prometheus-operator
enabled: true

View file

@ -23,3 +23,7 @@ spec:
selfHeal: true
retry:
limit: -1
backoff:
duration: 15s
factor: 1
maxDuration: 15s

View file

@ -1,32 +0,0 @@
# This workflow will build a Java project with Gradle, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17' ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK {% raw %}${{matrix.java}}{% endraw %}
uses: https://github.com/actions/setup-java@v4
with:
java-version: '{% raw %}${{matrix.java}}{% endraw %}'
distribution: 'adopt'
cache: maven
- name: Setup Gradle
uses: https://github.com/gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew build

View file

@ -28,12 +28,12 @@ jobs:
distribution: 'adopt'
cache: maven
- name: Build with Maven Wrapper
run: ./mvnw -B verify
run: ./mvnw -B -DskipTests verify
- name: Build image
#run: ./mvnw spring-boot:build-image # the original image build
run: |
export CONTAINER_REPO=$(echo {% raw %}${{ env.GITHUB_REPOSITORY }}{% endraw %} | tr '[:upper:]' '[:lower:]')
./mvnw com.google.cloud.tools:jib-maven-plugin:3.4.4:build -Djib.allowInsecureRegistries=true -Dimage={{{ .Env.DOMAIN_GITEA }}}/${CONTAINER_REPO}:latest -Djib.to.auth.username={% raw %}${{ github.actor }}{% endraw %} -Djib.to.auth.password={% raw %}${{ secrets.PACKAGES_TOKEN }}{% endraw %}
./mvnw com.google.cloud.tools:jib-maven-plugin:3.4.4:build -Djib.allowInsecureRegistries=true -Dimage={{{ .Env.DOMAIN_GITEA }}}/${CONTAINER_REPO}:latest -Djib.to.auth.username={% raw %}${{ github.actor }}{% endraw %} -Djib.to.auth.password={% raw %}${{ secrets.PACKAGES_TOKEN }}{% endraw %} -Djib.from.platforms=linux/arm64,linux/amd64
- name: Build image as tar
run: |
./mvnw com.google.cloud.tools:jib-maven-plugin:3.4.4:buildTar -Djib.allowInsecureRegistries=true
@ -57,7 +57,11 @@ jobs:
NODE_TLS_REJECT_UNAUTHORIZED: 0 # This is necessary due to self signed certs for forgejo, proper setups can skip this
- name: install trivy from deb package
run: |
wget -O trivy.deb https://github.com/aquasecurity/trivy/releases/download/v0.58.0/trivy_0.58.0_Linux-64bit.deb
if [[ "$(uname -m)" == "x86_64" ]]; then
wget -O trivy.deb https://github.com/aquasecurity/trivy/releases/download/v0.58.0/trivy_0.58.0_Linux-64bit.deb
else
wget -O trivy.deb https://github.com/aquasecurity/trivy/releases/download/v0.58.0/trivy_0.58.0_Linux-ARM64.deb
fi
DEBIAN_FRONTEND=noninteractive dpkg -i trivy.deb
- name: scan the image
run: trivy image --input jib-image.tar

View file

@ -23,3 +23,7 @@ spec:
selfHeal: true
retry:
limit: -1
backoff:
duration: 15s
factor: 1
maxDuration: 15s

View file

@ -100,11 +100,11 @@ data:
user-user1.json: |
{
"username": "user1",
"email": "",
"email": "user1@user.de",
"firstName": "user",
"lastName": "one",
"requiredActions": [],
"emailVerified": false,
"emailVerified": true,
"groups": [
"/admin"
],
@ -113,11 +113,11 @@ data:
user-user2.json: |
{
"username": "user2",
"email": "",
"email": "user2@user.de",
"firstName": "user",
"lastName": "two",
"requiredActions": [],
"emailVerified": false,
"emailVerified": true,
"groups": [
"/base-user"
],
@ -181,6 +181,44 @@ data:
]
}
grafana-client-payload.json: |
{
"clientId": "grafana",
"name": "Grafana Client",
"description": "Used for Grafana SSO",
"rootUrl": "https://{{{ .Env.DOMAIN }}}/grafana",
"adminUrl": "https://{{{ .Env.DOMAIN }}}/grafana",
"baseUrl": "https://{{{ .Env.DOMAIN }}}/grafana",
"alwaysDisplayInConsole": false,
"redirectUris": [
"http://{{{ .Env.DOMAIN }}}/grafana/*"
],
"webOrigins": [
"https://{{{ .Env.DOMAIN }}}/grafana"
],
"standardFlowEnabled": true,
"implicitFlowEnabled": false,
"directAccessGrantsEnabled": true,
"serviceAccountsEnabled": false,
"publicClient": false,
"frontchannelLogout": true,
"protocol": "openid-connect",
"attributes": {
"saml_idp_initiated_sso_url_name": "",
"oidc.ciba.grant.enabled": "false",
"oauth2.device.authorization.grant.enabled": "false"
},
"defaultClientScopes": [
"web-origins",
"acr",
"offline_access",
"roles",
"profile",
"groups",
"email"
]
}
---
apiVersion: batch/v1
kind: Job
@ -247,7 +285,11 @@ spec:
fi
set -e
curl -sS -LO "https://dl.k8s.io/release/v1.28.3//bin/linux/amd64/kubectl"
if [[ "$(uname -m)" == "x86_64" ]]; then
curl -sS -LO "https://dl.k8s.io/release/v1.28.3//bin/linux/amd64/kubectl"
else
curl -sS -LO "https://dl.k8s.io/release/v1.28.3//bin/linux/arm64/kubectl"
fi
chmod +x kubectl
echo "creating cnoe realm and groups"
@ -330,7 +372,24 @@ spec:
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')
echo "creating Grafana client"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
-X POST --data @/var/config/grafana-client-payload.json \
${KEYCLOAK_URL}/admin/realms/cnoe/clients
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 == "grafana") | .id')
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}
GRAFANA_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 Backstage client"
curl -sS -H "Content-Type: application/json" \
-H "Authorization: bearer ${KEYCLOAK_TOKEN}" \
@ -365,6 +424,8 @@ spec:
ARGOCD_SESSION_TOKEN: ${ARGOCD_SESSION_TOKEN}
BACKSTAGE_CLIENT_SECRET: ${BACKSTAGE_CLIENT_SECRET}
BACKSTAGE_CLIENT_ID: backstage
GRAFANA_CLIENT_SECRET: ${GRAFANA_CLIENT_SECRET}
GRAFANA_CLIENT_ID: grafana
" > /tmp/secret.yaml
./kubectl apply -f /tmp/secret.yaml