From 63f5459d9dac8f701b84c52ded31e2d88ad96018 Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Mon, 7 Sep 2020 19:54:10 +0300 Subject: [PATCH] feat: public helm repository via github pages --- .editorconfig | 2 + .github/workflows/release.yaml | 74 ++++++++++++++++++++++++---------- .gitignore | 2 + .helmignore | 1 + .release-it.json | 26 +++++------- Chart.yaml | 2 +- Dockerfile | 4 +- README.adoc | 71 +++++++++++++++++++++++--------- requirements.txt | 2 - 9 files changed, 121 insertions(+), 63 deletions(-) delete mode 100644 requirements.txt diff --git a/.editorconfig b/.editorconfig index bc9737a..8eaf3f6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,5 @@ indent_size=2 [*.py] indent_size = 4 +[README.adoc] +max_line_length = 100 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 922fabf..29d34ba 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,38 +1,70 @@ -name: Release Helm chart and Docker image +name: Release CMAK operator + on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch + jobs: build_docker_job: - name: Helm chart and Docker image + name: Docker image runs-on: ubuntu-18.04 steps: - name: checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: nodejs 12 + uses: actions/setup-node@v1 + with: + node-version: '12.x' + - run: npm install release-it@14.0.2 @release-it/conventional-changelog@2.0.0 + - name: releaseIt + run: | + git config user.email "eshepelyuk@github" + git config user.name "Ievgenii Shepeliuk" + npx release-it --ci + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: cmak version + id: cmakVersion + run: | + cat /tmp/cmak.version + echo "::set-env name=CMAK_VERSION::$(cat /tmp/cmak.version)" + - uses: azure/setup-helm@v1 + - run: helm package . --version $CMAK_VERSION + - name: upload artifact + uses: actions/upload-artifact@v2 + with: + name: "helm" + path: "cmak-operator-${{ env.CMAK_VERSION }}.tgz" - name: docker login uses: docker/login-action@v1 with: username: eshepelyuk password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: detect version - run: echo "::set-env name=CMAK_VERSION::${GITHUB_REF:10}" - - uses: azure/setup-helm@v1 - - name: package helm chart - run: helm package . - name: publish docker image uses: hiberbee/github-action-skaffold@latest with: command: build tag: ${{ env.CMAK_VERSION }} - - name: attach helm chart to release - uses: ncipollo/release-action@v1 - with: - artifacts: "cmak-operator-${{ env.CMAK_VERSION }}.tgz" - allowUpdates: true - omitBody: true - omitBodyDuringUpdate: true - omitName: true - omitNameDuringUpdate: true - replacesArtifacts: true - token: ${{ secrets.GITHUB_TOKEN }} + + publish_chart_job: + needs: build_docker_job + name: Helm chart + runs-on: ubuntu-18.04 + steps: + - name: checkout gh-pages + uses: actions/checkout@v2 + with: + ref: gh-pages + - name: download artifact + uses: actions/download-artifact@v2 + id: download + with: + name: helm + - uses: azure/setup-helm@v1 + - run: helm repo index . + - name: publish + uses: actions-js/push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages diff --git a/.gitignore b/.gitignore index 646ec78..65164e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ CHANGELOG.md *.tgz node_modules package-lock.json +package.json +.idea diff --git a/.helmignore b/.helmignore index 831fdbf..1e646bb 100644 --- a/.helmignore +++ b/.helmignore @@ -31,3 +31,4 @@ venv *.json skaffold.yaml +node_modules diff --git a/.release-it.json b/.release-it.json index 86614a7..494a068 100644 --- a/.release-it.json +++ b/.release-it.json @@ -1,29 +1,21 @@ { + "ci": true, "git": { - "commitMessage": "chore: release ${version}", - "tagAnnotation": "chore: release ${version}", - "requireCleanWorkingDir": true, - "requireCommits": true, "requireBranch": "master", - "commit": true, - "push": true, - "tag": true + "commit": false, + "tagAnnotation": "chore: release ${version}" }, - - "npm": { - "publish": false - }, - + "npm": false, "github": { - "release": true + "release": true, + "assets": ["cmak-operator*.tgz"] }, - "plugins": { "@release-it/conventional-changelog": { "preset": "conventionalcommits" - }, - "@release-it/bumper": { - "out": "Chart.yaml" } + }, + "hooks": { + "after:release": "echo ${version} > /tmp/cmak.version" } } diff --git a/Chart.yaml b/Chart.yaml index 40ca462..0112060 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -2,6 +2,6 @@ apiVersion: v2 name: cmak-operator description: CMAK operator for K8S. type: application -version: 0.2.1 +version: 0.0.0 appVersion: 3.0.0.5 diff --git a/Dockerfile b/Dockerfile index 3283c78..6d84c0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,6 @@ FROM python:3.8-alpine3.11 COPY *.py *.txt /opt/ -RUN pip install -r /opt/requirements.txt +RUN pip install click~=7.0 kazoo~=2.8 -WORKDIR /opt +WORKDIR /opt diff --git a/README.adoc b/README.adoc index 2a53331..ba9ab36 100644 --- a/README.adoc +++ b/README.adoc @@ -1,5 +1,4 @@ = CMAK operator -:cmak-v: 0.2.1 :toc: macro :icons: font @@ -11,60 +10,93 @@ ifdef::env-github[] :warning-caption: :warning: endif::[] -image:https://img.shields.io/github/v/tag/eshepelyuk/cmak-operator?sort=semver&style=for-the-badge[GitHub tag (latest SemVer)] image:https://img.shields.io/github/license/eshepelyuk/cmak-operator?logo=github&style=for-the-badge[GitHub, link="https://opensource.org/licenses/MIT", window="_blank"] +image:https://img.shields.io/github/v/tag/eshepelyuk/cmak-operator?sort=semver&style=for-the-badge&label=current[Release, +link="https://github.com/eshepelyuk/cmak-operator/releases/latest"] +image:https://img.shields.io/docker/pulls/eshepelyuk/cmak-operator-cli?style=for-the-badge[Docker Hub, +link="https://hub.docker.com/repository/docker/eshepelyuk/cmak-operator-cli"] +image:https://img.shields.io/github/license/eshepelyuk/cmak-operator?logo=github&style=for-the-badge[MIT licence, +link="https://opensource.org/licenses/MIT", window="_blank"] toc::[] -CMAK operator is a Helm chart and set of tools that allows to install +CMAK operator is a set of tools package as Helm chart, that allows to install and configure https://github.com/yahoo/CMAK[CMAK (ex Kafka Manager)] into Kubernetes cluster. https://github.com/yahoo/CMAK[CMAK (ex. Kafka Manager)] is well-known and mature tool for monitoring and managing https://kafka.apache.org/[Apache Kafka] clusters. -It's extremely easy to configure multiple clusters in CMAK, -as well as connection settings and enable optional authorization -using https://helm.sh/docs/chart_template_guide/values_files/[Helm values files] == Prerequisites -CMAK operator creates https://kubernetes.io/docs/concepts/workloads/controllers/job/[Kubernetes Jobs] for configuring CMAK. +CMAK operator creates +https://kubernetes.io/docs/concepts/workloads/controllers/job/[Kubernetes Jobs] +for configuring CMAK. Kubernetes Jobs are not automatically garbage collected. -To enable cleanup it is required to enable `TTLAfterFinished` https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/[feature gate]. +To enable cleanup it is required to enable `TTLAfterFinished` +https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/[feature gate]. + +== Installation -== Installation with Helm +CMAK operator could be installed only using Helm 3. +Helm chart is published to public Helm repository, hosted by GitHub. It's recommended to install CMAK operator into a dedicated namespace. [source] -[subs="attributes"] +.Add Helm repository ---- -$ helm install --create-namespace --namespace cmak-ns cmak \ - https://github.com/eshepelyuk/cmak-operator/releases/download/{cmak-v}/cmak-operator-{cmak-v}.tgz +$ helm repo add cmak https://eshepelyuk.github.io/cmak-operator +$ helm repo update ---- +[source] +.Install latest version +---- +$ helm install --create-namespace -n cmak-ns mycmak cmak/cmak-operator +---- + +[source] +.Seach for available versions +---- +$ helm search repo cmak-operator --versions +NAME CHART VERSION APP VERSION DESCRIPTION +cmak/cmak-operator 0.2.1 3.0.0.5 CMAK operator for K8S. +cmak/cmak-operator 0.2.0 3.0.0.5 CMAK operator for K8S. +---- + +[source] +.Install specific version +---- +$ helm install --create-namespace -n cmak-ns --version 0.2.1 mycmak cmak/cmak-operator +---- === Check installation [IMPORTANT] .Exposing CMAK UI ==== -Currently, CMAK operator doesn't create any `Ingress` or similar resources to expose UI via HTTP. -A users of CMAK operator should take care of this by themselves. +Currently, CMAK operator doesn't create neither `Ingress` +nor any other K8S resources to expose UI via HTTP. +Users of CMAK operator should take care of this by themselves. ==== -The simpliest test is to port forward CMAK UI HTTP port and access it from browser via localhost. +The simpliest test is to port forward CMAK UI HTTP port and access it from browser . [source] ---- $ kubectl port-forward -n cmak-ns service/cmak 9000:9000 ---- -Then, navigate to http://localhost:9000. - +Then, open http://localhost:9000 in your browser. == Configuration -Check `values.yaml` for all available options. +It's extremely easy to configure multiple clusters in CMAK, +starting from cluster setup, connection settings and ending with authorization +using https://helm.sh/docs/chart_template_guide/values_files/[Helm values files]. + +Check https://helm.sh/docs/chart_template_guide/values_files/[Helm values files] +for all available options and their description. . Minimal values.yaml configuration for adding a several Kafka clusters to CMAK. [source,yaml] @@ -107,8 +139,7 @@ Configuration should be passed to helm via command line during installation or u [source] [subs="attributes"] ---- -$ helm install --create-namespace --namespace cmak-ns -f cmak-values.yaml cmak \ - https://github.com/eshepelyuk/cmak-operator/releases/download/{cmak-v}/cmak-operator-{cmak-v}.tgz +$ helm install --create-namespace -n cmak-ns -f cmak-values.yaml mycmak cmak/cmak-operator ---- == Troubleshooting diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f8fcd52..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -click~=7.0 -kazoo~=2.8