Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecamp3-logging: add workflow to deploy it with github actions #6263

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/deploy-ecamp3-logging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy ecamp3-logging

on:
workflow_dispatch:
inputs:
environment:
description: 'Choose environment'
type: environment
required: true

jobs:
deploy-ecamp3-logging:
name: "Deploy ecamp3-logging"
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Validate environment
uses: actions/github-script@v7
with:
script: |
if (!"${{ github.event.inputs.environment }}".startsWith("ecamp3-logging")) {
throw new Error("Environment must start with 'ecamp3-logging'");
}


- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Dump secrets to .env
run: |
echo '${{ toJSON(secrets) }}' | jq -r 'keys[] as $k | select(.[$k] |contains("\n") | not) | "\($k)=\"\(.[$k])\""' >> .env
working-directory: .ops/ecamp3-logging

- name: Dump variables to .env
run: |
echo '${{ toJSON(vars) }}' | jq -r 'keys[] as $k | select(.[$k] |contains("\n") | not) | "\($k)=\"\(.[$k])\""' >> .env
working-directory: .ops/ecamp3-logging

- name: Show .env for debugging
run: echo "$(cat .env | sort)"
working-directory: .ops/ecamp3-logging

- name: Setup helm
run: |
mkdir ~/.kube && echo '${{ secrets.KUBECONFIG }}' > ~/.kube/config && chmod go-r ~/.kube/config

- name: Add helm repositories
run: |
helm repo add fluent https://fluent.github.io/helm-charts
helm repo update

- name: Diff deployment
run: |
./deploy.sh diff || true
working-directory: .ops/ecamp3-logging

- name: Show values.out.yaml
run: cat values.out.yaml
working-directory: .ops/ecamp3-logging

- name: Deploy
run: |
./deploy.sh deploy
working-directory: .ops/ecamp3-logging
3 changes: 2 additions & 1 deletion .ops/ecamp3-logging/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/charts
.env
/charts
/values.out.yaml
2 changes: 2 additions & 0 deletions .ops/ecamp3-logging/.helmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.env
/deploy.sh
/values.out.yaml
4 changes: 1 addition & 3 deletions .ops/ecamp3-logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ sh files/kibana/restore-kibana-objects.sh

To diff the deployment
```shell
helm template \
--namespace ecamp3-logging --no-hooks --skip-tests \
ecamp3-logging . --values=values.yaml --values=values-prod.yaml | kubectl diff --namespace ecamp3-logging -f - | batcat -l diff -
./deploy.sh diff
```
41 changes: 28 additions & 13 deletions .ops/ecamp3-logging/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
#!/bin/bash
#!/bin/sh

set -e
set -ea

SCRIPT_DIR=$(realpath "$(dirname "$0")")
cd $SCRIPT_DIR

if [ $# -ne 1 ]; then
echo "Usage: $0 <prod|dev>"
echo "(or other environments)"
exit 1
ELASTIC_NODE_REQUESTS_MEMORY=1000Mi
ELASTIC_NODE_LIMITS_MEMORY=1000Mi
RANDOM_STRING=$(uuidgen)

if [ -f $SCRIPT_DIR/.env ]; then
. $SCRIPT_DIR/.env
fi

# to debug: --dry-run --debug
envsubst < $SCRIPT_DIR/values.yaml > $SCRIPT_DIR/values.out.yaml

helm dep build
helm upgrade --install ecamp3-logging \
--namespace=ecamp3-logging \
--create-namespace \
$SCRIPT_DIR \
--values $SCRIPT_DIR/values.yaml \
--values $SCRIPT_DIR/values-$1.yaml

if [ $1 = "deploy" ]; then
# to debug: --dry-run --debug
helm upgrade --install ecamp3-logging \
--namespace ecamp3-logging \
--create-namespace \
$SCRIPT_DIR \
--values $SCRIPT_DIR/values.out.yaml
exit 0
fi

if [ $1 = "diff" ]; then
helm template \
--namespace ecamp3-logging --no-hooks --skip-tests ecamp3-logging \
$SCRIPT_DIR \
--values $SCRIPT_DIR/values.out.yaml | kubectl diff --namespace ecamp3-logging -f -
exit 0
fi
Empty file.
7 changes: 0 additions & 7 deletions .ops/ecamp3-logging/values-prod.yaml

This file was deleted.

10 changes: 8 additions & 2 deletions .ops/ecamp3-logging/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
fluent-operator:
containerRuntime: containerd
operator:
annotations:
trigger-recreate: ${RANDOM_STRING}
fluentbit:
enable: true
input:
Expand All @@ -19,6 +22,9 @@ fluent-operator:
watchedNamespaces:
- default
- ingress-nginx
envVars:
- name: TRIGGER_FLUENTD_RECREATE
value: ${RANDOM_STRING}
enable: true

fluentd:
Expand All @@ -38,9 +44,9 @@ elasticsearch:
elasticNode:
resources:
requests:
memory: 1000Mi
memory: ${ELASTIC_NODE_REQUESTS_MEMORY}
limits:
memory: 1000Mi
memory: ${ELASTIC_NODE_LIMITS_MEMORY}
persistence:
storageClassName: do-block-storage
resources:
Expand Down
Loading