-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArgoCD - local UI deployment (#1686)
Here we integrate the wbaas UI into ArgoCD in a simpler way without additional templating and applicationsets (in contrast to what was tried in #1662). It uses plain yaml values files generated by helmfile via bin/generate-values. ./bin/generate-values $ ./bin/generate-values error: missing environment usage: generate-values <environment> <release-name> [output-file-template] The script can be run like ./bin/generate-values local ui where local could be staging or production and ui any other helmfile release. The third parameter let's you define a different helmfile than k8s/helmfile/helmfile.yaml. This is needed for the CI script. Once we moved all components to Argo we could create a Makefile target that generates/updates all values files, for our convenience. .github/workflows/check-generated-values.yml This is a new GitHub workflow that runs the script to check if the checked-in values files are actually up to date. It does this by iterating over each generated values file that is present in k8s/argocd/ and runs generate-values to compare it against. How to test this locally Mind my GitHub comments about the targetRevision in both Application manifests. Prior discussion Paired on & discussed with tom Bug: T360876 Co-authored-by: Thomas Arrow <[email protected]>
- Loading branch information
Showing
18 changed files
with
375 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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: HEAD | ||
ref: values | ||
|
||
syncPolicy: | ||
automated: | ||
# disable self-healing for local env so we can use skaffold | ||
selfHeal: {{- if eq .Values.environment "local" }} false {{ else }} true {{ end}} | ||
prune: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: HEAD | ||
helm: | ||
values: | | ||
{{ toYaml .Values | indent 8 }} | ||
syncPolicy: | ||
automated: | ||
prune: true | ||
selfHeal: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
image: | ||
tag: sha-840d55d | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
image: | ||
tag: sha-840d55d | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
image: | ||
tag: sha-840d55d | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
environment: local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
environment: production | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
environment: staging | ||
|
Oops, something went wrong.