Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
feat: Update to Keptn 0.14 (#74)
Browse files Browse the repository at this point in the history
* Use Helm chart and update to Keptn 0.14

Signed-off-by: TannerGabriel <[email protected]>

* Update Github actions

Signed-off-by: TannerGabriel <[email protected]>

* Add build helm chart script

Signed-off-by: TannerGabriel <[email protected]>

* Remove deploy folder and add environment variable

Signed-off-by: TannerGabriel <[email protected]>

* Move unleash secret to unleash-service

Signed-off-by: TannerGabriel <[email protected]>
  • Loading branch information
TannerGabriel authored May 20, 2022
1 parent 3485657 commit 72ef399
Show file tree
Hide file tree
Showing 22 changed files with 882 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Unit Tests'
description: 'Run unit tests using go'
inputs:
GO_VERSION:
default: "1.16"
default: "1.17"
env:
GO111MODULE: "on"
GOPROXY: "https://proxy.golang.org"
Expand Down
38 changes: 34 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:
jobs:
prepare_ci_run:
name: Prepare CI Run
uses: keptn/gh-automation/.github/workflows/prepare-ci.yml@v1.4.0
uses: keptn/gh-automation/.github/workflows/prepare-ci.yml@v1.5.3

############################################################################
# Unit tests #
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Unit tests
uses: ./.github/actions/unit-tests

Expand All @@ -42,7 +42,7 @@ jobs:
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
steps:
- name: Checkout Code
uses: actions/checkout@v2.4.0
uses: actions/checkout@v3.0.2

- name: Load CI Environment from .ci_env
id: load_ci_env
Expand All @@ -52,7 +52,7 @@ jobs:

- name: Docker Build
id: docker_build
uses: keptn/gh-automation/.github/actions/docker-build@v1.4.0
uses: keptn/gh-automation/.github/actions/docker-build@v1.5.3
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
Expand All @@ -74,3 +74,33 @@ jobs:
message: |
The following Docker Images have been built:
${{ fromJSON(steps.docker_build.outputs.BUILD_METADATA)['image.name'] }}


helm_chart_build:
needs: [prepare_ci_run, docker_build]
name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }}
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}.${DATETIME}" "${IMAGE}"

