Skip to content

Commit

Permalink
Improve argocd installation
Browse files Browse the repository at this point in the history
  • Loading branch information
electrocucaracha committed Oct 22, 2024
1 parent 162a682 commit 3ae44ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
14 changes: 14 additions & 0 deletions _commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ BASH
BASH
}

function _run_argocd_cmd {
# Installing ArgoCD CLI
if ! command -v argocd >/dev/null; then
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
sudo curl -fsSL -o /usr/bin/argocd "https://github.com/argoproj/argo-cd/releases/download/$argocd_version/argocd-$OS-$ARCH"
sudo chmod +x /usr/bin/argocd
fi

argocd_cmd="ARGOCD_OPTS='--port-forward-namespace argocd --port-forward' $(command -v argocd) "
echo "$argocd_cmd $@"
eval "$argocd_cmd $@"
}

function _run_ansible_cmd {
local playbook=$1
local log=$2
Expand Down
27 changes: 8 additions & 19 deletions _installers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,26 +341,15 @@ function install_nephio {
function install_argocd {
argocd_version=$(_get_version argocd)

kubectl create namespace argocd-system || :
kubectl apply -n argocd-system -f "https://raw.githubusercontent.com/argoproj/argo-cd/$argocd_version/manifests/install.yaml"
kubectl create namespace argocd || :
kubectl apply -n argocd -f "https://raw.githubusercontent.com/argoproj/argo-cd/$argocd_version/manifests/install.yaml"
if [[ -n $(kubectl get ipaddresspools.metallb.io -n metallb-system -o jsonpath='{range .items[*].metadata.name}{@}{"\n"}{end}') ]]; then
kubectl patch svc argocd-server -n argocd-system -p '{"spec": {"type": "LoadBalancer"}}'
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
fi
wait_for_pods argocd

# Installing ArgoCD CLI
if ! command -v argocd >/dev/null; then
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
sudo curl -fsSL -o /usr/bin/argocd "https://github.com/argoproj/argo-cd/releases/download/$argocd_version/argocd-$OS-$ARCH"
sudo chmod +x /usr/bin/argocd
fi
wait_for_pods argocd-system

# Cluster registration
export ARGOCD_OPTS='--port-forward-namespace argocd-system --port-forward'
admin_pass=$(kubectl get secrets -n argocd-system argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d)
argocd login --username admin --password "$admin_pass"
argocd account update-password --account admin --current-password "$admin_pass" --new-password P4$$w0rd
argocd cluster add "$(kubectl config get-contexts -o name)" --yes
kubectl delete secrets -n argocd-system argocd-initial-admin-secret --ignore-not-found
admin_pass=$(kubectl get secrets -n argocd argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d)
_run_argocd_cmd login --username admin --password "$admin_pass"
_run_argocd_cmd account update-password --account admin --current-password "$admin_pass" --new-password P4$$w0rd
kubectl delete secrets -n argocd argocd-initial-admin-secret --ignore-not-found
}

0 comments on commit 3ae44ac

Please sign in to comment.