add adopt-helm and instructions
This commit is contained in:
parent
6d06d62bbe
commit
4a7d7c6ad9
13
README.md
13
README.md
|
@ -68,5 +68,18 @@ pre-bootstrap files:
|
||||||
- `install.sh`
|
- `install.sh`
|
||||||
- `uninstall.sh`
|
- `uninstall.sh`
|
||||||
|
|
||||||
|
## Adopting a helm chart
|
||||||
|
|
||||||
|
To adopt an existing helm chart, there is an adopt-helm.sh script. It is not perfectly
|
||||||
|
reliable, however, so ensure the output makes sense.
|
||||||
|
|
||||||
|
1. Setup your helm release how you need it to work
|
||||||
|
2. `cd argo1`
|
||||||
|
2. `bash adopt-helm.sh release-name`
|
||||||
|
3. Follow configuration instructions
|
||||||
|
4. Validate templates/release-name.yaml
|
||||||
|
- Especially, check that the repoURL is correct.
|
||||||
|
5. Commit templates/release-name.yaml and values.yaml
|
||||||
|
|
||||||
|
|
||||||
[argo-crds]: https://argo-cd.readthedocs.io/en/stable/operator-manual/installation/
|
[argo-crds]: https://argo-cd.readthedocs.io/en/stable/operator-manual/installation/
|
||||||
|
|
121
argo1/adopt-helm.sh
Normal file
121
argo1/adopt-helm.sh
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
SOURCE_RELEASE="$1"
|
||||||
|
|
||||||
|
eval "$(
|
||||||
|
helm list -A -o json | jq -r --arg release $SOURCE_RELEASE '
|
||||||
|
.[]
|
||||||
|
| select(.name == $release)
|
||||||
|
| (
|
||||||
|
@sh "CHART=\( .chart | split("-") | .[0:-1] | join("-") )",
|
||||||
|
@sh "VERSION=\( .chart | split("-") | .[-1] )",
|
||||||
|
@sh "RELEASE=\( .name )",
|
||||||
|
@sh "NAMESPACE=\( .namespace )"
|
||||||
|
)
|
||||||
|
'
|
||||||
|
)"
|
||||||
|
|
||||||
|
TEMPLATE="${PWD}/templates/${RELEASE}.yaml"
|
||||||
|
if [ -e "$TEMPLATE" ];then
|
||||||
|
1>&2 echo "$TEMPLATE: already exists. aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REPO="$(
|
||||||
|
helm repo list -o json \
|
||||||
|
| jq -r '.[].url' \
|
||||||
|
| xargs -P 8 -L 1 bash -c '
|
||||||
|
if helm show readme --repo "$1" $0 > /dev/null 2>&1;then
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
|
' "$CHART" \
|
||||||
|
| sort | uniq
|
||||||
|
)"
|
||||||
|
|
||||||
|
REPOS_MATCHING="$(echo "$REPO" | grep . | wc -l | tr -d ' \t\n\r\v')"
|
||||||
|
|
||||||
|
if [ x"$REPOS_MATCHING" != x"1" ];then
|
||||||
|
1>&2 echo "found $REPOS_MATCHING repos with $CHART. aborting."
|
||||||
|
1>&2 echo "$REPO"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$CHART" = x"$VERSION" ];then 1>&2 echo "could not parse chart version from name"; exit 1; fi
|
||||||
|
|
||||||
|
VALUES="$(helm get values -n "$NAMESPACE" "$RELEASE" -o yaml)"
|
||||||
|
|
||||||
|
echo -n '# {{ if (index .Values "'"$RELEASE"'").enabled }}
|
||||||
|
---
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: "{{ .Release.Name }}-'"$RELEASE"'"
|
||||||
|
namespace: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
chart: "'"$CHART"'"
|
||||||
|
repoURL: "'"$REPO"'"
|
||||||
|
targetRevision: "'"$VERSION"'"
|
||||||
|
helm:
|
||||||
|
values: |-
|
||||||
|
{{ (index .Values "'"$RELEASE"'").values | nindent 8 }}
|
||||||
|
# the next line preserves the release name.
|
||||||
|
# this is optional but recommended for singleton services.
|
||||||
|
releaseName: "'"$RELEASE"'"
|
||||||
|
destination:
|
||||||
|
server: "https://kubernetes.default.svc"
|
||||||
|
namespace: "'"$NAMESPACE"'"
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
retry:
|
||||||
|
limit: 10
|
||||||
|
backoff:
|
||||||
|
duration: 5s
|
||||||
|
factor: 2
|
||||||
|
maxDuration: 3m0s
|
||||||
|
# {{- end }}
|
||||||
|
' > "$TEMPLATE"
|
||||||
|
|
||||||
|
if [ x"$VALUES" = x"null" ];then
|
||||||
|
SAMPLE_VALUES="## (sample configs from $CHART -- choose one) ##
|
||||||
|
|
||||||
|
### (minimal config) ###
|
||||||
|
$CHART: {enabled: true}
|
||||||
|
|
||||||
|
### (skeleton config) ###
|
||||||
|
$CHART:
|
||||||
|
enabled: true
|
||||||
|
values: |
|
||||||
|
# values.yaml contents here
|
||||||
|
"
|
||||||
|
else
|
||||||
|
SAMPLE_VALUES="
|
||||||
|
## (sample config from $CHART) ##
|
||||||
|
|
||||||
|
$RELEASE:
|
||||||
|
enabled: true
|
||||||
|
values: |
|
||||||
|
$(echo "$VALUES" | sed -e 's/^/ /')
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
|
which pbcopy > /dev/null 2>&1 && (echo "$SAMPLE_VALUES" | pbcopy)
|
||||||
|
|
||||||
|
printf '#####
|
||||||
|
A new template has been added at %s.
|
||||||
|
|
||||||
|
Please finish configuring this template by adding the following to values.yaml and customizing:
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
(this has also been copied to your clipboard on macos
|
||||||
|
' "$TEMPLATE" "$SAMPLE_VALUES"
|
Loading…
Reference in New Issue
Block a user