Skip to content

Commit

Permalink
feat(monitoring-proxy): added monitoring-proxy helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Tassatux committed Mar 14, 2024
1 parent 951137d commit f6f508b
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/monitoring-proxy/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions charts/monitoring-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: monitoring-proxy
description: Expose control-plane and kube-proxy metrics for monitoring, with auth when required
type: application
version: 0.1.0
62 changes: 62 additions & 0 deletions charts/monitoring-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "monitoring-proxy.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 "monitoring-proxy.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 "monitoring-proxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "monitoring-proxy.labels" -}}
helm.sh/chart: {{ include "monitoring-proxy.chart" . }}
{{ include "monitoring-proxy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "monitoring-proxy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "monitoring-proxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "monitoring-proxy.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "monitoring-proxy.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/monitoring-proxy/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.controlPlane.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "monitoring-proxy.fullname" . }}-haproxy
data:
haproxy.cfg: |
defaults
mode tcp
frontend kube-controller-manager
bind ${POD_IP}:{{ .Values.kubeControllerManager.port }}
default_backend kube-controller-manager
backend kube-controller-manager
server kube-controller-manager 127.0.0.1:{{ .Values.kubeControllerManager.port }}
frontend kube-scheduler
bind ${POD_IP}:{{ .Values.kubeScheduler.port }}
default_backend kube-scheduler
backend kube-scheduler
server kube-scheduler 127.0.0.1:{{ .Values.kubeScheduler.port }}
{{- end }}
80 changes: 80 additions & 0 deletions charts/monitoring-proxy/templates/cp-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if .Values.controlPlane.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "monitoring-proxy.fullname" . }}
labels:
{{- include "monitoring-proxy.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "monitoring-proxy.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "monitoring-proxy.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "monitoring-proxy.serviceAccountName" . }}
hostNetwork: true
volumes:
- name: config-haproxy
configMap:
name: {{ include "monitoring-proxy.fullname" . }}-haproxy
nodeSelector:
{{- toYaml .Values.controlPlane.nodeSelector | nindent 8 }}
tolerations:
{{- toYaml .Values.controlPlane.tolerations | nindent 8 }}
containers:
- name: haproxy
image: {{ .Values.haproxy.image.repository }}:{{ .Values.haproxy.image.tag }}
volumeMounts:
- name: config-haproxy
mountPath: /usr/local/etc/haproxy
readOnly: true
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
resources:
{{- toYaml .Values.haproxy.resources | nindent 12 }}
ports:
- containerPort: {{ .Values.kubeControllerManager.port }}
name: kube-c-m
- containerPort: {{ .Values.kubeScheduler.port }}
name: kube-scheduler
securityContext:
allowPrivilegeEscalation: false
- name: kube-rbac-proxy
image: {{ .Values.kubeRbacProxy.image.repository }}:{{ .Values.kubeRbacProxy.image.tag }}
args:
{{- if .Values.etcd.https }}
- "--secure-listen-address=$(POD_IP):{{ .Values.etcd.port }}"
{{- else }}
- "--insecure-listen-address=$(POD_IP):{{ .Values.etcd.port }}"
{{- end }}
- "--upstream={{ .Values.etcd.upstreamScheme }}://127.0.0.1:{{ .Values.etcd.port }}/"
- "--auth-header-fields-enabled"
- "--allow-paths=/metrics"
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
resources:
{{- toYaml .Values.kubeRbacProxy.resources | nindent 12 }}
ports:
- containerPort: {{ .Values.etcd.port }}
name: etcd
securityContext:
allowPrivilegeEscalation: false
{{- end }}
53 changes: 53 additions & 0 deletions charts/monitoring-proxy/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{- if .Values.kubeProxy.enabled }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "monitoring-proxy.fullname" . }}-kube-proxy
labels:
{{- include "monitoring-proxy.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "monitoring-proxy.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "monitoring-proxy.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "monitoring-proxy.serviceAccountName" . }}
hostNetwork: true
tolerations:
{{- toYaml .Values.kubeProxy.tolerations | nindent 8 }}
containers:
- name: kube-rbac-proxy
image: {{ .Values.kubeRbacProxy.image.repository }}:{{ .Values.kubeRbacProxy.image.tag }}
args:
{{- if .Values.kubeProxy.https }}
- "--secure-listen-address=$(POD_IP):{{ .Values.kubeProxy.port }}"
{{- else }}
- "--insecure-listen-address=$(POD_IP):{{ .Values.kubeProxy.port }}"
{{- end }}
- "--upstream={{ .Values.kubeProxy.upstreamScheme }}://127.0.0.1:{{ .Values.kubeProxy.port }}/"
- "--auth-header-fields-enabled"
- "--allow-paths=/metrics"
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
resources:
{{- toYaml .Values.kubeRbacProxy.resources | nindent 12 }}
ports:
- containerPort: {{ .Values.kubeProxy.port }}
name: kube-proxy
securityContext:
allowPrivilegeEscalation: false
{{- end }}
27 changes: 27 additions & 0 deletions charts/monitoring-proxy/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "monitoring-proxy.fullname" . }}
rules:
- apiGroups: ["authentication.k8s.io"]
resources:
- tokenreviews
verbs: ["create"]
- apiGroups: ["authorization.k8s.io"]
resources:
- subjectaccessreviews
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "monitoring-proxy.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "monitoring-proxy.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "monitoring-proxy.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
13 changes: 13 additions & 0 deletions charts/monitoring-proxy/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "monitoring-proxy.serviceAccountName" . }}
labels:
{{- include "monitoring-proxy.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
69 changes: 69 additions & 0 deletions charts/monitoring-proxy/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: true
automount: true
annotations: {}
name: ""

podAnnotations: {}
podLabels: {}

haproxy:
image:
repository: haproxy
tag: "2.9.6"
resources:
requests:
cpu: 1m
memory: 100Mi
limits:
cpu: 200m
memory: 256Mi

kubeRbacProxy:
image:
repository: quay.io/brancz/kube-rbac-proxy
tag: "v0.16.0"
resources:
requests:
cpu: 1m
memory: 10Mi
limits:
cpu: 200m
memory: 256Mi

controlPlane:
enabled: true
nodeSelector:
node-role.kubernetes.io/control-plane: ""
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule

etcd:
port: 2381
https: false
upstreamScheme: http
kubeControllerManager:
port: 10257
kubeScheduler:
port: 10259

kubeProxy:
enabled: true
port: 10249
https: false
upstreamScheme: http
tolerations:
- effect: NoSchedule
operator: Exists
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
operator: Exists

0 comments on commit f6f508b

Please sign in to comment.