Skip to content

Commit

Permalink
update doc and bash
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa6765 committed Nov 16, 2024
1 parent 9e94cf5 commit c5320af
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ $ kubectl get secrets --namespace=logging elasticsearch-master-credentials -ojso
```

* `username is elastic`

# sample project deploy

```bash
kubectl create namespace backend
kubectl apply -f project.yml
```

74 changes: 61 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ show_menu() {
echo "2. Install Kibana"
echo "3. Install Fluent Bit"
echo "4. Install Complete Stack"
echo "5. Exit"
echo "5. Uninstall Complete Stack"
echo "6. Exit"
}

# Setup namespace
Expand Down Expand Up @@ -51,28 +52,45 @@ setup_helm_repo_fluentbit() {

# Install components
install_elasticsearch() {
echo "Installing Elasticsearch..."
helm install elasticsearch elastic/elasticsearch -f ek/elasticsearch-values.yaml -n logging || { echo "Failed to install Elasticsearch"; exit 1; }
echo "Checking Elasticsearch installation..."
if helm list -n logging | grep -q "elasticsearch"; then
echo "Elasticsearch already exists, upgrading..."
helm upgrade elasticsearch elastic/elasticsearch -f ek/elasticsearch-values.yaml -n logging || { echo "Failed to upgrade Elasticsearch"; exit 1; }
else
echo "Installing Elasticsearch..."
helm install elasticsearch elastic/elasticsearch -f ek/elasticsearch-values.yaml -n logging || { echo "Failed to install Elasticsearch"; exit 1; }
fi
}

install_kibana() {
echo "Installing Kibana..."
helm install kibana elastic/kibana -f ek/kibana-values.yaml -n logging || { echo "Failed to install Kibana"; exit 1; }
echo "Checking Kibana installation..."
if helm list -n logging | grep -q "kibana"; then
echo "Kibana already exists, upgrading..."
helm upgrade kibana elastic/kibana -f ek/kibana-values.yaml -n logging || { echo "Failed to upgrade Kibana"; exit 1; }
else
echo "Installing Kibana..."
helm install kibana elastic/kibana -f ek/kibana-values.yaml -n logging || { echo "Failed to install Kibana"; exit 1; }
fi
}

install_fluentbit() {
echo "Installing Fluent Bit..."
helm install fluentbit fluent/fluent-bit -f fluentbit/values.yaml -n logging || { echo "Failed to install Fluent Bit"; exit 1; }
echo "Checking Fluent Bit installation..."
if helm list -n logging | grep -q "fluentbit"; then
echo "Fluent Bit already exists, upgrading..."
helm upgrade fluentbit fluent/fluent-bit -f fluentbit/values.yaml -n logging || { echo "Failed to upgrade Fluent Bit"; exit 1; }
else
echo "Installing Fluent Bit..."
helm install fluentbit fluent/fluent-bit -f fluentbit/values.yaml -n logging || { echo "Failed to install Fluent Bit"; exit 1; }
fi
}

# Add sleep function with loading animation
wait_with_loader() {
local seconds=$1
local message="Please wait while the system initializes"
local message="${2:-Please wait while the system initializes}"
local spin='-\|/'
local i=0

echo "Quote: $(get_random_quote)"
for ((s=seconds; s>0; s--)); do
i=$(( (i+1) %4 ))
printf "\r${message} ${spin:$i:1} (${s}s remaining)"
Expand All @@ -81,12 +99,39 @@ wait_with_loader() {
printf "\r${message} Done!\n"
}

# Add new uninstall function
uninstall_stack() {
echo "Uninstalling EFK Stack..."

# Uninstall Fluent Bit
if helm list -n logging | grep -q "fluentbit"; then
echo "Uninstalling Fluent Bit..."
helm uninstall fluentbit -n logging || echo "Failed to uninstall Fluent Bit"
fi

# Uninstall Kibana
if helm list -n logging | grep -q "kibana"; then
echo "Uninstalling Kibana..."
helm uninstall kibana -n logging || echo "Failed to uninstall Kibana"
fi

# Uninstall Elasticsearch
if helm list -n logging | grep -q "elasticsearch"; then
echo "Uninstalling Elasticsearch..."
helm uninstall elasticsearch -n logging || echo "Failed to uninstall Elasticsearch"
fi

# Delete namespace
echo "Deleting logging namespace..."
kubectl delete namespace logging --timeout=60s || echo "Failed to delete namespace"
}

# Main execution
main() {
print_banner

show_menu
read -p "Enter your choice (1-5): " choice
read -p "Enter your choice (1-6): " choice

case $choice in
1)
Expand All @@ -110,19 +155,22 @@ main() {
setup_helm_repo_fluentbit

install_elasticsearch
wait_with_loader 110
wait_with_loader 110 "Waiting for Elasticsearch to be ready ..."

install_kibana
wait_with_loader 110
wait_with_loader 110 "Waiting for Kibana to be ready ..."

install_fluentbit
;;
5)
uninstall_stack
;;
6)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option. Please select 1-5."
echo "Invalid option. Please select 1-6."
exit 1
;;
esac
Expand Down

0 comments on commit c5320af

Please sign in to comment.