30 lines
880 B
Bash
Executable File
30 lines
880 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
SCRIPT_PATH="$(realpath "${BASH_SOURCE[0]}")"
|
|
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
# Source environment variables
|
|
if [[ -f "../load-env.sh" ]]; then
|
|
source ../load-env.sh
|
|
fi
|
|
|
|
echo "Setting up CoreDNS for k3s..."
|
|
echo "Script directory: ${SCRIPT_DIR}"
|
|
echo "Current directory: $(pwd)"
|
|
|
|
# Apply the custom config for the k3s-provided CoreDNS
|
|
echo "Applying CoreDNS configuration..."
|
|
cat "${SCRIPT_DIR}/coredns/coredns-config.yaml" | envsubst | kubectl apply -f -
|
|
|
|
# Apply the LoadBalancer service for external access to CoreDNS
|
|
echo "Applying CoreDNS service configuration..."
|
|
cat "${SCRIPT_DIR}/coredns/coredns-service.yaml" | envsubst | kubectl apply -f -
|
|
|
|
# Restart CoreDNS pods to apply the changes
|
|
echo "Restarting CoreDNS pods to apply changes..."
|
|
kubectl delete pod -n kube-system -l k8s-app=kube-dns
|
|
|
|
echo "CoreDNS setup complete!"
|