export REGISTRY=registry.reymota.es
export IMG_VERSION = alpine-3
export NAMESPACE = rmdev

# limpia todo
all: imagen clean install

imagen:
	cd ../; make

ns:
	-cat namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" |kubectl create -f -

install:
	-cat reg-secret.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
	-cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -

	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl create -f -
	-cat reymota-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -


clean:

clean:
	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl delete -f -

	-cat env-prod-configmap.yaml  | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -

	-cat reg-secret.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
	-cat reymota-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -


borraclaims:
	-cat pvc-reymota.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
	-cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -

claims:
	-cat pvc-reymota.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
	-cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -

app:
	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl delete -f -
	-cat reymota-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | kubectl create -f -

