Package: cdk8s-jenkins
cdk8s-jenkinscdk8s-jenkinsis a library that lets you easily define a manifest for deploying a Jenkins instance to your Kubernetes cluster.PrerequisitesThis library uses a Custom Resource Definition provided by jenkins, and thus requires both the CRD and the operator to be installed on the cluster.
You can set this up by,Apply the Custom Resource Definition(CRD) for jenkins on your Kubernetes cluster.kubectl apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/config/crd/bases/jenkins.io_jenkins.yamlInstall the Jenkins Operator on your Kubernetes cluster.kubectl apply -f https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/deploy/all-in-one-v1alpha2.yamlFor more information regarding applying jenkins crd and installing jenkins operator, please referjenkins official documentaion.UsageThe library provides a high levelJenkinsconstruct to provision a Jenkins instance.
You can just instantiate the Jenkins instance and that would add a Jenkins resource to the kubernetes manifest.The library provide a set of defaults, so provisioning a basic Jenkins instance requires no configuration:import{Jenkins}from'cdk8s-jenkins';//insideyourchart:constjenkins=newJenkins(this,'my-jenkins');The library also enables configuring the following parmeters for the Jenkins instance:metadataconstjenkins=newJenkins(this,'my-jenkins',{metadata:{namespace:'jenkins-namespace',labels:{customApp:'my-jenkins'},},});disableCsrfProtectionThis allows you to toggle CSRF Protection for Jenkins.constjenkins=newJenkins(this,'my-jenkins',{disableCsrfProtection:true,});basePluginsThese are the plugins required by the jenkins operator.constjenkins=newJenkins(this,'my-jenkins',{basePlugins:[{name:'configuration-as-code',version:'1.55',}],});You can also utilizeaddBasePluginsfunction to add base plugins to jenkins configuration after initialization.constjenkins=newJenkins(this,'my-jenkins');jenkins.addBasePlugins([{name:'workflow-api',version:'2.76',}]);pluginsThese are the plugins that you can add to your jenkins instance.constjenkins=newJenkins(this,'my-jenkins',{plugins:[{name:'simple-theme-plugin',version:'0.7',}],});You can also utilizeaddPluginsfunction to add plugins to jenkins configuration after initialization.constjenkins=newJenkins(this,'my-jenkins');jenkins.addPlugins([{name:'simple-theme-plugin',version:'0.7',}]);seedJobsYou can define list of jenkins seed job configurations here. For more info you can take look atjenkins documentation.constjenkins=newJenkins(this,'my-jenkins',{seedJobs:[{id:'jenkins-operator',targets:'cicd/jobs/*.jenkins',description:'Jenkins Operator repository',repositoryBranch:'master',repositoryUrl:'https://github.com/jenkinsci/kubernetes-operator.git',}],});You can also utilizeaddSeedJobsfunction to add seed jobs to jenkins configuration after initialization.constjenkins=newJenkins(this,'my-jenkins');jenkins.addSeedJobs([{id:'jenkins-operator',targets:'cicd/jobs/*.jenkins',description:'Jenkins Operator repository',repositoryBranch:'master',repositoryUrl:'https://github.com/jenkinsci/kubernetes-operator.git',}]);Using escape hatchesYou can utilize escape hatches to make changes to the configurations that are not yet exposed by the library.For instance, if you would like to update the version of a base plugin:constjenkins=newJenkins(this,'my-jenkins');constjenkinsApiObject=ApiObject.of(jenkins);jenkinsApiObject.addJsonPatch(JsonPatch.replace('/spec/master/basePlugins/1',{name:'workflow-job',version:'3.00',}));For more information regarding escape hatches, take a look atcdk8s documentation.SecuritySeeCONTRIBUTINGfor more
information.LicenseThis project is licensed under the Apache-2.0 License.