jenkinsci / kubernetes-operator

Kubernetes native Jenkins Operator
https://jenkinsci.github.io/kubernetes-operator
Other
598 stars 233 forks source link

operator unable to apply new settings when Azure AD authentication is enabled #949

Closed crespo-obie closed 8 months ago

crespo-obie commented 9 months ago

Describe the bug operator is unable to reload Jenkins Pod when new values are applied if Azure AD authentication is enabled.

To Reproduce

Additional information

Kubernetes version: 1.28 Jenkins Operator version: 0.7.0 Jenkins Image version : jenkins/jenkins:lts (2.426.2)

Workaround : CAUTION! this will not initiate backup and will restore the last working backup

Add error logs about the problem here (operator logs and Kubernetes events).

lhupfeldt commented 8 months ago

Would it be possible for you to share your configuration for Azure AD authentication? Are you running the operator and Jenkins in different namespaces? I'm currently struggling to get GitHub authentication working, we may want to move to Azure AD authentication later, but since both are external (not Jenkins built in) authentication, your configuration may help me understand why GH auth is not working.

crespo-obie commented 8 months ago

For AzureAD Authentication:

Configuration is done as follows :

using Helm or Jenkins CR :

plugins:
  - name: azure-ad
  - version: "449.v92b_39a_d8e523"

on user CasC :

unclassified:
  location:
    url: <callback-FQDN-configured-in-AzureAD-app-registration>
jenkins:
  authorizationStrategy:
    azureAdMatrix:
      entries:
      - group:
          name: "jenkins-administrators"
          permissions:
          - "Overall/Administer"
          - "Overall/Read"
      - group:
          name: "jenkins-users"
          permissions:
          - "Agent/Build"
  securityRealm:
    azure:
      clientId: "${AZURE_AD_CLIENT_ID}"
      clientSecret: "${AZURE_AD_CLIENT_SECRET}"
      tenant: "${AZURE_AD_TENANT_ID}"    

Introduce AzureAD App Registration credentials via kubernetes secrets.

Detailed instructions on User customization: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customizing-jenkins/

Possible issue you may encounter with external authentication is the callback URLs, if you are running jenkins behind reverse proxy. Ensure that the required redirection is enabled.

inspect logs on both operator and jenkins pods to identify issues as follows :

kubectl logs --tail 100 -f <operator-pod-name>
kubectl logs --tail 100 -f jenkins-<cr-name>

I was able to resolve the impersonation issue by implementing the following :

kubectl edit secret jenkins-operator-credentials-<cr-name>
lhupfeldt commented 8 months ago

Thank you for this. I don't see anything which would explain our problem, but the information may be useful for us late.

brokenpip3 commented 8 months ago

@crespo-obie thanks for reporting back the solution, I'm closing since this is a well know issue see: https://github.com/jenkinsci/kubernetes-operator/issues/963#issuecomment-1925683691

if someone wants to create a PR for documenting this will be great, thanks.