Separates cluster service config from install.
This commit is contained in:
124
bin/wild-cluster-services-configure
Executable file
124
bin/wild-cluster-services-configure
Executable file
@@ -0,0 +1,124 @@
|
||||
#\!/bin/bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# Usage function
|
||||
usage() {
|
||||
echo "Usage: wild-cluster-services-configure [options] [service...]"
|
||||
echo ""
|
||||
echo "Compile service templates with configuration"
|
||||
echo ""
|
||||
echo "Arguments:"
|
||||
echo " service Specific service(s) to compile (optional)"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " wild-cluster-services-configure # Compile all services"
|
||||
echo " wild-cluster-services-configure metallb traefik # Compile specific services"
|
||||
echo ""
|
||||
echo "Available services:"
|
||||
echo " metallb, longhorn, traefik, coredns, cert-manager,"
|
||||
echo " externaldns, kubernetes-dashboard, nfs, docker-registry"
|
||||
}
|
||||
|
||||
# Parse arguments
|
||||
DRY_RUN=false
|
||||
LIST_SERVICES=false
|
||||
SPECIFIC_SERVICES=()
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
SPECIFIC_SERVICES+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Initialize Wild Cloud environment
|
||||
if [ -z "${WC_ROOT}" ]; then
|
||||
print "WC_ROOT is not set."
|
||||
exit 1
|
||||
else
|
||||
source "${WC_ROOT}/scripts/common.sh"
|
||||
init_wild_env
|
||||
fi
|
||||
|
||||
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster-services"
|
||||
|
||||
# Check if cluster setup directory exists
|
||||
if [ ! -d "$CLUSTER_SETUP_DIR" ]; then
|
||||
print_error "Cluster services setup directory not found: $CLUSTER_SETUP_DIR"
|
||||
print_info "Run 'wild-cluster-services-generate' first to generate setup files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# CLUSTER SERVICES TEMPLATE COMPILATION
|
||||
# =============================================================================
|
||||
|
||||
print_header "Cluster services template compilation"
|
||||
|
||||
# Get list of services to compile
|
||||
if [ ${#SPECIFIC_SERVICES[@]} -gt 0 ]; then
|
||||
SERVICES_TO_INSTALL=("${SPECIFIC_SERVICES[@]}")
|
||||
print_info "Compiling specific services: ${SERVICES_TO_INSTALL[*]}"
|
||||
else
|
||||
# Compile all available services in a specific order for dependencies
|
||||
SERVICES_TO_INSTALL=(
|
||||
"metallb"
|
||||
"longhorn"
|
||||
"traefik"
|
||||
"coredns"
|
||||
"cert-manager"
|
||||
"externaldns"
|
||||
"kubernetes-dashboard"
|
||||
"nfs"
|
||||
"docker-registry"
|
||||
)
|
||||
print_info "Installing all available services"
|
||||
fi
|
||||
|
||||
print_info "Services to compile: ${SERVICES_TO_INSTALL[*]}"
|
||||
|
||||
# Compile services
|
||||
cd "$CLUSTER_SETUP_DIR"
|
||||
INSTALLED_COUNT=0
|
||||
FAILED_COUNT=0
|
||||
|
||||
for service in "${SERVICES_TO_INSTALL[@]}"; do
|
||||
print_info "Compiling $service"
|
||||
|
||||
service_dir="$CLUSTER_SETUP_DIR/$service"
|
||||
source_service_dir="$service_dir/kustomize.template"
|
||||
dest_service_dir="$service_dir/kustomize"
|
||||
|
||||
# Run configuration to make sure we have the template values we need.
|
||||
config_script="$service_dir/configure.sh"
|
||||
if [ -f "$config_script" ]; then
|
||||
source "$config_script"
|
||||
fi
|
||||
|
||||
wild-compile-template-dir --clean "$source_service_dir" "$dest_service_dir"
|
||||
echo ""
|
||||
done
|
||||
|
||||
cd - >/dev/null
|
||||
|
||||
print_success "Successfully compiled: $INSTALLED_COUNT services"
|
Reference in New Issue
Block a user