Skip to content

Commit

Permalink
feat(makefile): add deploy command to deploy image to k8s (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson committed Jul 25, 2016
1 parent ee0937e commit ed96f15
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ DEV_ENV_WORK_DIR := /go/src/${REPO_PATH}
DEV_ENV_PREFIX := docker run --rm -e GO15VENDOREXPERIMENT=1 -v ${CURDIR}:${DEV_ENV_WORK_DIR} -w ${DEV_ENV_WORK_DIR}
DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}

# Get the component informtation to a tmp location and get replica count
KUBE := $(shell which kubectl)
ifdef KUBE
$(shell kubectl get rc deis-$(SHORT_NAME) --namespace deis -o yaml > /tmp/deis-$(SHORT_NAME))
DESIRED_REPLICAS=$(shell kubectl get -o template rc/deis-$(SHORT_NAME) --template={{.status.replicas}} --namespace deis)
endif

# SemVer with build information is defined in the SemVer 2 spec, but Docker
# doesn't allow +, so we use -.
BINARY_DEST_DIR := rootfs/usr/bin
Expand Down Expand Up @@ -56,4 +63,9 @@ docker-build: build
docker-push:
docker push ${IMAGE}

deploy: docker-build docker-push
sed 's#\(image:\) .*#\1 $(IMAGE)#' /tmp/deis-$(SHORT_NAME) | kubectl apply --validate=true -f -
kubectl scale rc deis-$(SHORT_NAME) --replicas 0 --namespace deis
kubectl scale rc deis-$(SHORT_NAME) --replicas $(DESIRED_REPLICAS) --namespace deis

.PHONY: all build docker-compile kube-up kube-down deploy

0 comments on commit ed96f15

Please sign in to comment.