- name: Upload Helm Chart as an artifact
id: upload_helm_chart
uses: actions/upload-artifact@v3
with:
name: helm-charts
path: installer/*.tgz
75 changes: 75 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Create Pre-Release
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Unit tests
uses: ./.github/actions/unit-tests

pre-release:
needs: test
name: Pre-Release
uses: keptn/gh-automation/.github/workflows/[email protected]

docker_build:
needs: [pre-release]
name: Docker Build
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Sanitize repo owner
uses: actions/github-script@v4
id: repo_slug
with:
result-encoding: string
script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
TAGS: |
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

helm_chart_build:
needs: [pre-release, docker_build]
name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}"

- name: Upload Helm Chart as release asset
env:
RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$RELEASE_TAG" installer/*.tgz
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Create Release
on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Unit tests
uses: ./.github/actions/unit-tests

release:
needs: test
name: Release
uses: keptn/gh-automation/.github/workflows/[email protected]

docker_build:
needs: [release]
name: Docker Build
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Sanitize repo owner
uses: actions/github-script@v4
id: repo_slug
with:
result-encoding: string
script: return '${{ github.repository_owner }}'.toLowerCase()

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected]
with:
TAGS: |
ghcr.io/${{ steps.repo_slug.outputs.result }}/${{ env.IMAGE }}:${{ env.VERSION }}
BUILD_ARGS: |
version=${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

helm_chart_build:
needs: [release, docker_build]

name: Build Helm Charts
runs-on: ubuntu-20.04
env:
VERSION: ${{ needs.release.outputs.RELEASE_TAG }}
steps:
- name: Checkout Code
uses: actions/[email protected]

- name: Load CI Environment from .ci_env
id: load_ci_env
uses: c-py/action-dotenv-to-setenv@v3
with:
env-file: .ci_env

- name: Build Helm Charts
id: build_helm_charts
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}"

- name: Upload Helm Chart as release asset
env:
RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "$RELEASE_TAG" installer/*.tgz
2 changes: 1 addition & 1 deletion .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
id: go
- name: Check out code.
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16.2-alpine as builder
FROM golang:1.17.5-alpine as builder
RUN apk add --no-cache gcc libc-dev git

ARG version=develop
Expand Down
56 changes: 44 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,63 @@ Example payload for an action.triggered event:
Please always double check the version of Keptn you are using compared to the version of this service, and follow the compatibility matrix below.


| Keptn Version\* | [Unleash Service Image](https://hub.docker.com/r/keptncontrib/unleash-service/tags) |
|:----------------:|:----------------------------------------:|
| 0.6.x | keptncontrib/unleash-service:0.1.0 |
| 0.7.x | keptncontrib/unleash-service:0.2.0 |
| 0.8.x | keptncontrib/unleash-service:0.3.0 |
| 0.8.0-0.8.3 | keptncontrib/unleash-service:0.3.1 |
| 0.8.4 | keptncontrib/unleash-service:0.3.2 |
| Keptn Version\* | [Unleash Service Image](https://hub.docker.com/r/keptncontrib/unleash-service/tags) |
|:---------------:|:-----------------------------------------------------------------------------------:|
| 0.6.x | keptncontrib/unleash-service:0.1.0 |
| 0.7.x | keptncontrib/unleash-service:0.2.0 |
| 0.8.x | keptncontrib/unleash-service:0.3.0 |
| 0.8.0-0.8.3 | keptncontrib/unleash-service:0.3.1 |
| 0.8.4 | keptncontrib/unleash-service:0.3.2 |
| 0.14.x | keptncontrib/unleash-service:0.4.0 |

\* This is the Keptn version we aim to be compatible with. Other versions should work too, but there is no guarantee.

**Note**: This integration is currently incompatible with Keptn 0.14.x and newer.

## Installation

To deploy the `unleash-service` in version 0.3.2, execute the following command:
The *unleash-service* can be installed as a part of [Keptn's uniform](https://keptn.sh).

### Deploy in your Kubernetes cluster

To deploy the current version of the *unleash-service* in your Keptn Kubernetes cluster use the [`helm chart`](chart/Chart.yaml) file, for example:

```console
helm install -n keptn unleash-service chart/
```
kubectl apply -f https://raw.githubusercontent.com/keptn-contrib/unleash-service/release-0.3.2/deploy/service.yaml -n keptn

This should install the `unleash-service` together with a Keptn `distributor` into the `keptn` namespace, which you can verify using

```console
kubectl -n keptn get deployment unleash-service -o wide
kubectl -n keptn get pods -l run=unleash-service
```

## Uninstall the unleash-service
### Up- or Downgrading

To uninstall the service, execute:
Adapt and use the following command in case you want to up- or downgrade your installed version (specified by the `$VERSION` placeholder):

```console
helm upgrade -n keptn --set image.tag=$VERSION unleash-service chart/
```
kubectl delete -f https://raw.githubusercontent.com/keptn-contrib/unleash-service/release-0.3.2/deploy/service.yaml -n keptn

### Uninstall

To delete a deployed *unleash-service*, use the file `deploy/*.yaml` files from this repository and delete the Kubernetes resources:

```console
helm uninstall -n keptn unleash-service
```

## Development

Development can be conducted using any GoLang compatible IDE/editor (e.g., Jetbrains GoLand, VSCode with Go plugins).

It is recommended to make use of branches as follows:

* `main`/`master` contains the latest potentially unstable version
* `release-*` contains a stable version of the service (e.g., `release-0.1.0` contains version 0.1.0)
* create a new branch for any changes that you are working on, e.g., `feature/my-cool-stuff` or `bug/overflow`
* once ready, create a pull request from that branch back to the `main`/`master` branch

When writing code, it is recommended to follow the coding style suggested by the [Golang community](https://github.com/golang/go/wiki/CodeReviewComments).
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: unleash-service
description: Helm Chart for the keptn unleash-service

# 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.8.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: "0.8.0"
Loading

0 comments on commit 72ef399

Please sign in to comment.