-
Notifications
You must be signed in to change notification settings - Fork 236
Generic Helm Chart #3266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csviri
wants to merge
9
commits into
operator-framework:main
Choose a base branch
from
csviri:helm-chart
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Generic Helm Chart #3266
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b5c7a0b
Generic Helm Chart
csviri 44a0578
wip
csviri 7a2f49f
Update helm/generic-helm-chart/templates/deployment.yaml
csviri dc525a5
wip
csviri 8d3b0aa
wip
csviri de0b4d3
wip
csviri 5be7e8d
wip
csviri b152194
helm chart fix
csviri 1dfb6bf
wip
csviri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # | ||
| # Copyright Java Operator SDK Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| apiVersion: v2 | ||
| name: generic-operator-chart | ||
| description: A generic reusable Helm chart for Java operators built with Java Operator SDK (JOSDK) | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "0.1.0" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| {{/* | ||
| Expand the name of the chart. | ||
| */}} | ||
| {{- define "generic-operator.name" -}} | ||
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Create a default fully qualified app name. | ||
| */}} | ||
| {{- define "generic-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 "generic-operator.chart" -}} | ||
| {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Common labels | ||
| */}} | ||
| {{- define "generic-operator.labels" -}} | ||
| helm.sh/chart: {{ include "generic-operator.chart" . }} | ||
| {{ include "generic-operator.selectorLabels" . }} | ||
| {{- if .Chart.AppVersion }} | ||
| app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
| {{- end }} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Selector labels | ||
| */}} | ||
| {{- define "generic-operator.selectorLabels" -}} | ||
| app.kubernetes.io/name: {{ include "generic-operator.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Create the name of the service account to use | ||
| */}} | ||
| {{- define "generic-operator.serviceAccountName" -}} | ||
| {{- if .Values.serviceAccount.create }} | ||
| {{- default (include "generic-operator.fullname" .) .Values.serviceAccount.name }} | ||
| {{- else }} | ||
| {{- default "default" .Values.serviceAccount.name }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Image tag - defaults to chart appVersion | ||
| */}} | ||
| {{- define "generic-operator.imageTag" -}} | ||
| {{- .Values.image.tag | default .Chart.AppVersion }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Default verbs for primary resources | ||
| */}} | ||
| {{- define "generic-operator.primaryVerbs" -}} | ||
| - get | ||
| - list | ||
| - watch | ||
| - patch | ||
| - update | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Default verbs for primary resource status | ||
| */}} | ||
| {{- define "generic-operator.primaryStatusVerbs" -}} | ||
| - get | ||
| - patch | ||
| - update | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Default verbs for secondary resources | ||
| */}} | ||
| {{- define "generic-operator.secondaryVerbs" -}} | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - update | ||
| - patch | ||
| - delete | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # | ||
| # Copyright Java Operator SDK Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| {{- if .Values.rbac.create }} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "generic-operator.fullname" . }} | ||
| labels: | ||
| {{- include "generic-operator.labels" . | nindent 4 }} | ||
| rules: | ||
| {{- /* Primary resources - the custom resources the operator reconciles */}} | ||
| {{- range .Values.primaryResources }} | ||
| - apiGroups: | ||
| - {{ .apiGroup | quote }} | ||
| resources: | ||
| {{- range .resources }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| verbs: | ||
| {{- if .verbs }} | ||
| {{- range .verbs }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| {{- else }} | ||
| {{- include "generic-operator.primaryVerbs" $ | nindent 2 }} | ||
| {{- end }} | ||
| - apiGroups: | ||
| - {{ .apiGroup | quote }} | ||
| resources: | ||
| {{- range .resources }} | ||
| - {{ . }}/status | ||
| {{- end }} | ||
| verbs: | ||
| {{- if .statusVerbs }} | ||
| {{- range .statusVerbs }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| {{- else }} | ||
| {{- include "generic-operator.primaryStatusVerbs" $ | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- /* Secondary resources - resources managed by the operator */}} | ||
| {{- range .Values.secondaryResources }} | ||
| - apiGroups: | ||
| - {{ .apiGroup | quote }} | ||
| resources: | ||
| {{- range .resources }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| verbs: | ||
| {{- if .verbs }} | ||
| {{- range .verbs }} | ||
| - {{ . }} | ||
| {{- end }} | ||
| {{- else }} | ||
| {{- include "generic-operator.secondaryVerbs" $ | nindent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
| # Event permissions - for recording events | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - events | ||
| verbs: | ||
| - create | ||
| - patch | ||
| {{- /* Leader election - Lease permissions */}} | ||
| {{- if .Values.leaderElection.enabled }} | ||
| # Lease permissions - for leader election | ||
| - apiGroups: | ||
| - coordination.k8s.io | ||
| resources: | ||
| - leases | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - create | ||
| - update | ||
| - patch | ||
| - delete | ||
| {{- end }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # | ||
| # Copyright Java Operator SDK Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| {{- if .Values.rbac.create }} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "generic-operator.fullname" . }} | ||
| labels: | ||
| {{- include "generic-operator.labels" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "generic-operator.fullname" . }} | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "generic-operator.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # | ||
| # Copyright Java Operator SDK Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: {{ include "generic-operator.fullname" . }}-config | ||
| labels: | ||
| {{- include "generic-operator.labels" . | nindent 4 }} | ||
| data: | ||
| config.yaml: | | ||
| {{- index .Values.operatorConfig "config" | nindent 4 }} | ||
| log4j2.xml: | | ||
| {{- .Values.operatorConfig.log4j2 | nindent 4 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # | ||
| # Copyright Java Operator SDK Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ include "generic-operator.fullname" . }} | ||
| labels: | ||
| {{- include "generic-operator.labels" . | nindent 4 }} | ||
| spec: | ||
| replicas: {{ .Values.replicaCount }} | ||
| selector: | ||
| matchLabels: | ||
| {{- include "generic-operator.selectorLabels" . | nindent 6 }} | ||
| template: | ||
| metadata: | ||
| annotations: | ||
| checksum/config: {{ .Values.operatorConfig | toJson | sha256sum }} | ||
| {{- with .Values.podAnnotations }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| labels: | ||
| {{- include "generic-operator.selectorLabels" . | nindent 8 }} | ||
| spec: | ||
| {{- with .Values.podSecurityContext }} | ||
| securityContext: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.imagePullSecrets }} | ||
| imagePullSecrets: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| serviceAccountName: {{ include "generic-operator.serviceAccountName" . }} | ||
| {{- with .Values.extraInitContainers }} | ||
| initContainers: | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| containers: | ||
| - name: operator | ||
| securityContext: | ||
| {{- toYaml .Values.securityContext | nindent 12 }} | ||
| image: "{{ required "A valid .Values.image.repository is required" .Values.image.repository }}:{{ include "generic-operator.imageTag" . }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| env: | ||
| - name: OPERATOR_NAMESPACE | ||
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: metadata.namespace | ||
| {{- if .Values.operator.watchNamespace }} | ||
| - name: WATCH_NAMESPACE | ||
| value: {{ .Values.operator.watchNamespace | quote }} | ||
| {{- end }} | ||
| {{- with .Values.operator.env }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| resources: | ||
| {{- toYaml .Values.resources | nindent 12 }} | ||
| volumeMounts: | ||
| - name: config | ||
| mountPath: /config | ||
| readOnly: true | ||
| {{- with .Values.extraVolumeMounts }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} | ||
| {{- with .Values.extraContainers }} | ||
| {{- toYaml . | nindent 6 }} | ||
| {{- end }} | ||
| volumes: | ||
| - name: config | ||
| configMap: | ||
| name: {{ include "generic-operator.fullname" . }}-config | ||
| {{- with .Values.extraVolumes }} | ||
| {{- toYaml . | nindent 6 }} | ||
| {{- end }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be same as JOSDK version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good question, so I don't really want to advertise this helm chart, as something that follows josdk semver versioning. Rather it mean to be a starting point for users to basically copy paste and extend. But this is up to the debate. For now I would stick with this basic / simple approach and we can discuss on next community meeting if we should improve on that in a next iteration, and follow semver + add helm repository support from the webpage.