Add jenkins-operator chart to incubator (#8979)

* Add jenkins-operator chart to incubator

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>

* fix linting errors

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>

* document non-standard items in values.yaml

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>

* chart version update

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>

* incorporate review comments

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>

* missing labels on job crd

Signed-off-by: Marat Garafutdinov <maratoid@gmail.com>
This commit is contained in:
Marat Garafutdinov
2018-11-30 10:20:24 -08:00
committed by k8s-ci-robot
parent 482d28da9b
commit 41d3f1e9c8
16 changed files with 821 additions and 0 deletions
@@ -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
@@ -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
@@ -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
@@ -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
+16
View File
@@ -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
@@ -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
@@ -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}}'
+58
View File
@@ -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 | `{}` |
@@ -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 - <<EOF
apiVersion: v1
data:
pass: cGFzc3dvcmQ=
user: YWRtaW4=
kind: Secret
metadata:
name: admin-secret
type: Opaque
EOF
c) Create jenkins instance custom resource:
kubectl apply -f - <<EOF
apiVersion: jenkins.jenkinsoperator.maratoid.github.com/v1alpha1
kind: JenkinsInstance
metadata:
name: jenkinsinstance-sample
spec:
image: "jenkins/jenkins:lts"
executors: 1
adminsecret: admin-secret
location: https://jenkins.example.com
adminemail: admin@example.com
service:
name: jenkins
servicetype: ClusterIP
serviceaccount: jenkins
EOF
d) create jenkins job custom resource:
kubectl apply -f - <<EOF
apiVersion: jenkins.jenkinsoperator.maratoid.github.com/v1alpha1
kind: JenkinsJob
metadata:
name: samplejob
spec:
jenkinsinstance: jenkinsinstance-sample
jobdsl: |
freeStyleJob('samplejob') {
description('Job created from custom resource with JobDSL')
displayName('From custom resource DSL')
steps {
shell('echo Hello World!')
}
}
EOF
3. For more details on supported custom resource object please refer to jenkins operator documentation:
https://github.com/samsung-cnct/jenkins-operator
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "jenkins-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "jenkins-operator.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "jenkins-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,14 @@
{{- if .Values.chartCrds }}
{{ $root := . }}
{{- if .Values.keepCRDs }}
{{- range tuple "CRD-protected/jenkins_v1alpha1_jenkinsinstance.yaml" "CRD-protected/jenkins_v1alpha1_jenkinsjob.yaml" }}
---
{{ tpl ($root.Files.Get .) $root }}
{{- end }}
{{- else }}
{{- range tuple "CRD/jenkins_v1alpha1_jenkinsinstance.yaml" "CRD/jenkins_v1alpha1_jenkinsjob.yaml" }}
---
{{ tpl ($root.Files.Get .) $root }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "jenkins-operator.fullname" . }}
labels:
helm.sh/chart: {{ include "jenkins-operator.chart" . }}
app.kubernetes.io/name: {{ include "jenkins-operator.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" | trunc 63 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "jenkins-operator.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ include "jenkins-operator.name" . }}
release: {{ .Release.Name }}
spec:
{{- if .Values.rbac }}
serviceAccountName: {{ include "jenkins-operator.name" . }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["./jenkins-operator"]
args: {{ toJson .Values.args }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
@@ -0,0 +1,4 @@
{{- if .Values.rbac }}
{{- $roleText := .Files.Get "RBAC/rbac_role.yaml" -}}
{{ tpl $roleText . }}
{{- end }}
@@ -0,0 +1,4 @@
{{- if .Values.rbac }}
{{- $roleBindingText := .Files.Get "RBAC/rbac_role_binding.yaml" -}}
{{ tpl $roleBindingText . }}
{{- end }}
@@ -0,0 +1,12 @@
{{- if .Values.rbac }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "jenkins-operator.name" . }}
labels:
helm.sh/chart: {{ include "jenkins-operator.chart" . }}
app.kubernetes.io/name: {{ include "jenkins-operator.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" | trunc 63 }}
{{- end }}
+30
View File
@@ -0,0 +1,30 @@
replicaCount: 1
image:
repository: quay.io/samsung_cnct/jenkins-operator
tag: 0.1.12
pullPolicy: IfNotPresent
# short resource name override
nameOverride: ''
# long resource name override
fullnameOverride: ''
# keep CRDs installed after a release deletion
keepCRDs: false
# install RBAC resources
rbac: true
# install CRDs from chart resources (rather than from embedded binary ones)
chartCrds: true
# command line arguments to be passed to the operator binary
args:
- --alsologtostderr
- --install-crds=false
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}