From 6cdb13d005142d77bec039d04a15dabc9b4d0c99 Mon Sep 17 00:00:00 2001 From: Evan Johnson Date: Wed, 14 Feb 2024 12:01:27 -0500 Subject: [PATCH] add helm test and publish workflow --- .github/workflows/helm.yml | 86 ++++++++++++++++++++++++++++++++++++++ README.md | 20 +++++---- deploy/chart/Chart.yaml | 4 +- deploy/chart/values.yaml | 4 +- 4 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/helm.yml diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml new file mode 100644 index 00000000..925e8d3c --- /dev/null +++ b/.github/workflows/helm.yml @@ -0,0 +1,86 @@ +name: Helm + +on: + push: + branches: + - main + paths: + - 'deploy/chart/**' + pull_request: + paths: + - 'deploy/chart/**' + workflow_dispatch: {} + +permissions: + contents: read + +jobs: + helm-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set Version + run: | + TAG=$(git describe --tags --abbrev=0) + sed -ie "s/appVersion: \"latest\"/appVersion: ${TAG}/g" deploy/chart/Chart.yaml + sed -ie "s/version: 0.0.0/version: ${TAG}/g" deploy/chart/Chart.yaml + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Run chart-testing (lint) + run: ct lint --check-version-increment=false --chart-dirs deploy --target-branch ${{ github.event.repository.default_branch }} + + # we cannot test a helm install without a valid linode + # - name: Create kind cluster + # uses: helm/kind-action@v1.8.0 + + #- name: Run chart-testing (install) + # run: ct install --chart-dirs helm-chart --namespace kube-system --helm-extra-set-args "--set=apiToken=test --set=region=us-east" --target-branch ${{ github.event.repository.default_branch }} + + helm-release: + if: github.ref == 'refs/heads/main' + needs: helm-test + permissions: + contents: write # for helm/chart-releaser-action to push chart release and create a release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set Version + run: | + TAG=$(git describe --tags --abbrev=0) + sed -ie "s/appVersion: \"latest\"/appVersion: ${TAG}/g" deploy/chart/Chart.yaml + sed -ie "s/version: 0.0.0/version: ${TAG}/g" deploy/chart/Chart.yaml + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Set up Helm + uses: azure/setup-helm@v3 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + CR_RELEASE_NAME_TEMPLATE: "{{ .Version }}" + with: + charts_dir: deploy + skip_existing: true diff --git a/README.md b/README.md index 48d65d98..2236b2bf 100644 --- a/README.md +++ b/README.md @@ -255,24 +255,28 @@ This will create a file `ccm-linode.yaml` which you can use to deploy the CCM. Note: Your kubelets, controller-manager, and apiserver must be started with `--cloud-provider=external` as noted in the following documentation. ## Deployment Through Helm Chart -Use the helm chart located under './deploy/chart'. This dir has the manifest for Linode CCM. There are two arguments required. +LINODE_API_TOKEN must be a Linode APIv4 [Personal Access Token](https://cloud.linode.com/profile/tokens) with all permissions. -The first argument must be a Linode APIv4 [Personal Access Token](https://cloud.linode.com/profile/tokens) with all permissions. +REGION must be a Linode [region](https://api.linode.com/v4/regions). +### Install the ccm-linode repo +```shell +helm repo add ccm-linode https://linode.github.io/linode-cloud-controller-manager/ +helm repo update ccm-linode +``` -The second argument must be a Linode [region](https://api.linode.com/v4/regions). +### To deploy ccm-linode. Run the following command: -### To deploy CCM run the following helm command once you are in the ccm root dir: ```sh export VERSION=v0.3.22 export LINODE_API_TOKEN= export REGION= -helm install linode-ccm --set apiToken=$LINODE_API_TOKEN,region=$REGION https://github.com/linode/linode-cloud-controller-manager/releases/download/$VERSION/helm-chart-$VERSION.tgz +helm install ccm-linode --set apiToken=$LINODE_API_TOKEN,region=$REGION ccm-linode/ccm-linode ``` _See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ -### To uninstall linode-ccm from kubernetes cluster. Run the following command: +### To uninstall ccm-linode from kubernetes cluster. Run the following command: ```sh -helm uninstall linode-ccm +helm uninstall ccm-linode ``` _See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ @@ -282,7 +286,7 @@ export VERSION=v0.3.22 export LINODE_API_TOKEN= export REGION= -helm upgrade linode-ccm --install --set apiToken=$LINODE_API_TOKEN,region=$REGION https://github.com/linode/linode-cloud-controller-manager/releases/download/$VERSION/helm-chart-$VERSION.tgz +helm upgrade ccm-linode --install --set apiToken=$LINODE_API_TOKEN,region=$REGION ccm-linode/ccm-linode ``` _See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ diff --git a/deploy/chart/Chart.yaml b/deploy/chart/Chart.yaml index c442b685..959afc24 100644 --- a/deploy/chart/Chart.yaml +++ b/deploy/chart/Chart.yaml @@ -2,5 +2,7 @@ apiVersion: v2 name: ccm-linode description: The Linode Cloud Controller Manager (CCM) provides a way for Kubernetes clusters to access additional Linode services. Linode's CCM will automatically provision a Linode NodeBalancer for Kubernetes Services of type "LoadBalancer". type: application -version: 1.0.0 +version: 0.0.0 appVersion: "latest" +maintainers: + - name: linode diff --git a/deploy/chart/values.yaml b/deploy/chart/values.yaml index 790458df..2c00b6d6 100644 --- a/deploy/chart/values.yaml +++ b/deploy/chart/values.yaml @@ -19,7 +19,7 @@ nodeSelector: # The pullPolicy is set to Always but can be changed when it is not required to always pull the new image image: repository: linode/linode-cloud-controller-manager - tag: latest + tag: # only set if required, defaults to .Chart.AppVersion set during release or "latest" by default pullPolicy: Always # Default namespace is "kube-system" but it can be set to another namespace @@ -48,4 +48,4 @@ tolerations: # LINODE_HOSTNAME_ONLY_INGRESS type bool is supported # env: # - name: EXAMPLE_ENV_VAR - # value: "true" \ No newline at end of file + # value: "true"