Add helper scripts for storage management: install-local-path-storage.sh: - Installs Rancher local-path-provisioner - Sets it as default storage class - Useful for local testing and single-node scenarios - Alternative to NFS for simpler setups diagnose-storage.sh: - Diagnoses storage-related issues - Checks for provisioner installation - Lists storage classes and PVC status - Identifies pods stuck due to storage problems 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
77 lines
2.2 KiB
Bash
Executable File
77 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
echo "=========================================="
|
|
echo "Installing Local Path Provisioner"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
log_info "This will install Rancher's local-path-provisioner for dynamic storage provisioning."
|
|
echo ""
|
|
|
|
# Create namespace for local-path-provisioner
|
|
log_info "Creating local-path-storage namespace..."
|
|
kubectl create namespace local-path-storage --dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
# Apply local-path-provisioner
|
|
log_info "Deploying local-path-provisioner..."
|
|
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.28/deploy/local-path-storage.yaml
|
|
|
|
# Wait for deployment to be ready
|
|
log_info "Waiting for local-path-provisioner to be ready..."
|
|
kubectl wait --for=condition=available --timeout=120s deployment/local-path-provisioner -n local-path-storage
|
|
|
|
# Check storage class
|
|
log_info "Checking storage class..."
|
|
kubectl get storageclass
|
|
|
|
# Set as default storage class
|
|
log_info "Setting local-path as default storage class..."
|
|
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
|
|
|
|
log_success "Local Path Provisioner installed successfully!"
|
|
echo ""
|
|
|
|
log_info "Storage configuration:"
|
|
kubectl get storageclass
|
|
echo ""
|
|
|
|
log_info "Provisioner pods:"
|
|
kubectl get pods -n local-path-storage
|
|
echo ""
|
|
|
|
echo "=========================================="
|
|
log_success "Installation Complete!"
|
|
echo "=========================================="
|
|
echo ""
|
|
log_info "You can now deploy applications that require persistent storage."
|
|
log_info "PersistentVolumeClaims will automatically be provisioned on the local node."
|
|
echo ""
|
|
log_warning "Note: local-path storage is NOT replicated across nodes."
|
|
log_warning "For production use with HA requirements, consider OpenEBS or Rook-Ceph."
|
|
echo ""
|