diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..8d8dbeb7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,9 @@ +# See https://github.com/scottrigby/prometheus-helm-charts/issues/12 +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners +# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax + +# The repo admins team will be the default owners for everything in the repo. +# Unless a later match takes precedence, they will be requested for review when someone opens a pull request. +* @tgip-work + +/charts/ethadapter/ @tgip-work diff --git a/.github/workflows/chart_testing.yaml b/.github/workflows/chart_testing.yaml new file mode 100644 index 00000000..e0ebb6d3 --- /dev/null +++ b/.github/workflows/chart_testing.yaml @@ -0,0 +1,32 @@ +# +# Checks if the version has been bumped for each changed Chart on a Pull Request. +# https://github.com/helm/chart-testing +# +name: Chart testing + +on: pull_request + +jobs: + chart-testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + with: + fetch-depth: 0 + + # + # Note: v3.5.0 = sha256:40d3529ca14fb02940091ae0b3fa77ce6c96ad78b31bbb243f4eed5ac33bdbe4 + # + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(docker run --rm --workdir=/data --volume "$(pwd)":/data quay.io/helmpack/chart-testing@sha256:40d3529ca14fb02940091ae0b3fa77ce6c96ad78b31bbb243f4eed5ac33bdbe4 ct list-changed --config ct.yaml) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + + - name: Run chart-testing (lint) + id: lint + run: | + docker run --rm --workdir=/data --volume "$(pwd)":/data quay.io/helmpack/chart-testing@sha256:40d3529ca14fb02940091ae0b3fa77ce6c96ad78b31bbb243f4eed5ac33bdbe4 ct lint --config ct.yaml diff --git a/.github/workflows/check-codeowners.yaml b/.github/workflows/check-codeowners.yaml new file mode 100644 index 00000000..21d4b20d --- /dev/null +++ b/.github/workflows/check-codeowners.yaml @@ -0,0 +1,32 @@ +# +# Checks if file .github/CODEOWNERS is up to date on a Pull Request. +# +name: Check CODEOWNERS + +on: pull_request + +jobs: + find-diffs: + runs-on: ubuntu-20.04 + name: Check if CODEOWNERS file is up to date with maintainers from helm chart(s) + + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + + - name: install yq + run: | + sudo snap install yq + + - name: generate CODEOWNERS + run: | + ./scripts/check-codeowners.sh > .github/CODEOWNERS + cat .github/CODEOWNERS + + - name: check CODEOWNERS for modifications + run: | + git diff --exit-code || echo "::warning::There is at least one codeowner mismatch." \ No newline at end of file diff --git a/.github/workflows/detect_secrets.yaml b/.github/workflows/detect_secrets.yaml new file mode 100644 index 00000000..e2473cf6 --- /dev/null +++ b/.github/workflows/detect_secrets.yaml @@ -0,0 +1,24 @@ +# +# Looks for potential secret values/sensitive data that MUST not be checked in on a Pull Request. +# See https://github.com/reviewdog/action-detect-secrets#troubleshooting for whitelisting false positives. +# +name: Detect Secrets + +on: pull_request + +jobs: + detect-secrets: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + + # https://github.com/reviewdog/action-detect-secrets - works for pull requests only + - name: detect-secrets + uses: reviewdog/action-detect-secrets@d248ce8b83ee2d3fdc01df94bc64312d428665ae # https://github.com/reviewdog/action-detect-secrets/releases/tag/v0.7.0 + with: + github_token: ${{ secrets.github_token }} + # see https://github.com/Yelp/detect-secrets + # https://github.com/reviewdog/action-detect-secrets/issues/16 + detect_secrets_flags: --force-use-all-plugins --exclude-files charts/standalone-quorum/templates/ --exclude-files charts/smartcontract/templates/configmap-code.yaml diff --git a/.github/workflows/helm_unittests.yaml b/.github/workflows/helm_unittests.yaml new file mode 100644 index 00000000..dd5c8a47 --- /dev/null +++ b/.github/workflows/helm_unittests.yaml @@ -0,0 +1,36 @@ +# +# Runs Helm Unittests https://github.com/quintush/helm-unittest on a push and Pull Request. +# +name: Helm Unittests + +on: [push, pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + name: Run Helm Unittest + # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + + # https://github.com/marketplace/actions/engineerd-configurator + - uses: engineerd/configurator@479197cb150e720c848c8dfbe12da101471258e3 # v0.0.8 + name: Setup helm + with: + name: helm + url: https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz + pathInArchive: linux-amd64/helm + - run: helm version + + # https://github.com/quintush/helm-unittest + - name: Setup Helm Unittest + run: helm plugin install https://github.com/quintush/helm-unittest --version=v0.2.8 + + - name: Run Helm Unittest + run: helm unittest --helm3=true charts/* + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..11a66dd5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,43 @@ +# +# Runs the "Chart Releaser" https://github.com/helm/chart-releaser-action on push to main branch (e.g. on a succesful merge from a Pull Request). +# 1. The "Chart Releaser" creates a GitHub Release for each Chart that has changed +# 2. and updates the "index.yaml" of the Helm Repository in branch "gh-pages" (GitHub Pages). +# +name: Release Charts + +on: + push: + branches: + - master + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + # https://github.com/marketplace/actions/engineerd-configurator + - uses: engineerd/configurator@479197cb150e720c848c8dfbe12da101471258e3 # v0.0.8 + name: Setup helm + with: + name: helm + url: https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz + pathInArchive: linux-amd64/helm + - run: helm version + + # https://github.com/helm/chart-releaser-action + - name: Run chart-releaser + uses: helm/chart-releaser-action@c25b74a986eb925b398320414b576227f375f946 # v1.2.1 + with: + charts_dir: charts + #config: cr.yaml + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/validate_code.yaml b/.github/workflows/validate_code.yaml new file mode 100644 index 00000000..6bdfee36 --- /dev/null +++ b/.github/workflows/validate_code.yaml @@ -0,0 +1,49 @@ +name: Validate code +on: [push, pull_request] +jobs: + pre-commit: + runs-on: ubuntu-latest + name: Run Pre-Commit and linter + # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest + defaults: + run: + shell: bash + + steps: + - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + name: Checkout + + # https://github.com/marketplace/actions/engineerd-configurator + - uses: engineerd/configurator@479197cb150e720c848c8dfbe12da101471258e3 # v0.0.8 + name: Setup helm + with: + name: helm + url: https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz + pathInArchive: linux-amd64/helm + - run: helm version + + # https://github.com/marketplace/actions/engineerd-configurator + - uses: engineerd/configurator@479197cb150e720c848c8dfbe12da101471258e3 # v0.0.8 + name: Setup helm-docs + with: + name: helm-docs + url: https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_Linux_x86_64.tar.gz + pathInArchive: helm-docs + - run: helm-docs --version + + - name: Helm Lint + run: helm lint ./charts/* --strict + + - uses: pre-commit/action@9b88afc9cd57fd75b655d5c71bd38146d07135fe # v2.0.3 + name: Run pre-commit + +# ToDo: Implement Checkov for Helm charts in order to follow unified good practices. + # checkov: + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 + # name: Checkout + + # - uses: bridgecrewio/checkov-action@00cc657f4d415593e5c8897bc87f490497ccb5f9 # v12.641.0 + # name: Run Checkov action diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..97f881db --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: https://github.com/norwoodj/helm-docs + rev: v1.5.0 + hooks: + - id: helm-docs + args: + # Make the tool search for charts under the `charts` directory + - --chart-search-root=charts + +# - repo: https://github.com/bridgecrewio/checkov.git +# rev: 'd9269af517a85a62d8010e17fa09b34e1a3b17ed' # 2.0.1054 ff217a56ee70b9b0c6d82174a9a816d52663187a = +# hooks: +# - id: checkov +# files: ^charts/ +# args: +# - -d +# - charts/ +# - --framework +# - helm +# - --quiet +# - --compact +# # - --soft-fail \ No newline at end of file diff --git a/README.md b/README.md index 14ba2fc5..026292e7 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ # Helm charts + +## Development + +1. We use [GitHub Flow](https://docs.github.com/en/get-started/quickstart/github-flow). + 1. Create a branch derived from branch `master`. + 2. Make your changes and test them. + 3. Create a Pull Request. + 4. Verify that all checks pass. If not, fix the issues on your branch and push them again. + 5. Wait for your Pull Request to be reviewed. + 6. After successful Review, your Pull Request will be merged. +2. Several checks run on a Pull Request. They all need to pass, otherwise your changes will not be accepted. +3. In case you are doing changes on a helm chart + 1. bump the version in `Chart.yaml`, + 2. Run `pre-commit run -a` to update the documentation. +4. After your Pull Request has been accepted and has been merged to `master` branch, an automated process will create a new Release of the modified helm charts. diff --git a/charts/blockchain-explorer/.helmignore b/_old_charts/blockchain-explorer/.helmignore similarity index 100% rename from charts/blockchain-explorer/.helmignore rename to _old_charts/blockchain-explorer/.helmignore diff --git a/charts/blockchain-explorer/Chart.yaml b/_old_charts/blockchain-explorer/Chart.yaml similarity index 100% rename from charts/blockchain-explorer/Chart.yaml rename to _old_charts/blockchain-explorer/Chart.yaml diff --git a/charts/blockchain-explorer/templates/NOTES.txt b/_old_charts/blockchain-explorer/templates/NOTES.txt similarity index 100% rename from charts/blockchain-explorer/templates/NOTES.txt rename to _old_charts/blockchain-explorer/templates/NOTES.txt diff --git a/charts/blockchain-explorer/templates/api-deployment.yaml b/_old_charts/blockchain-explorer/templates/api-deployment.yaml similarity index 100% rename from charts/blockchain-explorer/templates/api-deployment.yaml rename to _old_charts/blockchain-explorer/templates/api-deployment.yaml diff --git a/charts/blockchain-explorer/templates/api-service.yaml b/_old_charts/blockchain-explorer/templates/api-service.yaml similarity index 100% rename from charts/blockchain-explorer/templates/api-service.yaml rename to _old_charts/blockchain-explorer/templates/api-service.yaml diff --git a/charts/blockchain-explorer/templates/explorer-configmap.yaml b/_old_charts/blockchain-explorer/templates/explorer-configmap.yaml similarity index 100% rename from charts/blockchain-explorer/templates/explorer-configmap.yaml rename to _old_charts/blockchain-explorer/templates/explorer-configmap.yaml diff --git a/charts/blockchain-explorer/templates/ingestion-deployment.yaml b/_old_charts/blockchain-explorer/templates/ingestion-deployment.yaml similarity index 100% rename from charts/blockchain-explorer/templates/ingestion-deployment.yaml rename to _old_charts/blockchain-explorer/templates/ingestion-deployment.yaml diff --git a/charts/blockchain-explorer/templates/mongodb-deployment.yaml b/_old_charts/blockchain-explorer/templates/mongodb-deployment.yaml similarity index 100% rename from charts/blockchain-explorer/templates/mongodb-deployment.yaml rename to _old_charts/blockchain-explorer/templates/mongodb-deployment.yaml diff --git a/charts/blockchain-explorer/templates/mongodb-service.yaml b/_old_charts/blockchain-explorer/templates/mongodb-service.yaml similarity index 100% rename from charts/blockchain-explorer/templates/mongodb-service.yaml rename to _old_charts/blockchain-explorer/templates/mongodb-service.yaml diff --git a/charts/blockchain-explorer/templates/nginx-deployment.yaml b/_old_charts/blockchain-explorer/templates/nginx-deployment.yaml similarity index 100% rename from charts/blockchain-explorer/templates/nginx-deployment.yaml rename to _old_charts/blockchain-explorer/templates/nginx-deployment.yaml diff --git a/charts/blockchain-explorer/templates/nginx-service.yaml b/_old_charts/blockchain-explorer/templates/nginx-service.yaml similarity index 100% rename from charts/blockchain-explorer/templates/nginx-service.yaml rename to _old_charts/blockchain-explorer/templates/nginx-service.yaml diff --git a/charts/blockchain-explorer/templates/quorum-examples-net-networkpolicy.yaml b/_old_charts/blockchain-explorer/templates/quorum-examples-net-networkpolicy.yaml similarity index 100% rename from charts/blockchain-explorer/templates/quorum-examples-net-networkpolicy.yaml rename to _old_charts/blockchain-explorer/templates/quorum-examples-net-networkpolicy.yaml diff --git a/charts/blockchain-explorer/templates/web-deployment.yaml b/_old_charts/blockchain-explorer/templates/web-deployment.yaml similarity index 100% rename from charts/blockchain-explorer/templates/web-deployment.yaml rename to _old_charts/blockchain-explorer/templates/web-deployment.yaml diff --git a/charts/blockchain-explorer/templates/web-service.yaml b/_old_charts/blockchain-explorer/templates/web-service.yaml similarity index 100% rename from charts/blockchain-explorer/templates/web-service.yaml rename to _old_charts/blockchain-explorer/templates/web-service.yaml diff --git a/charts/blockchain-explorer/values.yaml b/_old_charts/blockchain-explorer/values.yaml similarity index 100% rename from charts/blockchain-explorer/values.yaml rename to _old_charts/blockchain-explorer/values.yaml diff --git a/charts/ethereum-adapter/.helmignore b/_old_charts/ethereum-adapter/.helmignore similarity index 100% rename from charts/ethereum-adapter/.helmignore rename to _old_charts/ethereum-adapter/.helmignore diff --git a/charts/ethereum-adapter/Chart.yaml b/_old_charts/ethereum-adapter/Chart.yaml similarity index 100% rename from charts/ethereum-adapter/Chart.yaml rename to _old_charts/ethereum-adapter/Chart.yaml diff --git a/charts/ethereum-adapter/templates/demo-configmap.yaml b/_old_charts/ethereum-adapter/templates/demo-configmap.yaml similarity index 89% rename from charts/ethereum-adapter/templates/demo-configmap.yaml rename to _old_charts/ethereum-adapter/templates/demo-configmap.yaml index a7c2fdd4..7a42ad37 100644 --- a/charts/ethereum-adapter/templates/demo-configmap.yaml +++ b/_old_charts/ethereum-adapter/templates/demo-configmap.yaml @@ -3,7 +3,7 @@ kind: ConfigMap metadata: name: genesis-config-demo labels: - name: genesis-config-demo + name: "genesis-config-demo" data: load-genesis.json: |- {{- $genesis := .Files.Get "common.json" | fromJson }} diff --git a/charts/ethereum-adapter/values.yaml b/_old_charts/ethereum-adapter/values.yaml similarity index 100% rename from charts/ethereum-adapter/values.yaml rename to _old_charts/ethereum-adapter/values.yaml diff --git a/charts/quorum-node/.helmignore b/_old_charts/quorum-node/.helmignore similarity index 100% rename from charts/quorum-node/.helmignore rename to _old_charts/quorum-node/.helmignore diff --git a/charts/quorum-node/Chart.yaml b/_old_charts/quorum-node/Chart.yaml similarity index 100% rename from charts/quorum-node/Chart.yaml rename to _old_charts/quorum-node/Chart.yaml diff --git a/charts/quorum-node/readme.md b/_old_charts/quorum-node/readme.md similarity index 100% rename from charts/quorum-node/readme.md rename to _old_charts/quorum-node/readme.md diff --git a/charts/quorum-node/templates/_helpers.tpl b/_old_charts/quorum-node/templates/_helpers.tpl similarity index 100% rename from charts/quorum-node/templates/_helpers.tpl rename to _old_charts/quorum-node/templates/_helpers.tpl diff --git a/charts/quorum-node/templates/post-install-upgrade.git-upload.yaml b/_old_charts/quorum-node/templates/post-install-upgrade.git-upload.yaml similarity index 100% rename from charts/quorum-node/templates/post-install-upgrade.git-upload.yaml rename to _old_charts/quorum-node/templates/post-install-upgrade.git-upload.yaml diff --git a/charts/quorum-node/templates/post-upgrade.propose-validators.yaml b/_old_charts/quorum-node/templates/post-upgrade.propose-validators.yaml similarity index 100% rename from charts/quorum-node/templates/post-upgrade.propose-validators.yaml rename to _old_charts/quorum-node/templates/post-upgrade.propose-validators.yaml diff --git a/charts/quorum-node/templates/quorum-genesis.yaml b/_old_charts/quorum-node/templates/quorum-genesis.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-genesis.yaml rename to _old_charts/quorum-node/templates/quorum-genesis.yaml diff --git a/charts/quorum-node/templates/quorum-keyconfig-account.yaml b/_old_charts/quorum-node/templates/quorum-keyconfig-account.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-keyconfig-account.yaml rename to _old_charts/quorum-node/templates/quorum-keyconfig-account.yaml diff --git a/charts/quorum-node/templates/quorum-keyconfigs.yaml b/_old_charts/quorum-node/templates/quorum-keyconfigs.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-keyconfigs.yaml rename to _old_charts/quorum-node/templates/quorum-keyconfigs.yaml diff --git a/charts/quorum-node/templates/quorum-node-deployment.yaml b/_old_charts/quorum-node/templates/quorum-node-deployment.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-node-deployment.yaml rename to _old_charts/quorum-node/templates/quorum-node-deployment.yaml diff --git a/charts/quorum-node/templates/quorum-persistent-volumes.yaml b/_old_charts/quorum-node/templates/quorum-persistent-volumes.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-persistent-volumes.yaml rename to _old_charts/quorum-node/templates/quorum-persistent-volumes.yaml diff --git a/charts/quorum-node/templates/quorum-services.yaml b/_old_charts/quorum-node/templates/quorum-services.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-services.yaml rename to _old_charts/quorum-node/templates/quorum-services.yaml diff --git a/charts/quorum-node/templates/quorum-shared-config.yaml b/_old_charts/quorum-node/templates/quorum-shared-config.yaml similarity index 100% rename from charts/quorum-node/templates/quorum-shared-config.yaml rename to _old_charts/quorum-node/templates/quorum-shared-config.yaml diff --git a/charts/quorum-node/templates/storage-class.yaml b/_old_charts/quorum-node/templates/storage-class.yaml similarity index 100% rename from charts/quorum-node/templates/storage-class.yaml rename to _old_charts/quorum-node/templates/storage-class.yaml diff --git a/charts/quorum-node/values.yaml b/_old_charts/quorum-node/values.yaml similarity index 100% rename from charts/quorum-node/values.yaml rename to _old_charts/quorum-node/values.yaml diff --git a/charts/releases/ethereum-adapter-0.1.0.tgz b/_old_charts/releases/ethereum-adapter-0.1.0.tgz similarity index 100% rename from charts/releases/ethereum-adapter-0.1.0.tgz rename to _old_charts/releases/ethereum-adapter-0.1.0.tgz diff --git a/charts/releases/index.yaml b/_old_charts/releases/index.yaml similarity index 100% rename from charts/releases/index.yaml rename to _old_charts/releases/index.yaml diff --git a/charts/releases/quorum-0.1.0.tgz b/_old_charts/releases/quorum-0.1.0.tgz similarity index 100% rename from charts/releases/quorum-0.1.0.tgz rename to _old_charts/releases/quorum-0.1.0.tgz diff --git a/charts/dummy/.helmignore b/charts/dummy/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/dummy/.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/charts/dummy/Chart.yaml b/charts/dummy/Chart.yaml new file mode 100644 index 00000000..fb3fd2a5 --- /dev/null +++ b/charts/dummy/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: dummy +description: A Helm chart for Kubernetes + +# 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: "1.16.0" diff --git a/charts/dummy/templates/NOTES.txt b/charts/dummy/templates/NOTES.txt new file mode 100644 index 00000000..8d8e7320 --- /dev/null +++ b/charts/dummy/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dummy.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dummy.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dummy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dummy.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/dummy/templates/_helpers.tpl b/charts/dummy/templates/_helpers.tpl new file mode 100644 index 00000000..54ad86ae --- /dev/null +++ b/charts/dummy/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dummy.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 "dummy.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 "dummy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dummy.labels" -}} +helm.sh/chart: {{ include "dummy.chart" . }} +{{ include "dummy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dummy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dummy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dummy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dummy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/dummy/templates/deployment.yaml b/charts/dummy/templates/deployment.yaml new file mode 100644 index 00000000..8efa39e5 --- /dev/null +++ b/charts/dummy/templates/deployment.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dummy.fullname" . }} + labels: + {{- include "dummy.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "dummy.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "dummy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dummy.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/dummy/templates/hpa.yaml b/charts/dummy/templates/hpa.yaml new file mode 100644 index 00000000..5e9ec6b7 --- /dev/null +++ b/charts/dummy/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "dummy.fullname" . }} + labels: + {{- include "dummy.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "dummy.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/dummy/templates/ingress.yaml b/charts/dummy/templates/ingress.yaml new file mode 100644 index 00000000..7626308c --- /dev/null +++ b/charts/dummy/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "dummy.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "dummy.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/dummy/templates/service.yaml b/charts/dummy/templates/service.yaml new file mode 100644 index 00000000..6db40832 --- /dev/null +++ b/charts/dummy/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dummy.fullname" . }} + labels: + {{- include "dummy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "dummy.selectorLabels" . | nindent 4 }} diff --git a/charts/dummy/templates/serviceaccount.yaml b/charts/dummy/templates/serviceaccount.yaml new file mode 100644 index 00000000..7a8568b5 --- /dev/null +++ b/charts/dummy/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dummy.serviceAccountName" . }} + labels: + {{- include "dummy.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/dummy/templates/tests/test-connection.yaml b/charts/dummy/templates/tests/test-connection.yaml new file mode 100644 index 00000000..1b9ad359 --- /dev/null +++ b/charts/dummy/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "dummy.fullname" . }}-test-connection" + labels: + {{- include "dummy.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "dummy.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/dummy/values.yaml b/charts/dummy/values.yaml new file mode 100644 index 00000000..50bec47b --- /dev/null +++ b/charts/dummy/values.yaml @@ -0,0 +1,82 @@ +# Default values for dummy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/read.me b/charts/read.me deleted file mode 100644 index e72ba540..00000000 --- a/charts/read.me +++ /dev/null @@ -1 +0,0 @@ -All operations over clusters will be automated with these Helm Charts diff --git a/ct.yaml b/ct.yaml new file mode 100644 index 00000000..a5e5c2b9 --- /dev/null +++ b/ct.yaml @@ -0,0 +1,9 @@ +# See https://github.com/helm/chart-testing#configuration +remote: origin +target-branch: master +chart-dirs: + - charts +chart-repos: + - ph-ethadapter=https://pharmaledger-imi.github.io/helmchart-ethadapter +helm-extra-args: --timeout 600s +validate-maintainers: false diff --git a/scripts/check-codeowners.sh b/scripts/check-codeowners.sh new file mode 100755 index 00000000..2840d85e --- /dev/null +++ b/scripts/check-codeowners.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +cat <