Makefile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. export REGISTRO=harbor.reymota.es\/reymota
  2. #export REGISTRO=registry.reymota.es
  3. export NAMESPACE = finanzas
  4. VERSION_FILE = .version
  5. # Get current version or default to alpine-1
  6. IMG_VERSION := $(shell cat $(VERSION_FILE) 2>/dev/null || echo "alpine-1")
  7. # Get built version for deployment targets
  8. BUILT_VERSION := $(shell cat .current_version 2>/dev/null || echo "$(IMG_VERSION)")
  9. export IMG_VERSION
  10. help:
  11. @echo ""
  12. @echo "Comandos disponibles:"
  13. @echo ""
  14. @grep "^[[:lower:]]" Makefile | grep -v "^\." | grep "##" | awk -F':.*## ' '{printf " \033[1m%-20s\033[0m %s\n", $$1, $$2}'
  15. @echo ""
  16. # limpia todo
  17. all: imagen clean install
  18. imagen: ## Crea la imagen
  19. @echo "Building image with version: $(IMG_VERSION)"
  20. @# Store current version for other targets to use
  21. @echo "$(IMG_VERSION)" > .current_version
  22. cd ../; make
  23. @# Increment version for next build
  24. @echo "$(IMG_VERSION)" | sed 's/alpine-\([0-9]*\)/alpine-\1/' | awk -F'-' '{print "alpine-" $$2+1}' > $(VERSION_FILE)
  25. @echo "Next version will be: $$(cat $(VERSION_FILE))"
  26. ns: ## Crea el namespace
  27. -cat namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" |kubectl create -f -
  28. install: ## Instala todo (meno las claims)
  29. -cat reg-secret.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  30. -cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  31. -cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  32. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
  33. -cat finanzas-service.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  34. -cat finanzas-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  35. clean: ## Borra todo (meno las claims)
  36. -cat finanzas-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  37. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
  38. -cat finanzas-service.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  39. -cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  40. -cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  41. -cat reg-secret.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  42. borraclaims: ## Borra las claims
  43. -cat pvc-finanzas.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  44. -cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
  45. claims: ## Crea las claims
  46. -cat pvc-finanzas.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  47. -cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
  48. app: ## Borra y vuelve a crear el deployment
  49. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
  50. -cat finanzas-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
  51. db: ## Crea la base de datos en el cluster
  52. -kubectl create -f finanzas-db.yaml