deploy-nginx.sh 777 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # Script to deploy nginx to k3s cluster
  3. echo "Deploying nginx to k3s cluster..."
  4. # Check if kubectl is available
  5. if ! command -v kubectl &> /dev/null; then
  6. echo "kubectl could not be found. Please install kubectl and configure kubectl config."
  7. exit 1
  8. fi
  9. # Deploy nginx
  10. echo "Applying nginx deployment..."
  11. kubectl apply -f nginx-deployment.yaml
  12. # Wait for deployment to be ready
  13. echo "Waiting for nginx deployment to be ready..."
  14. kubectl rollout status deployment/nginx-deployment -n default
  15. # Show deployment status
  16. echo "Nginx deployment status:"
  17. kubectl get deployments,pods,services -l app=nginx
  18. echo "Nginx deployment completed!"
  19. echo "To access nginx service, use the external IP from the following command:"
  20. echo "kubectl get svc nginx-service"