jenkinsci / configuration-as-code-plugin

Jenkins Configuration as Code Plugin
https://plugins.jenkins.io/configuration-as-code
MIT License
2.69k stars 718 forks source link

Helm and multiple kubernetes clusters #1975

Open wrender opened 2 years ago

wrender commented 2 years ago

Description

We are trying to setup one Jenkins in a kubernetes cluster, and that Jenkins will deploy and build software in multiple other kubernetes clusters as well.

Using helm with the Jenkins helm chart and values.yaml file I can't seem to figure out how to define multiple kubernetes clouds. I've tried something like:

jenkins:
  clouds:
  - kubernetes:
    jenkinsTunnel: "jenkins-agent.jenkins.svc.cluster.local:50000"
    jenkinsUrl: "http://jenkins.jenkins.svc.cluster.local:8080"
    name: "kubernetes"
    namespace: "jenkins-agents"
    podLabels:
      - key: "jenkins/jenkins-agent"
        value: "true"
    serverUrl: "https://kubernetes.default"
  - kubernetes:
    jenkinsTunnel: "myjenkins.domain.local:50000"
    jenkinsUrl: "http://myjenkins.domain.local:8080"
    name: "second-kubernetes-cluster"
    namespace: "jenkins-agents"
    podLabels:
      - key: "jenkins/jenkins-agent"
        value: "true"
    serverUrl: "https://remotecluster.blah.blah.blah"

(I can do it through the gui but then the kubernetes Jenkins pod restarts and it is gone.) Other config as code settings seem to work.

Does anyone have an example helm chart values.yaml of this? I couldnt seem to find one that shows multiple kubernetes clusters. Also not sure if I need a controller or what in each kubernetes cluster to make this work.

As well wanting to set it up so that certain kubernetes clouds are only accessible to certain Jenkins users. Ideally separated by folder.

hervelemeur commented 2 years ago

Did you find an example?

wrender commented 2 years ago

No. Seems like maybe a bug too. See here https://github.com/jenkinsci/helm-charts/issues/634

jetersen commented 2 years ago

Configure in GUI and export? https://github.com/jenkinsci/configuration-as-code-plugin/blob/master/docs/features/configExport.md

mparada-suva commented 10 months ago

No. Seems like maybe a bug too. See here jenkinsci/helm-charts#634

I made a patch that may be what you were looking for: https://github.com/jenkinsci/helm-charts/pull/973