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 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-14 15:57:42 -03:00
|
|
|
persistence:
|
|
|
|
|
enabled: true
|
|
|
|
|
storageClass: astreae
|
|
|
|
|
size: 50Gi
|
|
|
|
|
serviceAccount:
|
|
|
|
|
create: true
|