This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from rabbitmq/metrics-aggregation
Option to aggregate channel, queue and connection metrics (cherry picked from commit 82fafae)
- Loading branch information
Showing
33 changed files
with
1,427 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
eval "$(make autocomplete)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PATH_add bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/* | ||
*.pem | ||
_manifest.yaml | ||
.erlang.cookie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
SHELL := bash# we want bash behaviour in all shell invocations | ||
GCP_PROJECT := cf-rabbitmq-for-k8s-bunny | ||
GCLOUD_CONFIG := rmq-for-k8s | ||
GKE_CLUSTER := gerhard-2020-01-16 | ||
GKE_ZONE := europe-west2-b | ||
GKE_VERSION := 1.16 | ||
|
||
LOCAL_BIN := $(CURDIR)/bin | ||
PATH := $(LOCAL_BIN):$(PATH) | ||
export PATH | ||
|
||
.DEFAULT_GOAL := help | ||
.PHONY: help | ||
help: | ||
@awk -F"[:#]" '/^[^\.][a-zA-Z\._\-]+:+.+##.+$$/ { printf "\033[36m%-24s\033[0m %s\n", $$1, $$4 }' $(MAKEFILE_LIST) \ | ||
| sort | ||
|
||
define MAKE_TARGETS | ||
awk -F: '/^[^\.%\t][a-zA-Z\._\-]*:+.*$$/ { printf "%s\n", $$1 }' $(MAKEFILE_LIST) | ||
endef | ||
define BASH_AUTOCOMPLETE | ||
complete -W \"$$($(MAKE_TARGETS) | sort | uniq)\" make gmake m | ||
endef | ||
.PHONY: autocomplete | ||
autocomplete: | ||
@echo "$(BASH_AUTOCOMPLETE)" | ||
.PHONY: ac | ||
ac: autocomplete | ||
|
||
# Do not use kubectl installed by Docker for Desktop, this will typically be an older version than kubernetes-cli | ||
KUBECTL := $(lastword /usr/local/Cellar/kubernetes-cli/$(GKE_VERSION).0/bin/kubectl $(wildcard /usr/local/Cellar/kubernetes-cli/*/bin/kubectl)) | ||
$(KUBECTL): | ||
brew install kubernetes-cli | ||
bin/kubectl: $(KUBECTL) ## Setup kubectl CLI | ||
mkdir -p $(LOCAL_BIN) \ | ||
&& ln -sf $(KUBECTL) $(LOCAL_BIN)/kubectl | ||
|
||
HELM := /usr/local/opt/helm@2/bin/helm | ||
$(HELM): | ||
brew install helm@2 | ||
bin/helm: $(HELM) ## Setup helm CLI | ||
mkdir -p $(LOCAL_BIN) \ | ||
&& ln -sf $(HELM) $(LOCAL_BIN)/helm | ||
|
||
LPASS := /usr/local/bin/lpass | ||
$(LPASS): | ||
brew install lastpass-cli | ||
|
||
.PHONY: gcloud-login | ||
gcloud-login: ## Login gcloud CLI | ||
gcloud config configurations activate $(GCLOUD_CONFIG) \ | ||
|| gcloud config configurations create $(GCLOUD_CONFIG) | ||
gcloud auth login | ||
gcloud config set project $(GCP_PROJECT) | ||
|
||
.PHONY: gke-ls | ||
gke-ls: ## List GKE clusters | ||
gcloud container clusters list | ||
|
||
.PHONY: gke-connect | ||
gke-connect: ## Connect kubectl to GKE cluster | ||
gcloud container clusters get-credentials $(GKE_CLUSTER) --zone $(GKE_ZONE) | ||
|
||
.PHONY: gke-admin | ||
gke-admin: $(KUBECTL) | ||
$(KUBECTL) apply --filename config/cluster-admin.yaml | ||
|
||
.PHONY: haproxy | ||
haproxy: config/haproxy/dhparams.pem config/haproxy/ca.pem config/haproxy/bundle.pem $(HELM) $(KUBECTL) | ||
cd config/haproxy \ | ||
&& $(HELM) template . --name haproxy > _manifest.yaml \ | ||
&& $(KUBECTL) apply --filename _manifest.yaml | ||
|
||
.PHONY: haproxy-delete | ||
haproxy-delete: $(KUBECTL) | ||
$(KUBECTL) delete -f config/haproxy/_manifest.yaml | ||
|
||
config/haproxy/dhparams.pem: | ||
openssl dhparam -out $(@) 2048 | ||
|
||
# https://support.cloudflare.com/hc/en-us/articles/115000479507 | ||
config/haproxy/ca.pem: $(LPASS) | ||
$(LPASS) show --notes "Shared-RabbitMQ/cloudflare-origin-ca-rsa-root.pem" > $(@) | ||
|
||
config/haproxy/bundle.pem: $(LPASS) | ||
$(LPASS) show --notes "Shared-RabbitMQ/cloudflare-edge-bundle.pem" > $(@) | ||
|
||
.PHONY: cluster-admin-binding | ||
cluster-admin-binding: $(KUBECTL) | ||
$(KUBECTL) get --filename config/cluster-admin.yaml \ | ||
|| $(KUBECTL) apply --filename config/cluster-admin.yaml | ||
|
||
.PHONY: rabbitmq | ||
rabbitmq: cluster-admin-binding config/agentmq/.erlang.cookie $(HELM) $(KUBECTL) | ||
cd config/agentmq \ | ||
&& $(HELM) template . --name agentmq > _manifest.yaml \ | ||
&& $(KUBECTL) apply --filename _manifest.yaml | ||
|
||
.PHONY: rabbitmq-delete | ||
rabbitmq-delete: $(KUBECTL) | ||
$(KUBECTL) delete -f config/agentmq/_manifest.yaml | ||
|
||
.PHONY: rabbitmq-proxy | ||
rabbitmq-proxy: $(KUBECTL) | ||
$(KUBECTL) port-forward service/agentmq 15672:15672 15692:15692 | ||
|
||
config/agentmq/.erlang.cookie: | ||
echo -n "$$(openssl rand -hex 10)" > $(@) | ||
|
||
clean: haproxy-delete rabbitmq-delete | ||
|
||
LIMIT ?= 20 | ||
events: $(KUBECTL) | ||
$(KUBECTL) get events --sort-by='.metadata.creationTimestamp' | tail -n $(LIMIT) | ||
|
||
resources: $(KUBECTL) | ||
$(KUBECTL) get all -o wide | ||
$(KUBECTL) get secret | ||
$(KUBECTL) get configmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
appVersion: "1.0" | ||
description: A Helm chart for Kubernetes | ||
name: agentmq | ||
version: 0.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
## Agentmq | ||
|
||
* all commands are assumed to be running from the example directory | ||
|
||
All the main variables are in `values.yaml`. Changes should be made there. | ||
|
||
### Install | ||
|
||
Make sure we set the correct variables. The default values in `values.yaml` are for local. | ||
|
||
``` | ||
helm install --name agentmq --namespace default -f values.yaml ../agentmq --set environment=dev --set key1=value1 --set key2=value2 | ||
``` | ||
|
||
Check all the things. | ||
|
||
``` | ||
helm ls | ||
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE | ||
...omitted | ||
agentmq 1 Thu Aug 23 15:17:37 2018 DEPLOYED agentmq-0.1.0 1.0 default | ||
``` | ||
|
||
### Upgrading | ||
``` | ||
helm upgrade -f values.yaml agentmq ../agentmq | ||
``` | ||
|
||
### Delete chart | ||
|
||
``` | ||
helm delete agentmq --purge | ||
release "agentmq" deleted | ||
``` | ||
|
||
|
||
### Testing locally | ||
|
||
to test the template and install procedure without actually doing it. | ||
|
||
``` | ||
helm install --dry-run --debug ../agentmq --set key1=var1 | ||
``` | ||
|
||
To just see the template | ||
|
||
``` | ||
helm template -f values.yaml agentmq ../agentmq | ||
``` | ||
|
||
|
||
## Configuration | ||
|
||
The following table lists the configurable vales that can be used in a XXX-values.yaml file. If no value is specified, it will default to whatever is in the **values.yaml** | ||
|
||
|
||
|
||
Parameter | Description | Default | ||
--------- | ----------- | ------- | ||
`rabbitmqUsers` | list of rabbitmq users | `[]` | ||
`serviceAccountName` | service account name | `agentmq` | ||
`service.type` | Type of service to create [service](https://kubernetes.io/docs/concepts/services-networking/service/) | `NodePort` | ||
`service.name` | service name [service](https://kubernetes.io/docs/concepts/services-networking/service/) | `agentmq` | ||
`service.selector.name` | selector for service [service](https://kubernetes.io/docs/concepts/services-networking/service/) | `agentmq` | ||
`image.tag` | Image tag [image](https://kubernetes.io/docs/concepts/containers/images/) | `test` | ||
`image.repository` | Image repository [image](https://kubernetes.io/docs/concepts/containers/images/) | `automox/local/agentmq` | ||
`replicaCount` | replicas to make | `1` | ||
`containerPorts` | ports to expose on the container | `[]` | ||
`environment` | local,dev,stg,prod | `local` | ||
`serviceName` | name of agentmq service | `agentmq` | ||
`affinity` | Node affinity | `{}` | ||
`tolerations` | List of node taints to tolerate | `[]` | ||
`nodeSelector` | Node to select | `{}` | ||
`servicePorts` | service ports to expose | `[]` | ||
`resources` | CPU/Memory resource requests/limits | `{}` | ||
`name` | name of the pod/deployment | `agentmq` | ||
|
||
## Exporter | ||
|
||
A sidecar container is deployed that exports rabbitmq data for prometheus. | ||
|
||
For detailed instructions, [check out the exporter](https://github.com/PatchSimple/rabbitmq-exporter) | ||
|
||
It is mounted to /tmp/configs/config.yaml and _should_ be updated in real time. | ||
|
||
**NOTE:** if the port is changed, the pod **needs** to be restarted to take effect. Idk how to solve this but if you do feel free! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "agentmq.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "agentmq.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "agentmq.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
Oops, something went wrong.