Skip to content

Commit 3027766

Browse files
author
Vaughn Dice
committed
ref(ci): refactor monitor ci
Consolidate refactored make logic for monitor components into `default.mk`; Introduce `test` and `test-style` targets for running shellcheck against bash scripts; Remove deprecated/unused `_scripts` and `manifests` directories
1 parent 6327552 commit 3027766

24 files changed

Lines changed: 76 additions & 434 deletions

default.mk

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
SHELL := /bin/bash
2+
3+
# all monitor components share/use the following targets/exports
4+
DOCKER_HOST = $(shell echo $$DOCKER_HOST)
5+
BUILD_TAG ?= git-$(shell git rev-parse --short HEAD)
6+
DEIS_REGISTRY ?= ${DEV_REGISTRY}
7+
IMAGE_PREFIX ?= deis
8+
9+
include ../includes.mk
10+
include ../versioning.mk
11+
12+
TEST_ENV_PREFIX := docker run --rm -v ${CURDIR}:/bash -w /bash quay.io/deis/shell-dev
13+
14+
build: docker-build
15+
push: docker-push
16+
deploy: check-kubectl docker-build docker-push upgrade
17+
18+
docker-build:
19+
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} rootfs
20+
docker tag ${IMAGE} ${MUTABLE_IMAGE}
21+
22+
clean: check-docker
23+
docker rmi $(IMAGE)
24+
25+
KD = kubectl --namespace=deis
26+
upgrade:
27+
${KD} patch ${RESOURCE_TYPE} deis-monitor-${SHORT_NAME} \
28+
--type='json' \
29+
-p='[ \
30+
{"op": "replace", "path": "/spec/strategy", "value":{"type":"Recreate"}}, \
31+
{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"$(IMAGE)"}, \
32+
{"op": "replace", "path": "/spec/template/spec/containers/0/imagePullPolicy", "value":"Always"} \
33+
]'
34+
@if [ "${RESOURCE_TYPE}" == "daemonset" ]; then \
35+
echo "Deleting daemonset pods as they aren't yet recreated when daemonset is patched..."; \
36+
${KD} delete $$(${KD} get pod -o name | grep "${SHORT_NAME}"); \
37+
fi
38+
39+
test: test-style
40+
41+
test-style:
42+
${TEST_ENV_PREFIX} shellcheck $(SHELL_SCRIPTS)
43+
44+
.PHONY: build push docker-build clean upgrade deploy test test-style

grafana/Makefile

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
1-
SHELL = /bin/bash
2-
3-
DOCKER_HOST = $(shell echo $$DOCKER_HOST)
4-
BUILD_TAG ?= git-$(shell git rev-parse --short HEAD)
51
SHORT_NAME ?= grafana
6-
DEIS_REGISTRY ?= ${DEV_REGISTRY}
7-
IMAGE_PREFIX ?= deis
8-
9-
include versioning.mk
10-
11-
build: docker-build
12-
push: docker-push
13-
install: kube-install
14-
uninstall: kube-delete
15-
upgrade: kube-update
16-
17-
docker-build:
18-
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} rootfs
19-
docker tag ${IMAGE} ${MUTABLE_IMAGE}
20-
21-
clean: check-docker
22-
docker rmi $(IMAGE)
23-
24-
update-manifests:
25-
sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-monitor-grafana-deployment.yaml > manifests/deis-monitor-grafana-deployment.tmp.yaml
26-
27-
kube-install: update-manifests
28-
kubectl create -f manifests/deis-monitor-grafana-svc.yaml
29-
kubectl create -f manifests/deis-monitor-grafana-deployment.tmp.yaml
30-
31-
kube-delete: update-manifests
32-
kubectl delete -f manifests/deis-monitor-grafana-svc.yaml
33-
kubectl delete -f manifests/deis-monitor-grafana-deployment.tmp.yaml
2+
RESOURCE_TYPE := deployment
3+
SHELL_SCRIPTS = rootfs/usr/share/grafana/start-grafana
344

35-
kube-update: update-manifests
36-
kubectl delete -f manifests/deis-monitor-grafana-deployment.tmp.yaml
37-
kubectl create -f manifests/deis-monitor-grafana-deployment.tmp.yaml
5+
include ../default.mk

grafana/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ There are a few key environment variables you should be aware of when interactin
118118

119119
* `make build` - Build docker image
120120
* `make push` - Push docker image to a registry
121-
* `make install` - Install all necessary components into kubernetes cluster (does not install telegraf or influx)
122-
* `make uninstall` - Remove grafana from kubernetes
123121
* `make upgrade` - Replaces the running grafana instance with a new one
124122

125123
The typical workflow will look something like this - `DEIS_REGISTRY=quay.io/ IMAGE_PREFIX=foouser make build push upgrade`

grafana/_scripts/deploy.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

grafana/manifests/deis-monitor-grafana-deployment.yaml

Lines changed: 0 additions & 34 deletions
This file was deleted.

grafana/manifests/deis-monitor-grafana-svc.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

grafana/rootfs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN apt-get update && \
1717
apt-get clean -y && \
1818
# package up license files if any by appending to existing tar
1919
COPYRIGHT_TAR='/usr/share/copyrights.tar'; \
20-
gunzip $COPYRIGHT_TAR.gz; tar -rf $COPYRIGHT_TAR /usr/share/doc/*/copyright; gzip $COPYRIGHT_TAR && \
20+
gunzip -f $COPYRIGHT_TAR.gz; tar -rf $COPYRIGHT_TAR /usr/share/doc/*/copyright; gzip $COPYRIGHT_TAR && \
2121
rm -rf \
2222
/usr/share/doc \
2323
/usr/share/man \

grafana/rootfs/usr/share/grafana/start-grafana

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then
3434
IFS=','
3535
for plugin in ${GF_INSTALL_PLUGINS}; do
3636
echo "Installing ${plugin} ..."
37-
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}
37+
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install "${plugin}"
3838
echo ""
3939
echo "Done installing ${plugin}"
4040
done
@@ -45,7 +45,7 @@ set -m
4545
echo "Starting Grafana in the background"
4646
exec /usr/sbin/grafana-server -config /usr/share/grafana/grafana.ini -homepath /usr/share/grafana &
4747
echo "Waiting for Grafana to come up..."
48-
until $(curl -q --fail --output /dev/null --silent http://${GRAFANA_USER}:${GRAFANA_PASSWD}@localhost:${GRAFANA_PORT}/api/org); do
48+
until curl -q --fail --output /dev/null --silent "http://${GRAFANA_USER}:${GRAFANA_PASSWD}@localhost:${GRAFANA_PORT}/api/org"; do
4949
printf "."
5050
sleep 2
5151
done

includes.mk

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: check-docker
2+
check-docker:
3+
@if [ -z $$(which docker) ]; then \
4+
echo "Missing \`docker\` client which is required for development"; \
5+
exit 2; \
6+
fi
7+
8+
.PHONY: check-kubectl
9+
check-kubectl:
10+
@if [ -z $$(which kubectl) ]; then \
11+
echo "Missing \`kubectl\` client which is required for development"; \
12+
exit 2; \
13+
fi

influxdb/Makefile

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
SHELL = /bin/bash
2-
3-
DOCKER_HOST = $(shell echo $$DOCKER_HOST)
4-
BUILD_TAG ?= git-$(shell git rev-parse --short HEAD)
51
SHORT_NAME ?= influxdb
6-
DEIS_REGISTRY ?= ${DEV_REGISTRY}
7-
IMAGE_PREFIX ?= deis
8-
9-
include versioning.mk
10-
11-
build: docker-build
12-
push: docker-push
13-
install: kube-install
14-
uninstall: kube-delete
15-
upgrade: kube-update
16-
17-
docker-build:
18-
docker build ${DOCKER_BUILD_FLAGS} -t ${IMAGE} rootfs
19-
docker tag ${IMAGE} ${MUTABLE_IMAGE}
20-
21-
clean: check-docker
22-
docker rmi $(IMAGE)
23-
24-
update-manifests:
25-
sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-monitor-influxdb-rc.yaml > manifests/deis-monitor-influxdb-rc.tmp.yaml
26-
27-
kube-install: update-manifests
28-
kubectl create -f manifests/deis-monitor-influxdb-api-svc.yaml
29-
kubectl create -f manifests/deis-monitor-influxdb-ui-svc.yaml
30-
kubectl create -f manifests/deis-monitor-influxdb-rc.tmp.yaml
31-
32-
kube-delete: update-manifests
33-
kubectl delete -f manifests/deis-monitor-influxdb-api-svc.yaml
34-
kubectl delete -f manifests/deis-monitor-influxdb-ui-svc.yaml
35-
kubectl delete -f manifests/deis-monitor-influxdb-rc.tmp.yaml
2+
RESOURCE_TYPE := deployment
3+
SHELL_SCRIPTS = rootfs/home/influxdb/start-influx
364

37-
kube-update: update-manifests
38-
kubectl delete -f manifests/deis-monitor-influxdb-rc.tmp.yaml
39-
kubectl create -f manifests/deis-monitor-influxdb-rc.tmp.yaml
5+
include ../default.mk

0 commit comments

Comments
 (0)