Skip to content

Commit

Permalink
*: Add helm charts for configuring and deploying chargeback components
Browse files Browse the repository at this point in the history
  • Loading branch information
Chance Zibolski committed Dec 7, 2017
1 parent d3b4875 commit 31d519d
Show file tree
Hide file tree
Showing 50 changed files with 585 additions and 209 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ deepcopy-gen
client-gen
lister-gen
informer-gen
tectonic-chargeback-0.1.0.tgz
1 change: 1 addition & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*@neomake*
21 changes: 16 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ GO_BUILD_ARGS := -ldflags '-extldflags "-static"'

CHARGEBACK_ALM_INSTALL_IMAGE := quay.io/coreos/chargeback-alm-install
CHARGEBACK_IMAGE := quay.io/coreos/chargeback
HELM_OPERATOR_IMAGE := quay.io/coreos/helm-operator
HADOOP_IMAGE := quay.io/coreos/chargeback-hadoop
HIVE_IMAGE := quay.io/coreos/chargeback-hive
PRESTO_IMAGE := quay.io/coreos/chargeback-presto
CODEGEN_IMAGE := quay.io/coreosinc/chargeback-codegen

TARGETS := chargeback hadoop hive presto chargeback-alm-install
TARGETS := chargeback hadoop hive presto helm-operator chargeback-alm-install
DOCKER_BUILD_TARGETS := $(addsuffix -docker-build, $(TARGETS))
DOCKER_PUSH_TARGETS := $(addsuffix -docker-push, $(TARGETS))
DOCKER_IMAGE_TARGETS := $(CHARGEBACK_IMAGE) $(HADOOP_IMAGE) $(HIVE_IMAGE) $(PRESTO_IMAGE) $(CHARGEBACK_ALM_INSTALL_IMAGE)
Expand Down Expand Up @@ -118,8 +119,11 @@ dist.zip: dist
chargeback-docker-build: images/chargeback/Dockerfile images/chargeback/bin/chargeback
$(MAKE) docker-build DOCKERFILE=$< IMAGE_NAME=$(CHARGEBACK_IMAGE)

chargeback-alm-install-docker-build: images/chargeback-alm-install/Dockerfile
$(MAKE) docker-build DOCKERFILE=$< IMAGE_NAME=$(CHARGEBACK_ALM_INSTALL_IMAGE) DOCKER_BUILD_CONTEXT=.
chargeback-alm-install-docker-build: images/chargeback-alm-install/Dockerfile tectonic-chargeback-0.1.0.tgz helm-operator-docker-build
$(MAKE) docker-build DOCKERFILE=$< IMAGE_NAME=$(CHARGEBACK_ALM_INSTALL_IMAGE)

helm-operator-docker-build: images/helm-operator/Dockerfile
$(MAKE) docker-build DOCKERFILE=$< IMAGE_NAME=$(HELM_OPERATOR_IMAGE) USE_LATEST_TAG=true

presto-docker-build: images/presto/Dockerfile
$(MAKE) docker-build DOCKERFILE=$< IMAGE_NAME=$(PRESTO_IMAGE)
Expand All @@ -146,14 +150,21 @@ images/chargeback/bin/chargeback: $(CHARGEBACK_GO_FILES)
mkdir -p $(dir $@)
CGO_ENABLED=0 GOOS=linux go build $(GO_BUILD_ARGS) -o $@ $(CHARGEBACK_GO_PKG)

tectonic-chargeback-chart: tectonic-chargeback-0.1.0.tgz

tectonic-chargeback-0.1.0.tgz: $(shell find charts -type f)
helm dep update --skip-refresh charts/tectonic-chargeback
helm package --save=false -d images/chargeback-alm-install charts/tectonic-chargeback

.PHONY: \
vendor fmt regenerate-hive-thrift \
k8s-update-codegen k8s-verify-codegen \
chargeback-docker-build chargeback-alm-install-docker-build \
chargeback-docker-build \
helm-operator-docker-build chargeback-alm-install-docker-build \
hadoop-docker-build presto-docker-build hive-docker-build \
docker-build docker-tag docker-push \
docker-build-all docker-tag-all docker-push-all \
chargeback-bin
chargeback-bin tectonic-chargeback-chart

