2025-12-14 15:57:42 -03:00
|
|
|
# services/jenkins/helmrelease.yaml
|
|
|
|
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
|
|
|
|
kind: HelmRelease
|
|
|
|
|
metadata:
|
|
|
|
|
name: jenkins
|
|
|
|
|
namespace: jenkins
|
|
|
|
|
spec:
|
|
|
|
|
interval: 30m
|
|
|
|
|
chart:
|
|
|
|
|
spec:
|
|
|
|
|
chart: jenkins
|
|
|
|
|
version: 5.8.114
|
|
|
|
|
sourceRef:
|
|
|
|
|
kind: HelmRepository
|
|
|
|
|
name: jenkins
|
|
|
|
|
namespace: flux-system
|
|
|
|
|
install:
|
|
|
|
|
remediation:
|
|
|
|
|
retries: 3
|
|
|
|
|
upgrade:
|
|
|
|
|
remediation:
|
|
|
|
|
retries: 3
|
|
|
|
|
remediateLastFailure: true
|
|
|
|
|
cleanupOnFail: true
|
|
|
|
|
values:
|
|
|
|
|
controller:
|
|
|
|
|
jenkinsUrl: https://ci.bstein.dev
|
|
|
|
|
ingress:
|
|
|
|
|
enabled: true
|
|
|
|
|
hostName: ci.bstein.dev
|
|
|
|
|
ingressClassName: traefik
|
|
|
|
|
annotations:
|
|
|
|
|
cert-manager.io/cluster-issuer: letsencrypt
|
|
|
|
|
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
|
|
|
|
tls:
|
|
|
|
|
- secretName: jenkins-tls
|
|
|
|
|
hosts:
|
|
|
|
|
- ci.bstein.dev
|
2025-12-14 17:59:48 -03:00
|
|
|
installPlugins:
|
|
|
|
|
- kubernetes
|
|
|
|
|
- workflow-aggregator
|
|
|
|
|
- git
|
|
|
|
|
- configuration-as-code
|
|
|
|
|
- oic-auth
|
2025-12-14 15:57:42 -03:00
|
|
|
containerEnv:
|
|
|
|
|
- name: ENABLE_OIDC
|
2025-12-14 20:58:57 -03:00
|
|
|
value: "true"
|
2025-12-14 19:22:47 -03:00
|
|
|
- name: OIDC_ISSUER
|
|
|
|
|
value: "https://sso.bstein.dev/realms/atlas"
|
2025-12-14 15:57:42 -03:00
|
|
|
- name: OIDC_CLIENT_ID
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: clientId
|
|
|
|
|
optional: true
|
|
|
|
|
- name: OIDC_CLIENT_SECRET
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: clientSecret
|
|
|
|
|
optional: true
|
|
|
|
|
- name: OIDC_AUTH_URL
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: authorizationUrl
|
|
|
|
|
optional: true
|
|
|
|
|
- name: OIDC_TOKEN_URL
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: tokenUrl
|
|
|
|
|
optional: true
|
|
|
|
|
- name: OIDC_USERINFO_URL
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: userInfoUrl
|
|
|
|
|
optional: true
|
|
|
|
|
- name: OIDC_LOGOUT_URL
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: jenkins-oidc
|
|
|
|
|
key: logoutUrl
|
|
|
|
|
optional: true
|
2025-12-14 19:22:47 -03:00
|
|
|
initScripts:
|
|
|
|
|
oidc.groovy: |
|
2025-12-14 20:58:57 -03:00
|
|
|
import hudson.util.Secret
|
|
|
|
|
import jenkins.model.IdStrategy
|
2025-12-14 19:22:47 -03:00
|
|
|
import jenkins.model.Jenkins
|
|
|
|
|
import org.jenkinsci.plugins.oic.OicSecurityRealm
|
2025-12-14 20:58:57 -03:00
|
|
|
import org.jenkinsci.plugins.oic.OicServerWellKnownConfiguration
|
2025-12-14 19:22:47 -03:00
|
|
|
def env = System.getenv()
|
2025-12-14 20:58:57 -03:00
|
|
|
if (!(env['ENABLE_OIDC'] ?: 'false').toBoolean()) {
|
2025-12-14 19:22:47 -03:00
|
|
|
println("OIDC disabled (ENABLE_OIDC=false); keeping default security realm")
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-12-14 20:58:57 -03:00
|
|
|
def required = ['OIDC_CLIENT_ID','OIDC_CLIENT_SECRET','OIDC_ISSUER']
|
2025-12-14 19:22:47 -03:00
|
|
|
if (!required.every { env[it] }) {
|
|
|
|
|
println("OIDC enabled but missing vars: ${required.findAll { !env[it] }}")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
2025-12-14 20:58:57 -03:00
|
|
|
def wellKnown = "${env['OIDC_ISSUER']}/.well-known/openid-configuration"
|
|
|
|
|
def serverCfg = new OicServerWellKnownConfiguration(wellKnown)
|
|
|
|
|
serverCfg.setScopesOverride('openid profile email')
|
2025-12-14 19:22:47 -03:00
|
|
|
def realm = new OicSecurityRealm(
|
|
|
|
|
env['OIDC_CLIENT_ID'],
|
2025-12-14 20:58:57 -03:00
|
|
|
Secret.fromString(env['OIDC_CLIENT_SECRET']),
|
|
|
|
|
serverCfg,
|
|
|
|
|
false,
|
|
|
|
|
IdStrategy.CASE_INSENSITIVE,
|
|
|
|
|
IdStrategy.CASE_INSENSITIVE
|
2025-12-14 19:22:47 -03:00
|
|
|
)
|
2025-12-14 21:23:15 -03:00
|
|
|
realm.createProxyAwareResourceRetriver()
|
2025-12-14 20:58:57 -03:00
|
|
|
realm.setLogoutFromOpenidProvider(true)
|
|
|
|
|
realm.setPostLogoutRedirectUrl('https://ci.bstein.dev')
|
|
|
|
|
realm.setUserNameField('preferred_username')
|
|
|
|
|
realm.setFullNameFieldName('name')
|
|
|
|
|
realm.setEmailFieldName('email')
|
|
|
|
|
realm.setGroupsFieldName('groups')
|
|
|
|
|
realm.setRootURLFromRequest(true)
|
|
|
|
|
realm.setSendScopesInTokenRequest(true)
|
2025-12-14 19:22:47 -03:00
|
|
|
def j = Jenkins.get()
|
|
|
|
|
j.setSecurityRealm(realm)
|
|
|
|
|
j.save()
|
2025-12-14 20:58:57 -03:00
|
|
|
println("Configured OIDC realm from init script (well-known)")
|
2025-12-14 19:22:47 -03:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
println("Failed to configure OIDC realm: ${e}")
|
|
|
|
|
}
|
2025-12-16 19:26:46 -03:00
|
|
|
JCasC:
|
|
|
|
|
configScripts:
|
2025-12-16 20:04:21 -03:00
|
|
|
security.yaml: |
|
|
|
|
|
jenkins:
|
|
|
|
|
securityRealm:
|
|
|
|
|
oic:
|
|
|
|
|
clientId: "${OIDC_CLIENT_ID}"
|
|
|
|
|
clientSecret: "${OIDC_CLIENT_SECRET}"
|
|
|
|
|
wellKnownOpenIDConfigurationUrl: "${OIDC_ISSUER}/.well-known/openid-configuration"
|
|
|
|
|
scopes: "openid profile email"
|
|
|
|
|
userNameField: "preferred_username"
|
|
|
|
|
fullNameFieldName: "name"
|
|
|
|
|
emailFieldName: "email"
|
|
|
|
|
groupsFieldName: "groups"
|
|
|
|
|
logoutFromOpenidProvider: true
|
|
|
|
|
rootURLFromRequest: true
|
|
|
|
|
authorizationStrategy:
|
|
|
|
|
loggedInUsersCanDoAnything:
|
|
|
|
|
allowAnonymousRead: false
|
2025-12-16 19:26:46 -03:00
|
|
|
creds.yaml: |
|
|
|
|
|
credentials:
|
|
|
|
|
system:
|
|
|
|
|
domainCredentials:
|
|
|
|
|
- credentials:
|
|
|
|
|
- usernamePassword:
|
|
|
|
|
scope: GLOBAL
|
|
|
|
|
id: gitea-pat
|
|
|
|
|
username: "bstein"
|
|
|
|
|
password: "4693a39ee3f0ebb58e7d1795ab98add6df44ef12"
|
|
|
|
|
description: "Gitea PAT for harbor-arm-build"
|
|
|
|
|
- usernamePassword:
|
|
|
|
|
scope: GLOBAL
|
|
|
|
|
id: harbor-robot
|
|
|
|
|
username: "robot$infra+robotuser-pipeline"
|
|
|
|
|
password: "ouuvMheoTxOQtFSbWnO1OKVujORMPfO7"
|
|
|
|
|
description: "Harbor robot for pipeline push"
|
|
|
|
|
jobs.yaml: |
|
|
|
|
|
jobs:
|
|
|
|
|
- script: |
|
|
|
|
|
pipelineJob('harbor-arm-build') {
|
|
|
|
|
definition {
|
|
|
|
|
cpsScm {
|
|
|
|
|
scm {
|
|
|
|
|
git {
|
|
|
|
|
remote {
|
|
|
|
|
url('https://scm.bstein.dev/bstein/harbor-arm-build.git')
|
|
|
|
|
credentials('gitea-pat')
|
|
|
|
|
}
|
|
|
|
|
branches('*/master')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
triggers {
|
|
|
|
|
scm('H/5 * * * *')
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-14 15:57:42 -03:00
|
|
|
persistence:
|
|
|
|
|
enabled: true
|
|
|
|
|
storageClass: astreae
|
|
|
|
|
size: 50Gi
|
|
|
|
|
serviceAccount:
|
|
|
|
|
create: true
|