Last active
January 15, 2024 16:48
-
-
Save pebcac/985713af5e9f2f4a858c8a0964200541 to your computer and use it in GitHub Desktop.
Generic makefile template for an OpenShift app deployment
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
# Makefile for OpenShift/Kubernetes Deployment | |
# Define variables | |
NAMESPACE := test | |
IMAGE_NAME := your-image-name | |
IMAGE_TAG := latest | |
DOCKER_REGISTRY := your-docker-registry | |
# Default target | |
all: deploy | |
# Deploy everything | |
deploy: deploy-sa deploy-role deploy-rolebinding deploy-app | |
# Deploy Service Account | |
deploy-sa: | |
oc apply -f serviceaccount.yaml | |
# Deploy Role | |
deploy-role: | |
oc apply -f role.yaml | |
# Deploy RoleBinding | |
deploy-rolebinding: | |
oc apply -f rolebinding.yaml | |
# Deploy Application | |
deploy-app: | |
oc apply -f deployment.yaml | |
oc apply -f service.yaml | |
# Build and push Docker image | |
build-push-image: | |
podman build -t $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) . | |
podman push $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) | |
# Run Tests | |
test: | |
kubectl -n $(NAMESPACE) get all | |
@echo "Running additional tests..." | |
# Here you can add your specific tests (e.g., curl for checking a web service) | |
# Clean up resources | |
clean: | |
oc delete -f deployment.yaml | |
oc delete -f service.yaml | |
oc delete -f rolebinding.yaml | |
oc delete -f role.yaml | |
oc delete -f serviceaccount.yaml | |
# Help | |
help: | |
@echo "Makefile for deploying and managing OpenShift/Kubernetes resources" | |
@echo "" | |
@echo "Usage:" | |
@echo " make deploy - Deploy all resources to the cluster" | |
@echo " make build-push-image - Build and push Docker image" | |
@echo " make test - Run tests" | |
@echo " make clean - Delete all deployed resources" | |
@echo " make help - Show this help message" | |
.PHONY: deploy deploy-sa deploy-role deploy-rolebinding deploy-app build-push-image test clean help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified template to use "oc" and "podman"