diff --git a/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsinstance.yaml b/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsinstance.yaml new file mode 100644 index 0000000000..a1b1eed224 --- /dev/null +++ b/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsinstance.yaml @@ -0,0 +1,114 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + helm.sh/resource-policy: keep + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + controller-tools.k8s.io: "1.0" + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: jenkinsinstances.jenkins.jenkinsoperator.maratoid.github.com +spec: + group: jenkins.jenkinsoperator.maratoid.github.com + names: + kind: JenkinsInstance + plural: jenkinsinstances + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + adminemail: + type: string + adminsecret: + type: string + annotations: + type: object + env: + type: object + executors: + format: int32 + type: integer + image: + pattern: .+:.+ + type: string + ingress: + properties: + annotations: + type: object + path: + type: string + service: + type: string + tlssecret: + type: string + type: object + location: + type: string + networkpolicy: + type: boolean + pluginconfig: + properties: + config: + type: string + configsecret: + type: string + type: object + plugins: + items: + properties: + id: + type: string + version: + type: string + type: object + type: array + service: + properties: + annotations: + type: object + name: + type: string + nodeport: + format: int32 + type: integer + servicetype: + type: string + type: object + serviceaccount: + type: string + storage: + properties: + jobspvc: + type: string + jobspvcspec: + type: object + type: object + type: object + status: + properties: + adminsecret: + type: string + phase: + type: string + required: + - phase + type: object + type: object + version: v1alpha1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: null diff --git a/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsjob.yaml b/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsjob.yaml new file mode 100644 index 0000000000..4c5f519d13 --- /dev/null +++ b/incubator/jenkins-operator/CRD-protected/jenkins_v1alpha1_jenkinsjob.yaml @@ -0,0 +1,67 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + helm.sh/resource-policy: keep + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + controller-tools.k8s.io: "1.0" + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: jenkinsjobs.jenkins.jenkinsoperator.maratoid.github.com +spec: + group: jenkins.jenkinsoperator.maratoid.github.com + names: + kind: JenkinsJob + plural: jenkinsjobs + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + credentials: + items: + properties: + credential: + pattern: ^[a-z][a-z-]*[a-z] + type: string + credentialtype: + pattern: usernamePassword|secretText|serviceaccount|vaultgithub|vaultapprole|vaulttoken + type: string + secret: + type: string + secretdata: + type: object + type: object + type: array + jenkinsinstance: + type: string + jobdsl: + type: string + jobxml: + type: string + type: object + status: + properties: + phase: + type: string + required: + - phase + type: object + type: object + version: v1alpha1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: null diff --git a/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsinstance.yaml b/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsinstance.yaml new file mode 100644 index 0000000000..007b183f1a --- /dev/null +++ b/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsinstance.yaml @@ -0,0 +1,112 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + controller-tools.k8s.io: "1.0" + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: jenkinsinstances.jenkins.jenkinsoperator.maratoid.github.com +spec: + group: jenkins.jenkinsoperator.maratoid.github.com + names: + kind: JenkinsInstance + plural: jenkinsinstances + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + adminemail: + type: string + adminsecret: + type: string + annotations: + type: object + env: + type: object + executors: + format: int32 + type: integer + image: + pattern: .+:.+ + type: string + ingress: + properties: + annotations: + type: object + path: + type: string + service: + type: string + tlssecret: + type: string + type: object + location: + type: string + networkpolicy: + type: boolean + pluginconfig: + properties: + config: + type: string + configsecret: + type: string + type: object + plugins: + items: + properties: + id: + type: string + version: + type: string + type: object + type: array + service: + properties: + annotations: + type: object + name: + type: string + nodeport: + format: int32 + type: integer + servicetype: + type: string + type: object + serviceaccount: + type: string + storage: + properties: + jobspvc: + type: string + jobspvcspec: + type: object + type: object + type: object + status: + properties: + adminsecret: + type: string + phase: + type: string + required: + - phase + type: object + type: object + version: v1alpha1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: null diff --git a/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsjob.yaml b/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsjob.yaml new file mode 100644 index 0000000000..67db59e863 --- /dev/null +++ b/incubator/jenkins-operator/CRD/jenkins_v1alpha1_jenkinsjob.yaml @@ -0,0 +1,65 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + controller-tools.k8s.io: "1.0" + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: jenkinsjobs.jenkins.jenkinsoperator.maratoid.github.com +spec: + group: jenkins.jenkinsoperator.maratoid.github.com + names: + kind: JenkinsJob + plural: jenkinsjobs + scope: Namespaced + validation: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + credentials: + items: + properties: + credential: + pattern: ^[a-z][a-z-]*[a-z] + type: string + credentialtype: + pattern: usernamePassword|secretText|serviceaccount|vaultgithub|vaultapprole|vaulttoken + type: string + secret: + type: string + secretdata: + type: object + type: object + type: array + jenkinsinstance: + type: string + jobdsl: + type: string + jobxml: + type: string + type: object + status: + properties: + phase: + type: string + required: + - phase + type: object + type: object + version: v1alpha1 +status: + acceptedNames: + kind: "" + plural: "" + conditions: null diff --git a/incubator/jenkins-operator/Chart.yaml b/incubator/jenkins-operator/Chart.yaml new file mode 100644 index 0000000000..b9e8a63e25 --- /dev/null +++ b/incubator/jenkins-operator/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +appVersion: 0.1.12 +description: A Helm chart for Kubernetes Jenkins Operator +name: jenkins-operator +version: 0.1.12 +icon: https://wiki.jenkins-ci.org/download/attachments/2916393/logo.png +keywords: +- jenkins +- testing +home: https://github.com/samsung-cnct/jenkins-operator +sources: +- https://github.com/samsung-cnct/jenkins-operator +- https://github.com/jenkinsci/jenkins +maintainers: +- name: maratoid + email: maratoid@gmail.com diff --git a/incubator/jenkins-operator/RBAC/rbac_role.yaml b/incubator/jenkins-operator/RBAC/rbac_role.yaml new file mode 100644 index 0000000000..d9f3d2972a --- /dev/null +++ b/incubator/jenkins-operator/RBAC/rbac_role.yaml @@ -0,0 +1,162 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: '{{ include "jenkins-operator.name" . }}-rbac-role' +rules: +- apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - apps + resources: + - deployments + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - events + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - nodes + verbs: + - list +- apiGroups: + - extensions + resources: + - ingresses + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - serviceaccounts + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - networking.k8s.io + resources: + - networkpolicies + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - jenkins.jenkinsoperator.maratoid.github.com + resources: + - jenkinsinstances + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - jenkins.jenkinsoperator.maratoid.github.com + resources: + - jenkinsjobs + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - watch + - create + - update + - patch + - delete diff --git a/incubator/jenkins-operator/RBAC/rbac_role_binding.yaml b/incubator/jenkins-operator/RBAC/rbac_role_binding.yaml new file mode 100644 index 0000000000..63a2d62694 --- /dev/null +++ b/incubator/jenkins-operator/RBAC/rbac_role_binding.yaml @@ -0,0 +1,19 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/instance: '{{.Release.Name}}' + app.kubernetes.io/managed-by: '{{.Release.Service}}' + app.kubernetes.io/name: '{{include "jenkins-operator.name" .}}' + app.kubernetes.io/version: '{{.Chart.AppVersion | replace "+" "_" | trunc 63}}' + helm.sh/chart: '{{include "jenkins-operator.chart" .}}' + name: '{{ include "jenkins-operator.name" . }}-rbac-rolebinding' +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: '{{ include "jenkins-operator.name" . }}-rbac-role' +subjects: +- kind: ServiceAccount + name: '{{ include "jenkins-operator.name" . }}' + namespace: '{{ .Release.Namespace}}' diff --git a/incubator/jenkins-operator/README.md b/incubator/jenkins-operator/README.md new file mode 100644 index 0000000000..f1c7b88079 --- /dev/null +++ b/incubator/jenkins-operator/README.md @@ -0,0 +1,58 @@ +# Jenkins Operator + +[jenkins-operator](https://github.com/samsung-cnct/jenkins-operator) simplifies +Jenkins configuration and management. + +**DISCLAIMER:** This application and chart are alpha quality. Proceed with care. + +## Introduction + +The jenkins operator manages Jenkins instances deployed to [Kubernetes](https://k8s.io) and automates tasks related to operating a Jenkins server + +- Create and Destroy instances +- Create and Destroy Jobs and Credentials + +For more information on using the operator please see [the documentation](https://github.com/samsung-cnct/jenkins-operator). + +## Prerequisites + +- Kubernetes 1.9+ +- Jenkins 2.1+ + +## Installing the Chart + +To install the chart with the release name `jenkins-operator` checkout this repository and run the following command from the root of it: + +```bash +$ helm install deployments/helm/jenkins-operator --name jenkins-operator +``` + +## Uninstalling the Chart + +To uninstall/delete the `jenkins-operator` deployment: + +```bash +$ helm delete jenkins-operator +``` + +## Configuration + +The following table lists the configurable parameters of the jenkins-operator chart and their default values. + +| Parameter | Description | Default | +| -------------------- | ---------------------------------------------------------------- | -------------------------------------------- | +| `replicaCount` | Number of operator replicas to create | `1` | +| `image.repository` | Operator container image, including version | `quay.io/samsung_cnct/jenkins-operator` | +| `image.tag` | Operator container image tag | `0.1.7` | +| `image.pullPolicy` | Operator container image pull policy | `IfNotPresent` | +| `nameOverride` | Override the app name | | +| `fullnameOverride` | Override the app full name | | +| `keepCRDs` | If Helm should skip deleting CRDs when the operator is deleted | `false` | +| `rbac` | Install required RBAC service account, roles and rolebindings | `true` | +| `chartCrds` | If the CRDs should be installed from chart templates | `true` | +| `args` | Arguments passed to the operator binary | `--alsologtostderr --install-crds=false` | +| `resources.cpu` | CPU limit per jenkins-operator pod | | +| `resources.memory` | Memory limit per jenkins-operator pod | | +| `nodeSelector` | Node labels for jenkins-operator pod assignment | `{}` | +| `tolerations` | Tolerations for pod assignment | `[]` | +| `affinity` | Affinity settings for pod assignment | `{}` | \ No newline at end of file diff --git a/incubator/jenkins-operator/templates/NOTES.txt b/incubator/jenkins-operator/templates/NOTES.txt new file mode 100644 index 0000000000..e078fcef95 --- /dev/null +++ b/incubator/jenkins-operator/templates/NOTES.txt @@ -0,0 +1,67 @@ +1. jenkins-operator deployed. + + Check the jenkins-operator logs: + export POD=$(kubectl get pods -l app={{ template "jenkins-operator.name" . }} --namespace {{ .Release.Namespace }} --output name) + kubectl logs $POD --namespace={{ .Release.Namespace }} + +2. If want to deploy a jenkins instance, please create Custom Resource objects, like so: + +a) Create a ServiceAccount : + +kubectl create sa jenkins + +b) Create admin secret (user: admin, password: password): + +kubectl apply -f - <