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

staging: argocd ui deployment #1703

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
60e0f2b
test
deer-wmde Jul 30, 2024
a52e209
add env config
deer-wmde Jul 30, 2024
0be0109
read values form deploy repo
deer-wmde Jul 31, 2024
6ff1962
test with PR branch
deer-wmde Jul 31, 2024
d9a4a53
cleanup
deer-wmde Jul 31, 2024
34a7948
restore helmfile
deer-wmde Jul 31, 2024
fa8f576
configure local cluster project
deer-wmde Jul 31, 2024
8b2bcac
add project to application
deer-wmde Jul 31, 2024
727d025
try namespace
deer-wmde Jul 31, 2024
b13d539
add namespac
deer-wmde Jul 31, 2024
564855f
adjust namepsace
deer-wmde Jul 31, 2024
65487f2
add namespaces
deer-wmde Jul 31, 2024
ebede90
test 2 destinations
deer-wmde Jul 31, 2024
189ee98
no array for namespace
deer-wmde Jul 31, 2024
12e8f45
try repostiory restriciton
deer-wmde Jul 31, 2024
18c8602
re-add project repos
deer-wmde Jul 31, 2024
e534518
add generate-values script
deer-wmde Jul 31, 2024
7cb73c1
add staging & production values files
deer-wmde Jul 31, 2024
159d5a1
add github workflow check
deer-wmde Jul 31, 2024
46fec8f
add indentation fix
deer-wmde Jul 31, 2024
2c24b24
restore helmfile
deer-wmde Jul 31, 2024
2e088f9
add indentation fix
deer-wmde Jul 31, 2024
d35e823
add fixed generated values files
deer-wmde Jul 31, 2024
8a6e66c
Merge branch 'main' into de/argo-ui-simple
deer-wmde Jul 31, 2024
b96d6f1
cleanup
deer-wmde Jul 31, 2024
5e27cf7
test workflow
deer-wmde Jul 31, 2024
ab6f50e
try docker for helmfile and yq
deer-wmde Jul 31, 2024
a78274a
shorten lines
deer-wmde Jul 31, 2024
bb06873
debug tighub
deer-wmde Jul 31, 2024
9f5e2a0
test more github
deer-wmde Jul 31, 2024
b4df986
add path restriction to workflow
deer-wmde Jul 31, 2024
27a9f9e
remove path restrictions again, seems unreliable
deer-wmde Jul 31, 2024
38f623b
more descriptive GH action step name
deer-wmde Jul 31, 2024
0a270e2
reduce argocd-config helmfile release
deer-wmde Aug 1, 2024
d9b7d58
remove ui release from helmfile
deer-wmde Aug 1, 2024
2bfa6ff
cleanup
deer-wmde Aug 1, 2024
abea973
cleanup
deer-wmde Aug 1, 2024
11e2801
re add ui release to helmfile (we still need it)
deer-wmde Aug 1, 2024
c29a485
make linter happy
deer-wmde Aug 1, 2024
15eca6e
load values file from right environment
deer-wmde Aug 1, 2024
aee87f2
added comment to explain values flow
deer-wmde Aug 1, 2024
2d30ed3
add newline for linter
deer-wmde Aug 1, 2024
02c8eb8
Merge branch 'main' into de/argo-ui-simple
deer-wmde Aug 2, 2024
04dd807
enable self-heal
deer-wmde Aug 2, 2024
51348b4
enable self heal for app of apps
deer-wmde Aug 2, 2024
67fd73c
uninstall local ui release in helmfile
deer-wmde Aug 2, 2024
d02b084
add debug flag for workflow
deer-wmde Aug 2, 2024
0c31a12
Update bin/generate-values
deer-wmde Aug 2, 2024
556b186
add debug output for generate values script
deer-wmde Aug 2, 2024
6181459
generate-values: add fix for uninstalled helmfile releases
deer-wmde Aug 2, 2024
22a8212
staging: uninstall ui release
deer-wmde Aug 2, 2024
1d65386
staging: install argo app-of-apps
deer-wmde Aug 2, 2024
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
59 changes: 59 additions & 0 deletions .github/workflows/check-generated-values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on: push
name: Check values files
jobs:
diff:
runs-on: ubuntu-latest
env:
TMP_DIR: "/tmp/shared"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Create directories
run: |
mkdir -p ~/.local/bin
mkdir -p "${TMP_DIR}"
chmod 777 "${TMP_DIR}"
- name: Create helmfile docker shim
run: |
docker pull ghcr.io/helmfile/helmfile:latest

