Skip to content

Commit

Permalink
Adding helm code
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Dec 14, 2022
1 parent f9fb78c commit 6290fd2
Show file tree
Hide file tree
Showing 441 changed files with 84,639 additions and 1 deletion.
153 changes: 153 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.7.0](https://github.com/deliverybot/helm/compare/v1.6.1...v1.7.0) (2021-01-09)


### Features

* Add flag for atomic variable ([#45](https://github.com/deliverybot/helm/issues/45)) ([c5da4d5](https://github.com/deliverybot/helm/commit/c5da4d5cd0cba39b959459af1da0b5e3ed9b887f))
* Add required parameter to all action inputs ([#33](https://github.com/deliverybot/helm/issues/33)) ([7035d19](https://github.com/deliverybot/helm/commit/7035d19603bf6ead15e61b8feba0f0feec9d9861))
* Upgrade helm ([#50](https://github.com/deliverybot/helm/issues/50)) ([0ce1ab7](https://github.com/deliverybot/helm/commit/0ce1ab79060b30006b1800919d61332ed279d75f))

### [1.6.1](https://github.com/deliverybot/helm/compare/v1.6.0...v1.6.1) (2020-06-06)


### Bug Fixes

* Remove colon in action.yml ([1f0d808](https://github.com/deliverybot/helm/commit/1f0d808b77f835b1547c80cdd5080a217465cefe))

## [1.6.0](https://github.com/deliverybot/helm/compare/v1.5.0...v1.6.0) (2020-06-06)


### Features

* Add additional parameters to download a chart by url ([#23](https://github.com/deliverybot/helm/issues/23)) ([547935f](https://github.com/deliverybot/helm/commit/547935f280af50b2cb7f7fcfd08c29f367433395))
* Add missing `helm` input parameter to action.yml ([#29](https://github.com/deliverybot/helm/issues/29)) ([8612a75](https://github.com/deliverybot/helm/commit/8612a75699d4ca8ea60072bb3350f4d26095ad27))
* Add support for EKS clusters and fix helm v3 home issue ([#27](https://github.com/deliverybot/helm/issues/27)) ([70b15cc](https://github.com/deliverybot/helm/commit/70b15cc0dc343686882dfb9185ff67cef9d47723)), closes [#22](https://github.com/deliverybot/helm/issues/22)

## [1.5.0](https://github.com/deliverybot/helm/compare/v1.4.0...v1.5.0) (2019-12-24)


### Features

* Add timeout parameter ([#18](https://github.com/deliverybot/helm/issues/18)) ([d494b05](https://github.com/deliverybot/helm/commit/d494b05))

## [1.4.0](https://github.com/deliverybot/helm/compare/v1.3.0...v1.4.0) (2019-11-21)


### Bug Fixes

* Pass kubeconfig var ([2b78a84](https://github.com/deliverybot/helm/commit/2b78a84))


### Features

* Update Helm 2 binary ([#15](https://github.com/deliverybot/helm/issues/15)) ([b5d5c58](https://github.com/deliverybot/helm/commit/b5d5c58))
* Update Helm 3 binary ([#14](https://github.com/deliverybot/helm/issues/14)) ([8dc3e86](https://github.com/deliverybot/helm/commit/8dc3e86))

## [1.3.0](https://github.com/deliverybot/helm/compare/v1.2.0...v1.3.0) (2019-10-16)


### Features

* Generated value file is last arg ([#13](https://github.com/deliverybot/helm/issues/13)) ([9e1a0cf](https://github.com/deliverybot/helm/commit/9e1a0cf))

## [1.2.0](https://github.com/deliverybot/helm/compare/v1.1.0...v1.2.0) (2019-09-30)


### Bug Fixes

* If remove mark inactive ([3edcc80](https://github.com/deliverybot/helm/commit/3edcc80))
* Include preview for inactive state ([4b47dd7](https://github.com/deliverybot/helm/commit/4b47dd7))


### Features

* Add delete --purge for helm2 ([de6b027](https://github.com/deliverybot/helm/commit/de6b027))

## [1.1.0](https://github.com/deliverybot/helm/compare/v1.0.0...v1.1.0) (2019-09-21)


### Bug Fixes

* CI pipeline using GitHub actions ([7eddfb9](https://github.com/deliverybot/helm/commit/7eddfb9))
* Helm3 compatibility on deletes ([c9eafdd](https://github.com/deliverybot/helm/commit/c9eafdd))


### Features

* Add helm3 binary ([5e2cd2f](https://github.com/deliverybot/helm/commit/5e2cd2f))
* Remove purge flag from helm delete ([3821f46](https://github.com/deliverybot/helm/commit/3821f46))

## [1.0.0](https://github.com/deliverybot/helm/compare/v0.1.2...v1.0.0) (2019-09-08)

### [0.1.2](https://github.com/deliverybot/helm/compare/v0.1.1...v0.1.2) (2019-09-08)

### [0.1.1](https://github.com/deliverybot/helm/compare/v0.1.0...v0.1.1) (2019-09-08)

## [0.1.0](https://github.com/deliverybot/helm/compare/v0.0.4...v0.1.0) (2019-09-08)


### Features

* Canary triggered on canary track only ([671da40](https://github.com/deliverybot/helm/commit/671da40))

### [0.0.4](https://github.com/deliverybot/helm/compare/v0.0.3...v0.0.4) (2019-09-08)


### Features

* Add migration ([10d3007](https://github.com/deliverybot/helm/commit/10d3007))
* Add remove canary option ([5f991c6](https://github.com/deliverybot/helm/commit/5f991c6))
* Add workers ([13efedc](https://github.com/deliverybot/helm/commit/13efedc))
* Introduce appName for canary deployments ([6538c4c](https://github.com/deliverybot/helm/commit/6538c4c))
* Update labels and names to app ([9387304](https://github.com/deliverybot/helm/commit/9387304))

### [0.0.3](https://github.com/deliverybot/helm/compare/v0.0.2...v0.0.3) (2019-09-01)


### Bug Fixes

* Add value files to args ([9036930](https://github.com/deliverybot/helm/commit/9036930))
* Default to root health ([b2d98d0](https://github.com/deliverybot/helm/commit/b2d98d0))
* Parse secret values ([64b622a](https://github.com/deliverybot/helm/commit/64b622a))
* Value list load if not string ([6483cd3](https://github.com/deliverybot/helm/commit/6483cd3))


### Features

* Helm chart customization ([abc7b15](https://github.com/deliverybot/helm/commit/abc7b15))
* Templating of value files ([4b30064](https://github.com/deliverybot/helm/commit/4b30064))

### [0.0.2](https://github.com/deliverybot/helm/compare/v0.0.1...v0.0.2) (2019-08-31)


### Bug Fixes

* Absolute path for helm chart ([e15e1e4](https://github.com/deliverybot/helm/commit/e15e1e4))
* Add debug for kubeconfig ([bfa3f4b](https://github.com/deliverybot/helm/commit/bfa3f4b))
* Add log and target url ([688f310](https://github.com/deliverybot/helm/commit/688f310))
* Cat out the value file ([4d83f1e](https://github.com/deliverybot/helm/commit/4d83f1e))
* Include debug logs about vars ([4ad9022](https://github.com/deliverybot/helm/commit/4ad9022))
* Parse values if an object ([76181ec](https://github.com/deliverybot/helm/commit/76181ec))
* Remove replace on vars ([e624622](https://github.com/deliverybot/helm/commit/e624622))
* Show variables in debug ([a416967](https://github.com/deliverybot/helm/commit/a416967))
* Undefined object opts ([ab3e5f9](https://github.com/deliverybot/helm/commit/ab3e5f9))


### Features

* Add basic app chart ([35049a2](https://github.com/deliverybot/helm/commit/35049a2))
* Add canary support built in ([27023d5](https://github.com/deliverybot/helm/commit/27023d5))

### 0.0.1 (2019-08-23)


### Features

* Add dry-run option to inputs ([988fedd](https://github.com/deliverybot/helm/commit/988fedd))
* Add helm action ([1b24336](https://github.com/deliverybot/helm/commit/1b24336))
* Add initial node_modules and package ([9005d46](https://github.com/deliverybot/helm/commit/9005d46))
* Implement deployment status ([2069c0b](https://github.com/deliverybot/helm/commit/2069c0b))
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM alpine:3.15

ENV BASE_URL="https://get.helm.sh"

ENV HELM_2_FILE="helm-v2.17.0-linux-amd64.tar.gz"
ENV HELM_3_FILE="helm-v3.5.0-linux-amd64.tar.gz"


RUN echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk update && apk add --no-cache ca-certificates \
--repository http://dl-3.alpinelinux.org/alpine/edge/community/ \
jq curl bash nodejs aws-cli libimagequant@edge-main && \
# Install helm version 2:
curl -L ${BASE_URL}/${HELM_2_FILE} |tar xvz && \
mv linux-amd64/helm /usr/bin/helm && \
chmod +x /usr/bin/helm && \
rm -rf linux-amd64 && \
# Install helm version 3:
curl -L ${BASE_URL}/${HELM_3_FILE} |tar xvz && \
mv linux-amd64/helm /usr/bin/helm3 && \
chmod +x /usr/bin/helm3 && \
rm -rf linux-amd64 && \
# Init version 2 helm:
helm init --client-only
######################
# Install awscli module
pip3 install awscli

ENV PYTHONPATH "/usr/lib/python3.8/site-packages/"

COPY . /usr/src/
ENTRYPOINT ["node", "/usr/src/index.js"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 deliverybot

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.
161 changes: 160 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,160 @@
# helm_preprod
# Helm Action

Deploys a helm chart using GitHub actions. Supports canary deployments and
provides a built in helm chart for apps that listen over http to get your ramped
up quickly.

View an example repository using this action at
[github.com/deliverybot/example-helm](https://github.com/deliverybot/example-helm).

## Parameters

### Inputs

Inputs below are additionally loaded from the payload of the deployment event
payload if the action was triggered by a deployment.

- `release`: Helm release name. Will be combined with track if set. (required)
- `namespace`: Kubernetes namespace name. (required)
- `chart`: Helm chart path. If set to "app" this will use the built in helm
chart found in this repository. (required)
- `chart_version`: The version of the helm chart you want to deploy (distinct from app version)
- `values`: Helm chart values, expected to be a YAML or JSON string.
- `track`: Track for the deployment. If the track is not "stable" it activates
the canary workflow described below.
- `task`: Task name. If the task is "remove" it will remove the configured helm
release.
- `dry-run`: Helm dry-run option.
- `token`: Github repository token. If included and the event is a deployment
then the deployment_status event will be fired.
- `value-files`: Additional value files to apply to the helm chart. Expects a
JSON encoded array or a string.
- `secrets`: Secret variables to include in value file interpolation. Expects a
JSON encoded map.
- `helm`: Helm binary to execute, one of: [`helm`, `helm3`].
- `version`: Version of the app, usually commit sha works here.
- `timeout`: specify a timeout for helm deployment
- `repository`: specify the URL for a helm repo to come from
- `atomic`: If true, upgrade process rolls back changes made in case of failed upgrade. Defaults to true.

Additional parameters: If the action is being triggered by a deployment event
and the `task` parameter in the deployment event is set to `"remove"` then this
action will execute a `helm delete $service`

#### Versions

- `helm`: v2.16.1
- `helm3`: v3.0.0

### Environment

- `KUBECONFIG_FILE`: Kubeconfig file for Kubernetes cluster access.

### Value file interpolation

The following syntax allows variables to be used in value files:

- `${{ secrets.KEY }}`: References secret variables passed in the secrets input.
- `${{ deployment }}`: References the deployment event that triggered this
action.

## Example

```yaml
# .github/workflows/deploy.yml
name: Deploy
on: ['deployment']

jobs:
deployment:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1

- name: 'Deploy'
uses: 'deliverybot/helm@v1'
with:
release: 'nginx'
namespace: 'default'
chart: 'app'
token: '${{ github.token }}'
values: |
name: foobar
value-files: >-
[
"values.yaml",
"values.production.yaml"
]
env:
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'
```
## Example canary
If a track is chosen that is equal to canary, this updates the helm chart
in a few ways:
1. Release name is changed to `{release}-{track}` (eg. myapp-canary).
2. The service is disabled on the helm chart `service.enabled=false`
3. The ingress is disabled on the helm chart `ingress.enabled=false`

Not enabling the service or ingress allows the stable ingress and service
resources to pick up the canary pods and route traffic to them.

```yaml
# .github/workflows/deploy.yml
name: Deploy
on: ['deployment']
jobs:
deployment:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v1
- name: 'Deploy'
uses: 'deliverybot/helm@v1'
with:
release: 'nginx'
track: canary
namespace: 'default'
chart: 'app'
token: '${{ github.token }}'
values: |
name: foobar
env:
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'
```

## Example pr cleanup

If you are creating an environment per pull request with Helm you may have the
issue where pull request environments like `pr123` sit around in your cluster.
By using GitHub actions we can clean those up by listening for pull request
close events.

```yaml
# .github/workflows/pr-cleanup.yml
name: PRCleanup
on:
pull_request:
types: [closed]
jobs:
deployment:
runs-on: 'ubuntu-latest'
steps:
- name: 'Deploy'
uses: 'deliverybot/helm@v1'
with:
# Task remove means to remove the helm release.
task: 'remove'
release: 'review-myapp-${{ github.event.pull_request.number }}'
version: '${{ github.sha }}'
track: 'stable'
chart: 'app'
namespace: 'example-helm'
token: '${{ github.token }}'
env:
KUBECONFIG_FILE: '${{ secrets.KUBECONFIG }}'
```
Loading

0 comments on commit 6290fd2

Please sign in to comment.