Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: align to helm defaults #2

Merged
merged 5 commits into from
Oct 11, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/release-pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: tdemin/find-latest-tag@v1
id: app_version
with:
repo: https://${{ secrets.HELM_CHARTS_BOT }}@github.com/krateoplatformops/finops-operator-exporter.git
repo: https://${{ secrets.HELM_CHARTS_BOT }}@github.com/krateoplatformops/composition-watcher.git

- name: Print latest App Version
run: echo ${{ steps.app_version.outputs.tag }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: tdemin/find-latest-tag@v1
id: app_version
with:
repo: https://${{ secrets.HELM_CHARTS_BOT }}@github.com/krateoplatformops/finops-operator-exporter.git
repo: https://${{ secrets.HELM_CHARTS_BOT }}@github.com/krateoplatformops/composition-watcher.git

- name: Checkout
uses: actions/checkout@v3
Expand Down
20 changes: 10 additions & 10 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.name" -}}
{{- define "composition-watcher.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ 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 "chart.fullname" -}}
{{- define "composition-watcher.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "chart.chart" -}}
{{- define "composition-watcher.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "chart.labels" -}}
helm.sh/chart: {{ include "chart.chart" . }}
{{ include "chart.selectorLabels" . }}
{{- define "composition-watcher.labels" -}}
helm.sh/chart: {{ include "composition-watcher.chart" . }}
{{ include "composition-watcher.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
{{- define "composition-watcher.selectorLabels" -}}
app.kubernetes.io/name: {{ include "composition-watcher.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "chart.serviceAccountName" -}}
{{- define "composition-watcher.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
{{- default (include "composition-watcher.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
8 changes: 8 additions & 0 deletions chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "composition-watcher.fullname" . }}
labels:
{{- include "composition-watcher.labels" . | nindent 4 }}
data:
RESOURCE_TREE_HANDLER_URL: {{ .Values.env.RESOURCE_TREE_HANDLER_URL }}
123 changes: 39 additions & 84 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,99 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chart.fullname" . }}-controller-manager
name: {{ include "composition-watcher.fullname" . }}
labels:
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: composition-watcher
app.kubernetes.io/part-of: composition-watcher
control-plane: controller-manager
{{- include "chart.labels" . | nindent 4 }}
{{- include "composition-watcher.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.controllerManager.replicas }}
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 6 }}
{{- include "composition-watcher.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
control-plane: controller-manager
{{- include "chart.selectorLabels" . | nindent 8 }}
{{- with .Values.podAnnotations }}
annotations:
kubectl.kubernetes.io/default-container: manager
spec:
containers:
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=0
env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: "cluster.local"
image: {{ .Values.proxy.image.repository }}:{{ .Values.proxy.image.tag
| default .Chart.AppVersion }}
name: kube-rbac-proxy
imagePullPolicy: {{ .Values.proxy.imagePullPolicy }}
ports:
- containerPort: 8443
name: https
protocol: TCP
resources: {{- toYaml .Values.proxy.resources | nindent
10 }}
{{- with .Values.proxy.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 10 }}
{{- end }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
command:
- /manager
env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
- name: RECONCILE_REQUEUE_AFTER
value: {{ quote .Values.requeueAfter }}
image: {{ .Values.controllerManager.image.repository }}:{{ .Values.controllerManager.image.tag
| default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.controllerManager.imagePullPolicy }}
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
{{- with .Values.controllerManager.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 10 }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "composition-watcher.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
resources: {{- toYaml .Values.controllerManager.resources
| nindent 10 }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
imagePullSecrets: {{- toYaml .Values.imagePullSecrets
| nindent 6 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "composition-watcher.serviceAccountName" . }}
securityContext:
runAsNonRoot: true
serviceAccountName: {{ include "chart.fullname" . }}-controller-manager
terminationGracePeriodSeconds: 10
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "composition-watcher.fullname" . }}
envFrom:
- configMapRef:
name: {{ include "composition-watcher.fullname" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
Expand Down
20 changes: 10 additions & 10 deletions chart/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{{- if .Values.controllerManager.autoscaling.enabled }}
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "chart.fullname" . }}
name: {{ include "composition-watcher.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
{{- include "composition-watcher.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "chart.fullname" . }}
minReplicas: {{ .Values.controllerManager.autoscaling.minReplicas }}
maxReplicas: {{ .Values.controllerManager.autoscaling.maxReplicas }}
name: {{ include "composition-watcher.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.controllerManager.autoscaling.targetCPUUtilizationPercentage }}
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.controllerManager.autoscaling.targetCPUUtilizationPercentage }}
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.controllerManager.autoscaling.targetMemoryUtilizationPercentage }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.controllerManager.autoscaling.targetMemoryUtilizationPercentage }}
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
41 changes: 0 additions & 41 deletions chart/templates/role.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions chart/templates/rolebinding.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions chart/templates/service.yaml

This file was deleted.

14 changes: 8 additions & 6 deletions chart/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "chart.fullname" . }}-controller-manager
name: {{ include "composition-watcher.serviceAccountName" . }}
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: composition-watcher
app.kubernetes.io/part-of: composition-watcher
{{- include "chart.labels" . | nindent 4 }}
{{- include "composition-watcher.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading
Loading