echo 'docker run \
--rm \
--volume "${TMP_DIR}:${TMP_DIR}" \
--volume "${PWD}:/workdir" \
--workdir /workdir \
--user $(id -u):$(id -g) \
ghcr.io/helmfile/helmfile:latest helmfile $*' \
| tee ~/.local/bin/helmfile

chmod +x ~/.local/bin/helmfile
- name: Create yq docker shim
run: |
docker pull mikefarah/yq:latest

echo 'docker run \
--rm \
--volume "${TMP_DIR}:${TMP_DIR}" \
--volume "${PWD}:/workdir" \
--workdir /workdir \
--user $(id -u):$(id -g) \
mikefarah/yq:latest $*' \
| tee ~/.local/bin/yq

chmod +x ~/.local/bin/yq
- name: Diff current values files against generated ones
run: >
set -x;
for ENV_DIR in k8s/argocd/*; do
ENV=$(basename "${ENV_DIR}")

for RELEASE_FILE in "${ENV_DIR}"/*.values.yaml; do
RELEASE=$(basename "${RELEASE_FILE}" .values.yaml)
TMP_VALUES="${TMP_DIR}"/tmp_"${ENV}.${RELEASE}".yml

echo "checking $RELEASE_FILE - [$ENV] [$RELEASE]"

./bin/generate-values "${ENV}" "${RELEASE}" "${TMP_VALUES}"
diff "${TMP_VALUES}" "${RELEASE_FILE}"
done
done
58 changes: 58 additions & 0 deletions bin/generate-values
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

function usage() {
echo
echo "usage: $(basename $0) <environment> <release-name> [output-file-template]"
echo
}

ENVIRONMENT="$1"
RELEASE="$2"

# absolute path of the wbaas-deploy repository
ROOT=$(realpath $(dirname $(realpath $BASH_SOURCE))/..)
OUTPUT_TEMPLATE="${ROOT}/k8s/argocd/${ENVIRONMENT}/${RELEASE}.values.yaml"
HELMFILE="k8s/helmfile/helmfile.yaml"
TMP_HELMFILE="$(dirname ${HELMFILE})/.tmp_helmfile.$(mktemp -u XXXXXX).yaml"

if [[ -n "$3" ]]; then
OUTPUT_TEMPLATE="$3"
fi

if [[ ! -e "${HELMFILE}" ]]; then
echo "error: helmfile not found: '${HELMFILE}'"
usage
exit 1
fi

if [[ -z "${ENVIRONMENT}" ]]; then
echo "error: missing environment"
usage
exit 2
fi

if [[ -z "${RELEASE}" ]]; then
echo "error: missing release name"
usage
exit 3
fi

echo "environment: ${ENVIRONMENT}"
echo "release: ${RELEASE}"

# modify tmp helmfile by setting each release as "installed", so it always gets processed
cp "${HELMFILE}" "${TMP_HELMFILE}"
sed -i 's/installed: .*$/installed: true/g' "${TMP_HELMFILE}"

helmfile \
--file "${TMP_HELMFILE}" \
--environment "${ENVIRONMENT}" \
--selector name="${RELEASE}" \
--output-file-template "${OUTPUT_TEMPLATE}" \
--skip-deps \
write-values

rm "${TMP_HELMFILE}"

# fix indentation in output file for yamllint action
yq -I 2 -i "${OUTPUT_TEMPLATE}"
6 changes: 6 additions & 0 deletions charts/argocd-apps/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: argocd-apps
description: Chart to deploy WBaaS apps in an "app-of-apps" pattern via ArgoCD
type: application
version: 0.1.0
appVersion: "1.0"
27 changes: 27 additions & 0 deletions charts/argocd-apps/templates/wbaas-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ui
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
namespace: default
server: {{ .Values.clusterUrl }}
project: {{ .Values.environment }}
sources:
- repoURL: {{ .Values.repoUrls.charts }}
path: charts/ui
targetRevision: HEAD
helm:
valueFiles:
- $values/k8s/argocd/{{ .Values.environment }}/ui.values.yaml
- repoURL: {{ .Values.repoUrls.deploy }}
targetRevision: de/argo-ui-simple
ref: values

syncPolicy:
automated:
selfHeal: true
prune: true
3 changes: 3 additions & 0 deletions charts/argocd-apps/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
clusterUrl: https://kubernetes.default.svc

# "inherits" values from argocd-config chart
23 changes: 23 additions & 0 deletions charts/argocd-config/.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/
6 changes: 6 additions & 0 deletions charts/argocd-config/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: argocd-apps
description: Chart to deploy ArgoCD configuration (including the argocd-apps chart)
type: application
version: 0.1.0
appVersion: "1.0"
20 changes: 20 additions & 0 deletions charts/argocd-config/templates/app-of-apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-of-apps
spec:
destination:
server: https://kubernetes.default.svc
namespace: argocd
project: {{ .Values.environment }}
source:
path: charts/argocd-apps
repoURL: {{ .Values.repoUrls.deploy }}
targetRevision: de/argo-ui-simple # debug! needs to be set to HEAD
helm:
values: |
{{ toYaml .Values | indent 8 }}
syncPolicy:
automated:
prune: true
selfHeal: true
16 changes: 16 additions & 0 deletions charts/argocd-config/templates/projects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: {{ .Values.environment }}
spec:
description: The {{ .Values.environment }} deployment of wikibase.cloud
destinations:
- name: in-cluster-default
namespace: default
server: https://kubernetes.default.svc
- name: in-cluster-argocd
namespace: argocd
server: https://kubernetes.default.svc
sourceRepos:
- {{ .Values.repoUrls.deploy }}
- {{ .Values.repoUrls.charts }}
5 changes: 5 additions & 0 deletions charts/argocd-config/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
environment: production

repoUrls:
deploy: https://github.com/wmde/wbaas-deploy
charts: https://github.com/wbstack/charts.git
29 changes: 29 additions & 0 deletions k8s/argocd/local/ui.values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
image:
tag: sha-a678a06
ingress:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
enabled: true
hosts:
- host: www.wbaas.localhost
paths:
- /*
tls: null
podLabels:
sidecar.istio.io/inject: "true"
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 1m
memory: 6Mi
ui:
apiUrl: http://api.wbaas.localhost
cnameConfigMapKey: cname_record
configMapName: wbaas-ui-config
recaptchaSitekeySecretKey: site_key
recaptchaSitekeySecretName: recaptcha-v3-secrets
subdomainSuffix: .wbaas.localhost
32 changes: 32 additions & 0 deletions k8s/argocd/production/ui.values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
image:
tag: sha-a678a06
ingress:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
enabled: true
hosts:
- host: www.wikibase.cloud
paths:
- /*
tls:
- hosts:
- www.wikibase.cloud
secretName: wikibase-production-tls
podLabels:
sidecar.istio.io/inject: "true"
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 1m
memory: 6Mi
ui:
apiUrl: https://api.wikibase.cloud
cnameConfigMapKey: cname_record
configMapName: wbaas-ui-config
recaptchaSitekeySecretKey: site_key
recaptchaSitekeySecretName: recaptcha-v3-secrets
subdomainSuffix: .wikibase.cloud
32 changes: 32 additions & 0 deletions k8s/argocd/staging/ui.values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
image:
tag: sha-a678a06
ingress:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
enabled: true
hosts:
- host: www.wikibase.dev
paths:
- /*
tls:
- hosts:
- www.wikibase.dev
secretName: wikibase-dev-tls
podLabels:
sidecar.istio.io/inject: "true"
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 1m
memory: 6Mi
ui:
apiUrl: https://api.wikibase.dev
cnameConfigMapKey: cname_record
configMapName: wbaas-ui-config
recaptchaSitekeySecretKey: site_key
recaptchaSitekeySecretName: recaptcha-v3-secrets
subdomainSuffix: .wikibase.dev
2 changes: 2 additions & 0 deletions k8s/helmfile/env/local/argocd-config.values.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
environment: local

2 changes: 2 additions & 0 deletions k8s/helmfile/env/production/argocd-config.values.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
environment: production

2 changes: 2 additions & 0 deletions k8s/helmfile/env/staging/argocd-config.values.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
environment: staging

7 changes: 7 additions & 0 deletions k8s/helmfile/helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ releases:
################################
# ALL ENVIRONMENTS
################################
- name: argocd-config
namespace: argocd
chart: ../../charts/argocd-config
installed: {{ ne .Environment.Name "production" | toYaml }}
<<: *default_release

- name: redirects
namespace: default
chart: ./../../charts/redirects
Expand Down Expand Up @@ -159,6 +165,7 @@ releases:
<<: *default_release

- name: ui
installed: {{ eq .Environment.Name "production" | toYaml }}
namespace: default
chart: wbstack/ui
version: 0.3.1
Expand Down