27 lines
760 B
Bash
Executable File
27 lines
760 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Apply the namespace
|
|
kubectl apply -f k8s/namespace.yaml
|
|
|
|
# Apply the StatefulSet and related objects
|
|
kubectl apply -f k8s/statefulset.yaml
|
|
|
|
# Apply the Django Deployment
|
|
kubectl apply -f k8s/deployment.yaml
|
|
|
|
# Apply the Django Service
|
|
kubectl apply -f k8s/service.yaml
|
|
|
|
# Wait for the PostgreSQL pod to be ready
|
|
echo "Waiting for PostgreSQL to be ready..."
|
|
kubectl wait --for=condition=Ready pod -l app=postgres -n webapp-namespace --timeout=120s
|
|
|
|
# Apply migrations using a Kubernetes Job
|
|
echo "Applying migrations..."
|
|
kubectl apply -f k8s/migrate-job.yaml
|
|
|
|
# Wait for the migration job to complete
|
|
kubectl wait --for=condition=Complete job/django-migrate -n webapp-namespace --timeout=120s
|
|
|
|
echo "All Kubernetes objects created successfully."
|