Skip to content

Commit ed96f15

Browse files
feat(makefile): add deploy command to deploy image to k8s (#396)
1 parent ee0937e commit ed96f15

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
1212
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
1313
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
1414

15+
# Get the component informtation to a tmp location and get replica count
16+
KUBE := $(shell which kubectl)
17+
ifdef KUBE
18+
$(shell kubectl get rc deis-$(SHORT_NAME) --namespace deis -o yaml > /tmp/deis-$(SHORT_NAME))
19+
DESIRED_REPLICAS=$(shell kubectl get -o template rc/deis-$(SHORT_NAME) --template={{.status.replicas}} --namespace deis)
20+
endif
21+
1522
# SemVer with build information is defined in the SemVer 2 spec, but Docker
1623
# doesn't allow +, so we use -.
1724
BINARY_DEST_DIR := rootfs/usr/bin
@@ -56,4 +63,9 @@ docker-build: build
5663
docker-push:
5764
docker push ${IMAGE}
5865

66+
deploy: docker-build docker-push
67+
sed 's#\(image:\) .*#\1 $(IMAGE)#' /tmp/deis-$(SHORT_NAME) | kubectl apply --validate=true -f -
68+
kubectl scale rc deis-$(SHORT_NAME) --replicas 0 --namespace deis
69+
kubectl scale rc deis-$(SHORT_NAME) --replicas $(DESIRED_REPLICAS) --namespace deis
70+
5971
.PHONY: all build docker-compile kube-up kube-down deploy

0 commit comments

Comments
 (0)