-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·62 lines (55 loc) · 1.87 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Function to install ArgoCD
install_argocd() {
echo "Installing ArgoCD..."
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
echo "ArgoCD installed successfully."
}
# Function to get ArgoCD secret
get_secret() {
echo "Retrieving ArgoCD admin's password..."
PASSWORD=$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)
echo "ArgoCD admin password: $PASSWORD"
}
# Function to set up port-forwarding
setup_port_forward() {
echo "Setting up port-forwarding..."
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
PORT_FORWARD_PID=$!
echo "Port-forwarding set up. ArgoCD UI available at https://localhost:8080"
echo "Press Enter to stop port-forwarding."
read
kill $PORT_FORWARD_PID
}
# Function to add load balancer
add_load_balancer() {
echo "Adding Load Balancer..."
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
echo "Load Balancer added. It may take a few minutes for an external IP to be assigned."
}
# Function to uninstall ArgoCD
uninstall_argocd() {
echo "Uninstalling ArgoCD..."
kubectl delete -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl delete namespace argocd
echo "ArgoCD uninstalled successfully."
}
# Main menu
echo "ArgoCD Setup Menu:"
echo "1. Install ArgoCD"
echo "2. Get ArgoCD secret"
echo "3. Set up port-forwarding"
echo "4. Add load balancer"
echo "5. Uninstall ArgoCD"
echo "6. Exit"
read -p "Enter your choice (1-6): " choice
case $choice in
1) install_argocd ;;
2) get_secret ;;
3) setup_port_forward ;;
4) add_load_balancer ;;
5) uninstall_argocd ;;
6) echo "Exiting..."; exit 0 ;;
*) echo "Invalid option." ;;
esac