From d9c22fcfebe5fbf6147a1cc87592964eb9e96ca0 Mon Sep 17 00:00:00 2001 From: Tiago Bueno <49003339+tlbueno@users.noreply.github.com> Date: Fri, 17 May 2024 16:35:10 -0300 Subject: [PATCH] Initial version Signed-off-by: Tiago Bueno <49003339+tlbueno@users.noreply.github.com> --- .github/dependabot.yaml | 16 ++++ .github/workflows/release.yaml | 35 +++++++++ .helmignore | 23 ++++++ LICENSE | 21 ++++++ README.md | 30 ++++++++ charts/olm-operator-installer/Chart.yaml | 24 ++++++ charts/olm-operator-installer/README.md | 73 +++++++++++++++++++ .../examples/amq-brokoer-operator -710x.yaml | 47 ++++++++++++ .../examples/amq-brokoer-operator-711x.yaml | 47 ++++++++++++ .../templates/NOTES.txt | 9 +++ .../templates/Namespace.yaml | 10 +++ .../templates/OperatorGroup.yaml | 16 ++++ .../templates/Subscription.yaml | 15 ++++ charts/olm-operator-installer/values.yaml | 45 ++++++++++++ 14 files changed, 411 insertions(+) create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .helmignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 charts/olm-operator-installer/Chart.yaml create mode 100644 charts/olm-operator-installer/README.md create mode 100644 charts/olm-operator-installer/examples/amq-brokoer-operator -710x.yaml create mode 100644 charts/olm-operator-installer/examples/amq-brokoer-operator-711x.yaml create mode 100644 charts/olm-operator-installer/templates/NOTES.txt create mode 100644 charts/olm-operator-installer/templates/Namespace.yaml create mode 100644 charts/olm-operator-installer/templates/OperatorGroup.yaml create mode 100644 charts/olm-operator-installer/templates/Subscription.yaml create mode 100644 charts/olm-operator-installer/values.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..69969a7 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,16 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + assignees: + - "tlbueno" + reviewers: + - "tlbueno" + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4159b5c --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,35 @@ +name: Release Charts + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + release: + # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions + # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v4 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.helmignore b/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bf88b35 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Tiago Bueno + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6e5373 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# helm-charts + +An collections of helm chart + +### Usage + +[Helm](https://helm.sh) must be installed to use the charts. Please refer to +Helm's [documentation](https://helm.sh/docs) to get started. + +Once Helm has been set up correctly, add the repo as follows: + +```sh +helm repo add tlbueno https://tlbueno.github.io/helm-charts +``` + +If you had already added this repo earlier, run `helm repo update` to retrieve +the latest versions of the packages. You can then run `helm search repo +tlbueno` to see the charts. + +To install the a chart: + +```sh +helm install my- tlbueno/ +``` + +To uninstall the chart: + +```sh +helm delete my- +``` \ No newline at end of file diff --git a/charts/olm-operator-installer/Chart.yaml b/charts/olm-operator-installer/Chart.yaml new file mode 100644 index 0000000..c1bee78 --- /dev/null +++ b/charts/olm-operator-installer/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: olm-operator-installer +description: A Helm chart to install an Operator Lifecycle Manager (OLM) operator + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "" diff --git a/charts/olm-operator-installer/README.md b/charts/olm-operator-installer/README.md new file mode 100644 index 0000000..228d772 --- /dev/null +++ b/charts/olm-operator-installer/README.md @@ -0,0 +1,73 @@ +# olm-operator-installer + +An helm chart to install an operator using Operator Lifecycle Manager (OLM) + +The chart will: +- create a namespace +- deploy an operator group with/without a selector label defined in the values +- deploy the subscription + +By default, the chart deploy a cert-manager operator. But you can find some more examples in [examples](./examples) folder + +### How to use + +Check [README.md](../../README.md) for repo installation details + +To install the chart, ie: +```sh +helm install my-operator-chart tlbueno-repo/olm-operator-installer +``` + +You may override the default values below by creating a yaml file with one or more entries and use it in helm command, ie: +```sh +helm install my-operator-chart -f ./my-values.yaml tlbueno-repo/olm-operator-installer +``` + +Default values: +```yaml +# Default values for olm-operator-installer. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +namespace: + # namespace where the operator will be installed + name: cert-manager + +operatorGroup: + # skip the operator group deploy if false + deploy: true + # operator group name + name: cert-manager-operator + + selector: + # do not set selector matchLabels if false + enabled: false + # A list of maps with the labels + matchLabels: + - name: olm-operator-installer/managed-by + value: "{{ .Values.subscription.name }}" + +subscription: + # subscription name + name: cert-manager-operator-sub + + # channel name + channel: stable + + # operator package name + operatorName: cert-manager + + # catalog name from which the operator will be installed + source: operatorhubio-catalog + + # catalog namespace + sourceNamespace: olm + + # install plan approval type + installPlanApproval: Automatic + + # the initial version of the operator to be installed + # if empty it will not be used in the subscription + startingCSV: "" +``` + diff --git a/charts/olm-operator-installer/examples/amq-brokoer-operator -710x.yaml b/charts/olm-operator-installer/examples/amq-brokoer-operator -710x.yaml new file mode 100644 index 0000000..5efa771 --- /dev/null +++ b/charts/olm-operator-installer/examples/amq-brokoer-operator -710x.yaml @@ -0,0 +1,47 @@ +# This is an example to install RedHat AMQ Broker Operator +# +# To have it working you need to have the redhat operator catalog installed on your cluster +# and the you need to have your cluster configured with credentials to install images from +# registry.redhat.io + +namespace: + # namespace where the operator will be installed + name: amq-broker-operator-olm + +operatorGroup: + # skip the operator group deploy if false + deploy: true + # operator group name + name: amq-broker-operator + + selector: + # do not set selector matchLabels if false + enabled: true + # A list of maps with the labels + matchLabels: + - name: olm-operator-installer/managed-by + value: "{{ .Values.subscription.name }}" + +subscription: + # subscription name + name: amq-broker-operator-olm-sub + + # channel name + channel: 7.10.x + + # operator package name + operatorName: amq-broker-rhel8 + + # catalog name from which the operator will be installed + source: redhat-operators-catalog + + # catalog namespace + sourceNamespace: olm + + # install plan approval type + installPlanApproval: Automatic + + # the initial version of the operator to be installed + # if empty it will not be used in the subscription + startingCSV: "" + diff --git a/charts/olm-operator-installer/examples/amq-brokoer-operator-711x.yaml b/charts/olm-operator-installer/examples/amq-brokoer-operator-711x.yaml new file mode 100644 index 0000000..e0798b1 --- /dev/null +++ b/charts/olm-operator-installer/examples/amq-brokoer-operator-711x.yaml @@ -0,0 +1,47 @@ +# This is an example to install RedHat AMQ Broker Operator +# +# To have it working you need to have the redhat operator catalog installed on your cluster +# and the you need to have your cluster configured with credentials to install images from +# registry.redhat.io + +namespace: + # namespace where the operator will be installed + name: amq-broker-operator-olm + +operatorGroup: + # skip the operator group deploy if false + deploy: true + # operator group name + name: amq-broker-operator + + selector: + # do not set selector matchLabels if false + enabled: true + # A list of maps with the labels + matchLabels: + - name: olm-operator-installer/managed-by + value: "{{ .Values.subscription.name }}" + +subscription: + # subscription name + name: amq-broker-operator-olm-sub + + # channel name + channel: 7.11.x + + # operator package name + operatorName: amq-broker-rhel8 + + # catalog name from which the operator will be installed + source: redhat-operators-catalog + + # catalog namespace + sourceNamespace: olm + + # install plan approval type + installPlanApproval: Automatic + + # the initial version of the operator to be installed + # if empty it will not be used in the subscription + startingCSV: "" + diff --git a/charts/olm-operator-installer/templates/NOTES.txt b/charts/olm-operator-installer/templates/NOTES.txt new file mode 100644 index 0000000..7f9a777 --- /dev/null +++ b/charts/olm-operator-installer/templates/NOTES.txt @@ -0,0 +1,9 @@ +Thank you for installing {{ .Chart.Name }}. + +Your release is named {{ .Release.Name }}. + +To learn more about the release, try: + + $ helm status {{ .Release.Name }} + $ helm get all {{ .Release.Name }} + diff --git a/charts/olm-operator-installer/templates/Namespace.yaml b/charts/olm-operator-installer/templates/Namespace.yaml new file mode 100644 index 0000000..41c0614 --- /dev/null +++ b/charts/olm-operator-installer/templates/Namespace.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace.name }} + {{- if .Values.operatorGroup.selector.enabled }} + labels: + {{- range .Values.operatorGroup.selector.matchLabels }} + {{ .name }}: {{ tpl .value $ }} + {{- end }} + {{- end }} diff --git a/charts/olm-operator-installer/templates/OperatorGroup.yaml b/charts/olm-operator-installer/templates/OperatorGroup.yaml new file mode 100644 index 0000000..35373bc --- /dev/null +++ b/charts/olm-operator-installer/templates/OperatorGroup.yaml @@ -0,0 +1,16 @@ +{{- if .Values.operatorGroup.deploy }} +apiVersion: operators.coreos.com/v1alpha2 +kind: OperatorGroup +metadata: + name: {{ .Values.operatorGroup.name }} + namespace: {{ .Values.namespace.name }} +spec: +{{- if .Values.operatorGroup.selector.enabled }} + selector: + matchLabels: + {{- range .Values.operatorGroup.selector.matchLabels }} + {{ .name }}: {{ tpl .value $ }} + {{- end }} +{{- end }} +{{- end }} + diff --git a/charts/olm-operator-installer/templates/Subscription.yaml b/charts/olm-operator-installer/templates/Subscription.yaml new file mode 100644 index 0000000..d0b3d8e --- /dev/null +++ b/charts/olm-operator-installer/templates/Subscription.yaml @@ -0,0 +1,15 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + name: {{ .Values.subscription.name }} + namespace: {{ .Values.namespace.name }} +spec: + channel: {{ .Values.subscription.channel }} + name: {{ .Values.subscription.operatorName }} + source: {{ .Values.subscription.source }} + sourceNamespace: {{ .Values.subscription.sourceNamespace }} + installPlanApproval: {{ .Values.subscription.installPlanApproval }} + {{- if .Values.subscription.startingCSV }} + startingCSV: {{ .Values.subscription.startingCSV }} + {{- end }} + diff --git a/charts/olm-operator-installer/values.yaml b/charts/olm-operator-installer/values.yaml new file mode 100644 index 0000000..dc22a20 --- /dev/null +++ b/charts/olm-operator-installer/values.yaml @@ -0,0 +1,45 @@ +# Default values for olm-operator-installer. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +namespace: + # namespace where the operator will be installed + name: cert-manager + +operatorGroup: + # skip the operator group deploy if false + deploy: true + # operator group name + name: cert-manager-operator + + selector: + # do not set selector matchLabels if false + enabled: false + # A list of maps with the labels + matchLabels: + - name: olm-operator-installer/managed-by + value: "{{ .Values.subscription.name }}" + +subscription: + # subscription name + name: cert-manager-operator-sub + + # channel name + channel: stable + + # operator package name + operatorName: cert-manager + + # catalog name from which the operator will be installed + source: operatorhubio-catalog + + # catalog namespace + sourceNamespace: olm + + # install plan approval type + installPlanApproval: Automatic + + # the initial version of the operator to be installed + # if empty it will not be used in the subscription + startingCSV: "" +