Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
knmsk committed Mar 11, 2023
1 parent 3908d7b commit ab944cd
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 75 deletions.
10 changes: 7 additions & 3 deletions charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Helm chart to install the k6 operator

| Name | Email | Url |
| ---- | ------ | --- |
| yorugac | [email protected] | |
| yorugac | <[email protected]> | |

## Source Code

Expand All @@ -24,6 +24,7 @@ Kubernetes: `>=1.16.0-0`

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity to be applied on all containers |
| authProxy.enabled | bool | `true` | enables the protection of /metrics endpoint. (https://github.com/brancz/kube-rbac-proxy) |
| authProxy.image.name | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | rbac-proxy image name |
| authProxy.image.pullPolicy | string | `"IfNotPresent"` | pull policy for the image can be Always, Never, IfNotPresent (default: IfNotPresent) |
Expand All @@ -45,9 +46,12 @@ Kubernetes: `>=1.16.0-0`
| manager.resources.limits.memory | string | `"100Mi"` | controller-manager Memory limit (Max) |
| manager.resources.requests.cpu | string | `"100m"` | controller-manager CPU request (Min) |
| manager.resources.requests.memory | string | `"50Mi"` | controller-manager Memory request (Min) |
| manager.serviceAccount | string | `"k6-operator-controller"` | kubernetes service account for the manager |
| manager.serviceAccount.create | bool | `true` | create the service account (default: true) |
| manager.serviceAccount.name | string | `"k6-operator-controller"` | kubernetes service account for the k6 manager |
| namespace.create | bool | `true` | create the namespace (default: true) |
| nodeSelector | object | `{}` | Node Selector to be applied on all containers |
| prometheus.enabled | bool | `false` | enables the prometheus metrics scraping (default: false) |
| tolerations | object | `{}` | Tolerations to be applied on all containers |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
27 changes: 27 additions & 0 deletions charts/samples/customAnnotationsAndLabels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,33 @@ customLabels:
certManager:
enabled: true

nodeSelector:
disktype: ssd

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value

tolerations:
- key: "key1"
operator: "Exists"
effect: "NoSchedule"

authProxy:
resources:
limits:
Expand Down
78 changes: 72 additions & 6 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,88 @@
{{- define "operator.labels" -}}
{{/*
Expand the name of the chart.
*/}}
{{- define "k6-operator.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 "k6-operator.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 "k6-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "k6-operator.serviceAccountName" -}}
{{- if .Values.manager.serviceAccount.create }}
{{- default (include "k6-operator.fullname" .) .Values.manager.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.manager.serviceAccount.name }}
{{- end }}
{{- end }}


{{- define "k6-operator.customLabels" -}}
{{- if .Values.customLabels }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- toYaml . }}
{{- end }}
{{- else}}
{{ print "{}" }}
{{- end }}
{{- end -}}

{{- define "operator.annotations" -}}
{{- define "k6-operator.customAnnotations" -}}
{{- if .Values.customAnnotations }}
{{- with .Values.customAnnotations }}
{{- toYaml . }}
{{- end }}
{{- end }}
{{- end -}}

{{- define "operator.namespace" -}}
{{- define "k6-operator.namespace" -}}
{{- if eq .Release.Namespace "default" }}
{{- printf "%v-system" .Release.Name | indent 1 }}
{{- else }}
Expand All @@ -25,14 +91,14 @@
{{- end -}}


{{- define "operator.livenessProbe" -}}
{{- define "k6-operator.livenessProbe" -}}
{{- if .Values.authProxy.livenessProbe }}
livenessProbe:
{{- toYaml .Values.authProxy.livenessProbe | nindent 12 }}
{{- end }}
{{- end -}}

{{- define "operator.readinessProbe" -}}
{{- define "k6-operator.readinessProbe" -}}
{{- if .Values.authProxy.readinessProbe }}
readinessProbe:
{{- toYaml .Values.authProxy.readinessProbe | nindent 12 }}
Expand Down
23 changes: 13 additions & 10 deletions charts/templates/clusterRole.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: {{ .Release.Name }}-manager-role
name: {{ include "k6-operator.fullname" . }}-manager-role
labels:
{{- include "operator.labels" . }}
app.kubernetes.io/component: controller
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "{}" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "{}" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "{}" | nindent 4 }}
rules:
- apiGroups:
- apps
Expand Down Expand Up @@ -87,11 +88,12 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-metrics-reader
name: {{ include "k6-operator.fullname" . }}-metrics-reader
labels:
{{- include "operator.labels" . }}
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "" | nindent 4 }}
rules:
- nonResourceURLs:
- /metrics
Expand All @@ -101,11 +103,12 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-proxy-role
name: {{ include "k6-operator.fullname" . }}-proxy-role
labels:
{{- include "operator.labels" . }}
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "{}" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "{}" | nindent 4 }}
rules:
- apiGroups:
- authentication.k8s.io
Expand Down
26 changes: 14 additions & 12 deletions charts/templates/clusterRoleBinding.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-manager-rolebinding
name: {{ include "k6-operator.fullname" . }}-manager-rolebinding
labels:
{{- include "operator.labels" . }}
app.kubernetes.io/component: controller
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "{}" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "" | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-manager-role
name: {{ include "k6-operator.fullname" . }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ .Values.manager.serviceAccount }}
namespace: {{- include "operator.namespace" . -}}
name: {{- include "k6-operator.serviceAccountName" . -}}
namespace: {{- include "k6-operator.namespace" . -}}
{{- if .Values.authProxy.enabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-proxy-rolebinding
name: {{ include "k6-operator.fullname" . }}-proxy-rolebinding
labels:
{{- include "operator.labels" . }}
{{- include "k6-operator.customLabels" . }}
annotations:
{{- include "operator.annotations" . | default "" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "" | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-proxy-role
name: {{ include "k6-operator.fullname" . }}-proxy-role
subjects:
- kind: ServiceAccount
name: {{ .Values.manager.serviceAccount }}
namespace: {{- include "operator.namespace" . -}}
name: {{- include "k6-operator.serviceAccountName" . -}}
namespace: {{- include "k6-operator.namespace" . -}}
{{- end }}
7 changes: 4 additions & 3 deletions charts/templates/crds/k6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
{{- include "operator.labels" . }}
app.kubernetes.io/component: controller
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | nindent 4 }}
annotations:
{{- include "operator.annotations" . | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | nindent 4 }}
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: k6s.k6.io
spec:
group: k6.io
Expand Down
32 changes: 22 additions & 10 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-controller-manager
namespace: {{- include "operator.namespace" . }}
name: {{ include "k6-operator.fullname" . }}-controller-manager
namespace: {{- include "k6-operator.namespace" . }}
labels:
control-plane: {{ .Values.controlPlane }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
app.kubernetes.io/component: controller
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "{}" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "{}" | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
control-plane: {{ .Values.controlPlane }}
{{- include "k6-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
control-plane: {{ .Values.controlPlane }}
{{- include "k6-operator.selectorLabels" . | nindent 8 }}
spec:
containers:
{{- if .Values.authProxy.enabled }}
Expand All @@ -42,7 +42,7 @@ spec:
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=10
{{- include "operator.readinessProbe" . }}
{{- include "k6-operator.readinessProbe" . }}
ports:
- containerPort: 8443
name: https
Expand Down Expand Up @@ -73,5 +73,17 @@ spec:
{{- if .Values.authProxy.enabled }}
- --metrics-addr=127.0.0.1:8080
{{- end }}
serviceAccount: {{ .Values.manager.serviceAccount }}
serviceAccount: {{ include "k6-operator.serviceAccountName" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 10
6 changes: 3 additions & 3 deletions charts/templates/namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Release.Name }}-system
name: {{ include "k6-operator.fullname" . }}-system
labels:
app.kubernetes.io/name: {{ .Release.Name }}
app.kubernetes.io/name: {{ include "k6-operator.fullname" . }}
control-plane: {{ .Values.controlPlane }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- include "operator.annotations" . | default "{}" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "{}" | nindent 4 }}
{{- end }}
9 changes: 5 additions & 4 deletions charts/templates/prometheus/serviceMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ kind: ServiceMonitor
metadata:
labels:
control-plane: {{ .Values.controlPlane }}
{{- with .Values.customLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
namespace: {{- include "k6-operator.namespace" . }}
app.kubernetes.io/component: monitoring
{{- include "k6-operator.labels" . | nindent 4 }}
{{- include "k6-operator.customLabels" . | default "{}" | nindent 4 }}
annotations:
{{- include "operator.annotations" . | default "{}" | nindent 4 }}
{{- include "k6-operator.customAnnotations" . | default "{}" | nindent 4 }}
name: controller-manager-metrics-monitor
namespace: system
spec:
Expand Down
Loading

0 comments on commit ab944cd

Please sign in to comment.