From 1c5a81daf048470d16af87a4cc52993ad133ee7f Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 11 Nov 2021 14:53:23 +0100 Subject: [PATCH] feat: release kubezero 1.20.11-4 --- charts/kubezero/Chart.yaml | 2 +- charts/kubezero/README.md | 14 +-- charts/kubezero/bootstrap.sh | 107 ++++++------------ charts/kubezero/convert/Chart.yaml | 13 --- charts/kubezero/convert/README.md | 26 ----- charts/kubezero/convert/templates/app.yaml | 29 ----- charts/kubezero/convert/values.yaml | 2 - charts/kubezero/{ => docs}/app.yaml | 0 .../kubezero/{ => docs}/applicationSet.yaml | 0 charts/kubezero/templates/_app.tpl | 2 +- charts/kubezero/templates/argocd.yaml | 37 ++++++ charts/kubezero/templates/argoless.yaml | 17 --- charts/kubezero/templates/kubezero.yaml | 71 ------------ charts/kubezero/values.yaml | 10 +- 14 files changed, 80 insertions(+), 250 deletions(-) delete mode 100644 charts/kubezero/convert/Chart.yaml delete mode 100644 charts/kubezero/convert/README.md delete mode 100644 charts/kubezero/convert/templates/app.yaml delete mode 100644 charts/kubezero/convert/values.yaml rename charts/kubezero/{ => docs}/app.yaml (100%) rename charts/kubezero/{ => docs}/applicationSet.yaml (100%) delete mode 100644 charts/kubezero/templates/argoless.yaml delete mode 100644 charts/kubezero/templates/kubezero.yaml diff --git a/charts/kubezero/Chart.yaml b/charts/kubezero/Chart.yaml index d6e0407..32bd07a 100644 --- a/charts/kubezero/Chart.yaml +++ b/charts/kubezero/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: kubezero description: KubeZero - Bootstrap and ArgoCD Root App of Apps chart type: application -version: 1.20.8-14 +version: 1.20.11-4 home: https://kubezero.com icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png keywords: diff --git a/charts/kubezero/README.md b/charts/kubezero/README.md index 2958bf8..3b92708 100644 --- a/charts/kubezero/README.md +++ b/charts/kubezero/README.md @@ -1,6 +1,6 @@ # kubezero -![Version: 1.20.8-13](https://img.shields.io/badge/Version-1.20.8--13-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) +![Version: 1.20.11-4](https://img.shields.io/badge/Version-1.20.11--4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) KubeZero - Bootstrap and ArgoCD Root App of Apps chart @@ -27,28 +27,23 @@ Kubernetes: `>= 1.18.0` | HighAvailableControlplane | bool | `false` | | | addons.enabled | bool | `false` | | | addons.targetRevision | string | `"0.1.0"` | | -| argocd.crds | bool | `true` | | | argocd.enabled | bool | `false` | | | argocd.istio.enabled | bool | `false` | | | argocd.namespace | string | `"argocd"` | | -| argocd.targetRevision | string | `"0.8.4"` | | -| aws-ebs-csi-driver.crds | bool | `true` | | +| argocd.targetRevision | string | `"0.8.7"` | | | aws-ebs-csi-driver.enabled | bool | `false` | | | aws-ebs-csi-driver.targetRevision | string | `"0.6.4"` | | | aws-efs-csi-driver.enabled | bool | `false` | | | aws-efs-csi-driver.targetRevision | string | `"0.4.2"` | | -| calico.crds | bool | `true` | | | calico.enabled | bool | `false` | | | calico.retain | bool | `true` | | | calico.targetRevision | string | `"0.2.2"` | | -| cert-manager.crds | bool | `true` | | | cert-manager.enabled | bool | `false` | | | cert-manager.namespace | string | `"cert-manager"` | | | cert-manager.targetRevision | string | `"0.7.3"` | | | istio-ingress.enabled | bool | `false` | | | istio-ingress.namespace | string | `"istio-ingress"` | | | istio-ingress.targetRevision | string | `"0.7.5"` | | -| istio.crds | bool | `true` | | | istio.enabled | bool | `false` | | | istio.namespace | string | `"istio-system"` | | | istio.targetRevision | string | `"0.7.5"` | | @@ -58,17 +53,14 @@ Kubernetes: `>= 1.18.0` | kubezero.gitSync | object | `{}` | | | kubezero.repoURL | string | `"https://zero-down-time.github.io/kubezero"` | | | kubezero.server | string | `"https://kubernetes.default.svc"` | | -| logging.crds | bool | `true` | | | logging.enabled | bool | `false` | | | logging.namespace | string | `"logging"` | | -| logging.targetRevision | string | `"0.7.14"` | | -| metrics.crds | bool | `true` | | +| logging.targetRevision | string | `"0.7.16"` | | | metrics.enabled | bool | `false` | | | metrics.istio.grafana | object | `{}` | | | metrics.istio.prometheus | object | `{}` | | | metrics.namespace | string | `"monitoring"` | | | metrics.targetRevision | string | `"0.5.4"` | | -| storage.crds | bool | `true` | | | storage.enabled | bool | `false` | | | storage.targetRevision | string | `"0.3.2"` | | diff --git a/charts/kubezero/bootstrap.sh b/charts/kubezero/bootstrap.sh index 395558d..0b28c01 100755 --- a/charts/kubezero/bootstrap.sh +++ b/charts/kubezero/bootstrap.sh @@ -5,7 +5,6 @@ ACTION=$1 ARTIFACTS=($(echo $2 | tr "," "\n")) CLUSTER=$3 LOCATION=${4:-""} -KUBEZERO_VERSION=${5:-""} which yq || { echo "yq not found!"; exit 1; } which helm || { echo "helm not found!"; exit 1; } @@ -16,8 +15,6 @@ echo $helm_version | grep -qe "^v3.[5-9]" || { echo "Helm version >= 3.5 require API_VERSIONS="-a monitoring.coreos.com/v1 -a snapshot.storage.k8s.io/v1" KUBE_VERSION="--kube-version $(kubectl version -o json | jq -r .serverVersion.gitVersion)" -[ -n "$KUBEZERO_VERSION" ] && KUBEZERO_VERSION="--version $KUBEZERO_VERSION --devel" - TMPDIR=$(mktemp -d kubezero.XXX) [ -z "$DEBUG" ] && trap 'rm -rf $TMPDIR' ERR EXIT @@ -61,17 +58,21 @@ function delete_ns() { # Extract crds via helm calls and apply delta=crds only function _crds() { - helm template $(chart_location $chart) -n $namespace --name-template $release --skip-crds --set ${release}.installCRDs=false -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION > $TMPDIR/helm-no-crds.yaml - helm template $(chart_location $chart) -n $namespace --name-template $release --include-crds --set ${release}.installCRDs=true -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION > $TMPDIR/helm-crds.yaml + helm template $(chart_location $chart) -n $namespace --name-template $module $targetRevision --skip-crds --set ${module}.installCRDs=false -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION > $TMPDIR/helm-no-crds.yaml + helm template $(chart_location $chart) -n $namespace --name-template $module $targetRevision --include-crds --set ${module}.installCRDs=true -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION > $TMPDIR/helm-crds.yaml diff -e $TMPDIR/helm-no-crds.yaml $TMPDIR/helm-crds.yaml | head -n-1 | tail -n+2 > $TMPDIR/crds.yaml - [ -s $TMPDIR/crds.yaml ] && kubectl apply -f $TMPDIR/crds.yaml + + # Only apply if there are actually any crds + if [ -s $TMPDIR/crds.yaml ]; then + kubectl apply -f $TMPDIR/crds.yaml + fi } # helm template | kubectl apply -f - # confine to one namespace if possible function apply(){ - helm template $(chart_location $chart) -n $namespace --name-template $release --skip-crds -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION $@ > $TMPDIR/helm.yaml + helm template $(chart_location $chart) -n $namespace --name-template $module $targetRevision --skip-crds -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION $@ > $TMPDIR/helm.yaml # If resources are in more than ONE $namespace, apply without restrictions nr_ns=$(grep -e '^ namespace:' $TMPDIR/helm.yaml | sed "s/\"//g" | sort | uniq | wc -l) @@ -85,26 +86,30 @@ function apply(){ function _helm() { local action=$1 + local module=$2 - local chart="kubezero-$2" - local release=$2 - local namespace=$(get_namespace $2) + local chart="kubezero-${module}" + local namespace=$(yq r $TMPDIR/kubezero/templates/${module}.yaml spec.destination.namespace) + + local targetRevision="--version $(yq r $TMPDIR/kubezero/templates/${module}.yaml spec.source.targetRevision)" + + yq r $TMPDIR/kubezero/templates/${module}.yaml 'spec.source.helm.values' > $TMPDIR/values.yaml if [ $action == "crds" ]; then - declare -F ${release}-crds && ${release}-crds - declare -F ${release}-crds || _crds + # Allow custom CRD handling + declare -F ${module}-crds && ${module}-crds || _crds elif [ $action == "apply" ]; then # namespace must exist prior to apply create_ns $namespace # Optional pre hook - declare -F ${release}-pre && ${release}-pre + declare -F ${module}-pre && ${module}-pre apply # Optional post hook - declare -F ${release}-post && ${release}-post + declare -F ${module}-post && ${module}-post elif [ $action == "delete" ]; then apply @@ -117,39 +122,6 @@ function _helm() { } -function is_enabled() { - local chart=$1 - local enabled=$(yq r $TMPDIR/kubezero.yaml ${chart}.enabled) - - if [ "$enabled" == "true" ]; then - # slice values for this chart only from kubezero.yaml - yq r $TMPDIR/kubezero.yaml ${chart}.values > $TMPDIR/values.yaml - return 0 - fi - return 1 -} - - -function has_crds() { - local chart=$1 - local enabled=$(yq r $TMPDIR/kubezero.yaml ${chart}.crds) - - [ "$enabled" == "true" ] && return 0 - return 1 -} - - -function get_namespace() { - local namespace=$(yq r $TMPDIR/kubezero.yaml ${1}.namespace) - [ -z "$namespace" ] && echo "kube-system" || echo $namespace -} - - -function update_kubezero_argo() { - helm template $(chart_location kubezero) -f ${VALUES%%,} --set installKubeZero=true $KUBEZERO_VERSION > $TMPDIR/kubezero-argocd.yaml - kubectl apply -f $TMPDIR/kubezero-argocd.yaml -} - ################ # cert-manager # ################ @@ -193,42 +165,37 @@ function metrics-pre() { } +########## ## MAIN ## -# First lets generate kubezero.yaml, either plain values.yaml or application.yaml for ArgoCD -if [ -f $CLUSTER/kubezero/application.yaml ]; then - yq r $CLUSTER/kubezero/application.yaml 'spec.source.helm.values' > $TMPDIR/_argovalues.yaml - VALUES=$TMPDIR/_argovalues.yaml -else - VALUES="$(find $CLUSTER -name '*.yaml' | sort | tr '\n' ',')" +########## +if [ ! -f $CLUSTER/kubezero/application.yaml ]; then + echo "Cannot find cluster config!" + exit 1 fi -helm template $(chart_location kubezero) -f ${VALUES%%,} $KUBEZERO_VERSION > $TMPDIR/kubezero.yaml -# Resolve all the all enabled artifacts in order of their appearance +KUBEZERO_VERSION=$(yq r $CLUSTER/kubezero/application.yaml 'spec.source.targetRevision') + +# Extract all kubezero values from argo app +yq r $CLUSTER/kubezero/application.yaml 'spec.source.helm.values' > $TMPDIR/values.yaml + +# Render all enabled Kubezero modules +helm template $(chart_location kubezero) -f $TMPDIR/values.yaml --version $KUBEZERO_VERSION --devel --output-dir $TMPDIR + +# Resolve all the all enabled artifacts if [ ${ARTIFACTS[0]} == "all" ]; then - ARTIFACTS=($(yq r -p p $TMPDIR/kubezero.yaml "*.enabled" | awk -F "." '{print $1}')) + ARTIFACTS=($(ls $TMPDIR/kubezero/templates | sed -e 's/.yaml//g')) fi echo "Artifacts: ${ARTIFACTS[@]}" - -if [ $1 == "deploy" ]; then +if [ $1 == "apply" -o $1 == "crds" ]; then for t in ${ARTIFACTS[@]}; do - is_enabled $t && _helm apply $t || true - done - -# If artifact enabled and has crds install -elif [ $1 == "crds" ]; then - for t in ${ARTIFACTS[@]}; do - is_enabled $t && has_crds $t && _helm crds $t || true + _helm $1 $t || true done # Delete in reverse order, continue even if errors elif [ $1 == "delete" ]; then set +e for (( idx=${#ARTIFACTS[@]}-1 ; idx>=0 ; idx-- )) ; do - is_enabled ${ARTIFACTS[idx]} && _helm delete ${ARTIFACTS[idx]} || true + _helm delete ${ARTIFACTS[idx]} || true done - -# Update ArgoCD Kubezero app -elif [ $1 == "argo" -a $2 == 'kubezero' ]; then - update_kubezero_argo fi diff --git a/charts/kubezero/convert/Chart.yaml b/charts/kubezero/convert/Chart.yaml deleted file mode 100644 index 0202a70..0000000 --- a/charts/kubezero/convert/Chart.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v2 -name: kubezero-git-sync -description: KubeZero Git Sync Argo Application to track cluster values via git -type: application -version: 0.1 -home: https://kubezero.com -icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png -keywords: - - kubezero - - argocd -maintainers: - - name: Quarky9 -kubeVersion: ">= 1.18.0" diff --git a/charts/kubezero/convert/README.md b/charts/kubezero/convert/README.md deleted file mode 100644 index beeb325..0000000 --- a/charts/kubezero/convert/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# kubezero-git-sync - -![Version: 0.1](https://img.shields.io/badge/Version-0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) - -KubeZero Git Sync Argo Application to track cluster values via git - -**Homepage:** - -## Maintainers - -| Name | Email | Url | -| ---- | ------ | --- | -| Quarky9 | | | - -## Requirements - -Kubernetes: `>= 1.18.0` - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| kubezero.version | string | `"1.20.8-9"` | | - ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/kubezero/convert/templates/app.yaml b/charts/kubezero/convert/templates/app.yaml deleted file mode 100644 index f2fc986..0000000 --- a/charts/kubezero/convert/templates/app.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: kubezero - namespace: argocd -spec: - project: kubezero - source: - repoURL: https://zero-down-time.github.io/kubezero - chart: kubezero - targetRevision: {{ .Values.kubezero.version }} - - helm: - parameters: - # We use this to detect if we are called from ArgoCD - - name: argocdAppName - value: $ARGOCD_APP_NAME - # This breaks the recursion, otherwise we install another kubezero project and app - - name: installKubeZero - value: "false" - values: | - {{- toYaml .Values | nindent 8 }} - - destination: - server: https://kubernetes.default.svc - namespace: argocd - syncPolicy: - automated: - prune: true diff --git a/charts/kubezero/convert/values.yaml b/charts/kubezero/convert/values.yaml deleted file mode 100644 index 8a5025e..0000000 --- a/charts/kubezero/convert/values.yaml +++ /dev/null @@ -1,2 +0,0 @@ -kubezero: - version: 1.20.8-9 diff --git a/charts/kubezero/app.yaml b/charts/kubezero/docs/app.yaml similarity index 100% rename from charts/kubezero/app.yaml rename to charts/kubezero/docs/app.yaml diff --git a/charts/kubezero/applicationSet.yaml b/charts/kubezero/docs/applicationSet.yaml similarity index 100% rename from charts/kubezero/applicationSet.yaml rename to charts/kubezero/docs/applicationSet.yaml diff --git a/charts/kubezero/templates/_app.tpl b/charts/kubezero/templates/_app.tpl index 269aa8f..f7ad24b 100644 --- a/charts/kubezero/templates/_app.tpl +++ b/charts/kubezero/templates/_app.tpl @@ -1,7 +1,7 @@ {{- define "kubezero-app.app" }} {{- $name := regexReplaceAll "kubezero/templates/([a-z-]*)..*" .Template.Name "${1}" }} -{{- if and .Values.argocdAppName ( index .Values $name "enabled" ) }} +{{- if index .Values $name "enabled" }} apiVersion: argoproj.io/v1alpha1 kind: Application metadata: diff --git a/charts/kubezero/templates/argocd.yaml b/charts/kubezero/templates/argocd.yaml index ef0e430..c46356c 100644 --- a/charts/kubezero/templates/argocd.yaml +++ b/charts/kubezero/templates/argocd.yaml @@ -13,10 +13,47 @@ argo-cd: {{- with index .Values "argocd" "server" }} {{- toYaml . | nindent 4 }} {{- end }} + additionalProjects: + - name: kubezero + namespace: argocd + description: KubeZero - ZeroDownTime Kubernetes Platform + sourceRepos: + - {{ .Values.kubezero.repoURL }} + {{- with .Values.kubezero.gitSync.repoURL }} + - {{ . }} + {{- end }} + destinations: + - namespace: '*' + server: https://kubernetes.default.svc + clusterResourceWhitelist: + - group: '*' + kind: '*' + additionalApplications: + - name: kubezero-git-sync + namespace: argocd + project: kubezero + source: + repoURL: {{ .Values.kubezero.gitSync.repoURL }} + targetRevision: {{ .Values.kubezero.gitSync.targetRevision }} + path: {{ .Values.kubezero.gitSync.path }} + + directory: + recurse: true + + destination: + server: https://kubernetes.default.svc + namespace: argocd + + {{- with .Values.kubezero.syncPolicy }} + syncPolicy: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with index .Values "argocd" "configs" }} configs: {{- toYaml . | nindent 4 }} {{- end }} + {{- if and ( index .Values "argocd" "istio" "enabled" ) .Values.istio.enabled }} istio: {{- with index .Values "argocd" "istio" }} diff --git a/charts/kubezero/templates/argoless.yaml b/charts/kubezero/templates/argoless.yaml deleted file mode 100644 index c38f0de..0000000 --- a/charts/kubezero/templates/argoless.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- if and ( not .Values.argocdAppName ) ( not .Values.installKubeZero ) }} -# if no ArgoCD is used, only render the global values.yaml for all kubezero modules - -{{- $artifacts := list "addons" "calico" "cert-manager" "kiam" "aws-ebs-csi-driver" "aws-efs-csi-driver" "istio" "istio-ingress" "metrics" "logging" "argocd" "storage" }} - -{{- range $artifacts }} -{{- if index $.Values . }} -{{ . }}: - enabled: {{ index $.Values . "enabled" }} - namespace: {{ default "kube-system" ( index $.Values . "namespace" ) }} - crds: {{ default false ( index $.Values . "crds" ) }} - values: - {{- include (print . "-values") $ | nindent 4 }} -{{- end }} -{{- end }} - -{{- end }} diff --git a/charts/kubezero/templates/kubezero.yaml b/charts/kubezero/templates/kubezero.yaml deleted file mode 100644 index cfdc0aa..0000000 --- a/charts/kubezero/templates/kubezero.yaml +++ /dev/null @@ -1,71 +0,0 @@ -{{- if .Values.installKubeZero }} -# Add KubeZero app and project - -apiVersion: argoproj.io/v1alpha1 -kind: AppProject -metadata: - name: kubezero - namespace: argocd - labels: - {{- include "kubezero-lib.labels" . | nindent 4 }} -spec: - description: KubeZero - ZeroDownTime Kubernetes Platform - - # Add the git repo used for git-sync - sourceRepos: - - {{ .Values.kubezero.repoURL }} - {{ with .Values.kubezero.gitSync.repoURL }} - - {{ . }} - {{- end }} - - # platform namespaces in the local cluster - destinations: - - namespace: argocd - server: https://kubernetes.default.svc - - namespace: kube-system - server: https://kubernetes.default.svc - - namespace: cert-manager - server: https://kubernetes.default.svc - - namespace: istio-system - server: https://kubernetes.default.svc - - namespace: istio-ingress - server: https://kubernetes.default.svc - - namespace: monitoring - server: https://kubernetes.default.svc - - namespace: elastic-system - server: https://kubernetes.default.svc - - namespace: logging - server: https://kubernetes.default.svc - - clusterResourceWhitelist: - - group: '*' - kind: '*' - ---- -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: kubezero-git-sync - namespace: argocd - labels: - {{- include "kubezero-lib.labels" . | nindent 4 }} -spec: - project: kubezero - source: - repoURL: {{ .Values.kubezero.gitSync.repoURL }} - targetRevision: {{ .Values.kubezero.gitSync.targetRevision }} - path: {{ .Values.kubezero.gitSync.path }} - - directory: - recurse: true - - destination: - server: https://kubernetes.default.svc - namespace: argocd - - {{- with .Values.kubezero.syncPolicy }} - syncPolicy: - {{- toYaml . | nindent 4 }} - {{- end }} - -{{- end }} diff --git a/charts/kubezero/values.yaml b/charts/kubezero/values.yaml index d95eea4..399022e 100644 --- a/charts/kubezero/values.yaml +++ b/charts/kubezero/values.yaml @@ -12,13 +12,11 @@ addons: calico: enabled: false - crds: true retain: true targetRevision: 0.2.2 cert-manager: enabled: false - crds: true namespace: cert-manager targetRevision: 0.7.3 @@ -28,12 +26,10 @@ kiam: storage: enabled: false - crds: true targetRevision: 0.3.2 aws-ebs-csi-driver: enabled: false - crds: true targetRevision: 0.6.4 aws-efs-csi-driver: @@ -42,7 +38,6 @@ aws-efs-csi-driver: istio: enabled: false - crds: true namespace: istio-system targetRevision: 0.7.5 @@ -53,7 +48,6 @@ istio-ingress: metrics: enabled: false - crds: true namespace: monitoring targetRevision: 0.5.4 istio: @@ -62,14 +56,12 @@ metrics: logging: enabled: false - crds: true namespace: logging targetRevision: 0.7.16 argocd: enabled: false - crds: true namespace: argocd - targetRevision: 0.8.4 + targetRevision: 0.8.7 istio: enabled: false