Created
February 18, 2025 15:33
-
-
Save akoserwal/0cfbf6879d49d3ab8c935e3b80360bb9 to your computer and use it in GitHub Desktop.
deploy-golang-kube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e # Exit on error | |
# Variables | |
IMAGE_NAME="goechoapp" | |
TAG="latest" | |
KIND_CLUSTER_NAME="local-cluster" | |
DEPLOYMENT_YAML="goechoapp/deploy/echoapp.yaml" | |
# Step 1: Build Docker Image | |
echo "Building Docker image..." | |
docker build -t ${IMAGE_NAME}:${TAG} -f goechoapp/Dockerfile | |
# Step 2: Create a Kind Cluster (if not exists) | |
if ! kind get clusters | grep -q ${KIND_CLUSTER_NAME}; then | |
echo "Creating Kind cluster..." | |
kind create cluster --name ${KIND_CLUSTER_NAME} | |
else | |
echo "Kind cluster already exists." | |
fi | |
# Step 3: Load Image into Kind | |
#echo "Loading image into Kind cluster..." | |
#kind load docker-image ${IMAGE_NAME}:${TAG} --name ${KIND_CLUSTER_NAME} | |
podman save localhost/goechoapp:latest -o goechoapp.tar && \ | |
kind load image-archive goechoapp.tar | |
# Step 4: Apply Kubernetes Deployment | |
echo "Applying Kubernetes deployment..." | |
kubectl apply -f ${DEPLOYMENT_YAML} | |
# Step 5: Verify Deployment | |
echo "Verifying deployment..." | |
kubectl get pods -o wide | |
kubectl get deployments | |
echo "Deployment completed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment