Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Add kubernetes support #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Run docker-compose
compose:
@docker-compose up -d docker-compose.yml

## Run minikube
minikube:
@bash -x scripts/minikube.sh

## Run haproxy
haproxy:
@bash -x scripts/haproxy.sh

## Run minikube & haproxy
run:
@bash -x scripts/run.sh

## Deploy k8s objects
deploy:
@bash -x scripts/deploy.sh

help:
@printf "Available targets:\n\n"
@awk '/^[a-zA-Z\-\_0-9%:\\]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = $$1; \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
gsub("\\\\", "", helpCommand); \
gsub(":+$$", "", helpCommand); \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u
@printf "\n"
10 changes: 10 additions & 0 deletions docker-containers/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM grafana/grafana
MAINTAINER Pedro César <[email protected]>

ADD conf/grafana.db /var/lib/grafana/grafana.db
ADD conf/home.json /usr/share/grafana/public/dashboards/home.json

ENV GF_SERVER_ROOT_URL http://localhost
ENV GF_SECURITY_ADMIN_PASSWORD admin
ENV GF_AUTH_ANONYMOUS_ENABLED true
ENTRYPOINT ["/run.sh"]
Binary file added docker-containers/grafana/grafana.db
Binary file not shown.
295 changes: 295 additions & 0 deletions docker-containers/grafana/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
{
"id": null,
"title": "Home",
"originalTitle": "Home",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": true,
"sharedCrosshair": false,
"rows": [
{
"collapse": false,
"editable": true,
"height": "100px",
"panels": [
{
"title": "Download",
"error": false,
"span": 12,
"editable": true,
"type": "graph",
"yaxes": [
{
"show": true,
"min": null,
"max": null,
"logBase": 1,
"format": "MBs"
},
{
"show": true,
"min": null,
"max": null,
"logBase": 1,
"format": "MBs"
}
],
"isNew": true,
"id": 1,
"datasource": "InfluxDB",
"renderer": "flot",
"x-axis": true,
"y-axis": true,
"y_formats": [
"MBs",
"MBs"
],
"grid": {
"leftLogBase": 1,
"leftMax": null,
"rightMax": null,
"leftMin": null,
"rightMin": null,
"rightLogBase": 1,
"threshold1": null,
"threshold2": null,
"threshold1Color": "rgba(216, 200, 27, 0.27)",
"threshold2Color": "rgba(234, 112, 112, 0.22)"
},
"lines": true,
"fill": 1,
"linewidth": 2,
"points": false,
"pointradius": 5,
"bars": false,
"stack": false,
"percentage": false,
"legend": {
"show": true,
"values": false,
"min": false,
"max": false,
"current": false,
"total": false,
"avg": false
},
"nullPointMode": "connected",
"steppedLine": false,
"tooltip": {
"value_type": "cumulative",
"shared": true
},
"timeFrom": null,
"timeShift": null,
"targets": [
{
"refId": "A",
"dsType": "influxdb",
"resultFormat": "time_series",
"tags": [],
"groupBy": [
{
"type": "time",
"params": [
"$interval"
]
},
{
"type": "fill",
"params": [
"null"
]
}
],
"select": [
[
{
"type": "field",
"params": [
"value"
]
},
{
"type": "mean",
"params": []
}
]
],
"alias": "Download",
"measurement": "download",
"query": "SELECT mean(\"value\") FROM \"download\" WHERE $timeFilter GROUP BY time($interval) fill(null)"
}
],
"aliasColors": {},
"seriesOverrides": [],
"links": [],
"height": "250px"
}
],
"title": "New row"
},
{
"height": "610px",
"panels": [
{
"title": "Upload",
"error": false,
"span": 12,
"editable": true,
"type": "graph",
"yaxes": [
{
"show": true,
"min": null,
"max": null,
"logBase": 1,
"format": "MBs"
},
{
"show": true,
"min": null,
"max": null,
"logBase": 1,
"format": "MBs"
}
],
"isNew": true,
"id": 2,
"datasource": "InfluxDB",
"renderer": "flot",
"x-axis": true,
"y-axis": true,
"y_formats": [
"MBs",
"MBs"
],
"grid": {
"leftLogBase": 1,
"leftMax": null,
"rightMax": null,
"leftMin": null,
"rightMin": null,
"rightLogBase": 1,
"threshold1": null,
"threshold2": null,
"threshold1Color": "rgba(216, 200, 27, 0.27)",
"threshold2Color": "rgba(234, 112, 112, 0.22)"
},
"lines": true,
"fill": 1,
"linewidth": 2,
"points": false,
"pointradius": 5,
"bars": false,
"stack": false,
"percentage": false,
"legend": {
"show": true,
"values": false,
"min": false,
"max": false,
"current": false,
"total": false,
"avg": false
},
"nullPointMode": "connected",
"steppedLine": false,
"tooltip": {
"value_type": "cumulative",
"shared": true
},
"timeFrom": null,
"timeShift": null,
"targets": [
{
"refId": "A",
"dsType": "influxdb",
"resultFormat": "time_series",
"tags": [],
"groupBy": [
{
"type": "time",
"params": [
"$interval"
]
},
{
"type": "fill",
"params": [
"null"
]
}
],
"select": [
[
{
"type": "field",
"params": [
"value"
]
},
{
"type": "mean",
"params": []
}
]
],
"alias": "Upload",
"measurement": "upload",
"query": "SELECT mean(\"value\") FROM \"upload\" WHERE $timeFilter GROUP BY time($interval) fill(null)"
}
],
"aliasColors": {},
"seriesOverrides": [],
"links": [],
"height": "250px"
}
],
"title": "Row",
"collapse": false,
"editable": true
}
],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"enable": false,
"type": "timepicker",
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
],
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"schemaVersion": 8,
"version": 5,
"links": []
}
48 changes: 48 additions & 0 deletions docker-containers/grafana/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash -e

: "${GF_PATHS_DATA:=/var/lib/grafana}"
: "${GF_PATHS_LOGS:=/var/log/grafana}"
: "${GF_PATHS_PLUGINS:=/var/lib/grafana/plugins}"

chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_LOGS"
chown -R grafana:grafana /etc/grafana

if [ ! -z ${GF_AWS_PROFILES+x} ]; then
mkdir -p ~grafana/.aws/
touch ~grafana/.aws/credentials

for profile in ${GF_AWS_PROFILES}; do
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID"
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY"
region_varname="GF_AWS_${profile}_REGION"

if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then
echo "[${profile}]" >> ~grafana/.aws/credentials
echo "aws_access_key_id = ${!access_key_varname}" >> ~grafana/.aws/credentials
echo "aws_secret_access_key = ${!secret_key_varname}" >> ~grafana/.aws/credentials
if [ ! -z "${!region_varname}" ]; then
echo "region = ${!region_varname}" >> ~grafana/.aws/credentials
fi
fi
done

chown grafana:grafana -R ~grafana/.aws
chmod 600 ~grafana/.aws/credentials
fi

if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then
OLDIFS=$IFS
IFS=','
for plugin in ${GF_INSTALL_PLUGINS}; do
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}
done
IFS=$OLDIFS
fi

exec gosu grafana /usr/sbin/grafana-server \
--homepath=/usr/share/grafana \
--config=/etc/grafana/grafana.ini \
cfg:default.paths.data="$GF_PATHS_DATA" \
cfg:default.paths.logs="$GF_PATHS_LOGS" \
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \
"$@"
Empty file.
Loading