k8s-update-codegen: $(CODEGEN_OUTPUT_GO_FILES)
./hack/update-codegen.sh
Expand Down
21 changes: 21 additions & 0 deletions charts/chargeback-operator/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
4 changes: 4 additions & 0 deletions charts/chargeback-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: chargeback-operator
version: 0.1.0
18 changes: 18 additions & 0 deletions charts/chargeback-operator/templates/chargeback-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: chargeback-config
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
data:
aws-region: {{ .Values.config.awsRegion | quote}}
log-reports: {{ .Values.config.logReports | quote}}
log-ddl-queries: {{ .Values.config.logDDLQueries | quote}}
log-dml-queries: {{ .Values.config.logDMLQueries | quote}}
disable-promsum: {{ .Values.config.disablePromsum | quote}}
prometheus-url: {{ .Values.config.prometheusURL | quote}}
promsum-poll-interval: {{ .Values.config.promsumPollInterval | quote}}
promsum-chunk-size: {{ .Values.config.promsumChunkSize | quote}}
promsum-step-size: {{ .Values.config.promsumStepSize | quote}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: chargeback
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
spec:
template:
metadata:
labels:
app: chargeback
annotations:
chargeback-config-hash: {{ include (print $.Template.BasePath "/chargeback-config.yaml") . | sha256sum }}
chargeback-secrets-hash: {{ include (print $.Template.BasePath "/chargeback-secrets.yaml") . | sha256sum }}
spec:
containers:
- name: chargeback
image: quay.io/coreos/chargeback:0.4.5
imagePullPolicy: Always
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
Expand All @@ -23,12 +30,12 @@ spec:
secretKeyRef:
name: chargeback-secrets
key: aws-secret-access-key
- name: LOG__DML_QUERIES
- name: LOG_DML_QUERIES
valueFrom:
configMapKeyRef:
name: chargeback-config
key: log-dml-queries
- name: LOG__DDL_QUERIES
- name: LOG_DDL_QUERIES
valueFrom:
configMapKeyRef:
name: chargeback-config
Expand Down Expand Up @@ -64,9 +71,7 @@ spec:
name: chargeback-config
key: disable-promsum
resources:
requests:
memory: "50Mi"
cpu: "50m"
{{ toYaml .Values.resources | indent 10 }}
ports:
- name: "http"
containerPort: 8080
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: chargeback
name: chargeback-admin
rules:
- apiGroups: ["chargeback.coreos.com"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["*"]
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: chargeback
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: chargeback
name: chargeback-admin
subjects:
- kind: ServiceAccount
name: chargeback
Expand All @@ -26,3 +28,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: chargeback
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/chargeback-operator/templates/chargeback-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: chargeback-secrets
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
type: Opaque
data:
aws-access-key-id: {{ .Values.config.awsAccessKeyID | b64enc | quote}}
aws-secret-access-key: {{ .Values.config.awsSecretAccessKey | b64enc | quote}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ kind: Service
apiVersion: v1
metadata:
name: chargeback
labels:
app: chargeback
{{- block "extraMetadata" . }}
{{- end }}
spec:
selector:
app: chargeback
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.config.awsBillingDataSource.enabled -}}
apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportDataStore
metadata:
name: "aws-billing"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
awsBilling:
source:
bucket: {{ .Values.config.awsBillingDataSource.bucket | quote }}
path: {{ .Values.config.awsBillingDataSource.path | quote }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
name: "node-allocatable-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "node-allocatable-memory-bytes"
Expand All @@ -19,6 +21,8 @@ metadata:
name: "node-allocatable-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "node-allocatable-cpu-cores"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: "node-capacity-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "node-capacity-memory-bytes"
Expand All @@ -18,6 +20,8 @@ metadata:
name: "node-capacity-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "node-capacity-cpu-cores"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: "pod-request-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "pod-request-cpu-cores"
Expand All @@ -18,6 +20,8 @@ metadata:
name: "pod-limit-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "pod-limit-cpu-cores"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: "pod-request-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "pod-request-memory-bytes"
Expand All @@ -18,6 +20,8 @@ metadata:
name: "pod-limit-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
promsum:
query: "pod-limit-memory-bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "node-allocatable-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
kube_node_status_allocatable_memory_bytes * on(node) group_left(provider_id) kube_node_info
Expand All @@ -12,6 +16,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "node-allocatable-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
kube_node_status_allocatable_cpu_cores * on(node) group_left(provider_id) kube_node_info
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "node-capacity-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
kube_node_status_capacity_memory_bytes * on(node) group_left(provider_id) kube_node_info
Expand All @@ -12,6 +16,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "node-capacity-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
kube_node_status_capacity_cpu_cores * on(node) group_left(provider_id) kube_node_info
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "pod-request-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
sum(kube_pod_container_resource_requests_cpu_cores) by (pod, namespace, node) keep_common
Expand All @@ -12,6 +16,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "pod-limit-cpu-cores"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
sum(kube_pod_container_resource_limits_cpu_cores) by (pod, namespace, node) keep_common
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "pod-request-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
sum(kube_pod_container_resource_requests_memory_bytes) by (pod, namespace, node) keep_common
Expand All @@ -12,6 +16,10 @@ apiVersion: chargeback.coreos.com/v1alpha1
kind: ReportPrometheusQuery
metadata:
name: "pod-limit-memory-bytes"
labels:
tectonic-chargeback: "true"
{{- block "extraMetadata" . }}
{{- end }}
spec:
query: |
sum(kube_pod_container_resource_limits_memory_bytes) by (pod, namespace, node) keep_common
Loading

0 comments on commit 31d519d

Please sign in to comment.