helm
helm copied to clipboard
How can I use multiple KUBECONFIG_FILE? - Works with auto_deploy_on, fails with manual deploy
I have 2 k8s clusters - one for production, one for review & staging environment.
Functionality I'm trying to achieve:
- Deploy to test cluster on merge to test branch
- Manually deploy master to production using the deliverybot web-app ( https://app.deliverybot.dev/ )
This is how my config looks like.
.github/workflows/cd.yml
name: 'Deploy'
on: [deployment]
jobs:
deployment:
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout'
uses: 'actions/checkout@v1'
- name: Set Test Kubeconfig
if: github.ref == 'refs/heads/test'
run: |
echo "KUBECONFIG_FILE<<EOF" >> $GITHUB_ENV
echo "${{ secrets.TEST_KUBECONFIG }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set Production Kubeconfig
if: github.ref == 'refs/heads/master'
run: |
echo "KUBECONFIG_FILE<<EOF" >> $GITHUB_ENV
echo "${{ secrets.PRODUCTION_KUBECONFIG }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 'Deploy'
# Parameters are pulled directly from the GitHub deployment event so the
# configuration for the job here is very minimal.
uses: 'deliverybot/helm@master'
with:
token: '${{ github.token }}'
secrets: '${{ toJSON(secrets) }}'
version: '${{ github.sha }}'
chart: './charts/my-app'
.github/deploy.yml
production:
production_environment: true
required_contexts: []
environment: production
description: "Production Deployment"
payload:
value_files: ["./values/my-app/values.common.yaml", "./values/my-app/values.production.yaml"]
# Remove the canary deployment if it exists when doing a full prod deploy.
remove_canary: true
release: production-my-app
namespace: production
track: stable
helm: helm3
test:
auto_deploy_on: refs/heads/test
required_contexts: []
environment: test
description: "Test deployment"
payload:
value_files: ["./values/my-app/values.common.yaml", "./values/my-app/values.test.yaml"]
remove_canary: true
release: test-my-app
namespace: test
track: stable
helm: helm3
This works when I push/merge to test branch.
But when i trigger a deployment from the deliverybot web-app targetting test/master , It skips the steps that sets kubeconfig