From ead5151bd34330dbfd301cd6d93137e082144cac Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 18 Dec 2024 13:38:22 +1100 Subject: [PATCH] chore: update storage-calculator and adjust metrics endpoint --- charts/lagoon-remote/Chart.yaml | 2 + ...storage-calculator.clusterrolebinding.yaml | 16 ++++++++ .../storage-calculator.deployment.yaml | 7 ++-- .../templates/storage-calculator.role.yaml | 40 +++++++++++++++++++ .../storage-calculator.rolebinding.yaml | 8 ++-- .../templates/storage-calculator.service.yaml | 5 ++- .../storage-calculator.servicemonitor.yaml | 2 +- charts/lagoon-remote/values.yaml | 4 +- 8 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 charts/lagoon-remote/templates/storage-calculator.clusterrolebinding.yaml create mode 100644 charts/lagoon-remote/templates/storage-calculator.role.yaml diff --git a/charts/lagoon-remote/Chart.yaml b/charts/lagoon-remote/Chart.yaml index 239ba341a..b16bedcfe 100644 --- a/charts/lagoon-remote/Chart.yaml +++ b/charts/lagoon-remote/Chart.yaml @@ -46,3 +46,5 @@ annotations: description: daemonset to manage node sysctl changes - kind: changed description: update uselagoon/lagoon-ssh-portal/ssh-portal from v0.41.3 to v0.41.4 + - kind: changed + description: update storage-calculator to v0.7.0 and adjust metrics endpoint diff --git a/charts/lagoon-remote/templates/storage-calculator.clusterrolebinding.yaml b/charts/lagoon-remote/templates/storage-calculator.clusterrolebinding.yaml new file mode 100644 index 000000000..0ea9f30e6 --- /dev/null +++ b/charts/lagoon-remote/templates/storage-calculator.clusterrolebinding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.storageCalculator.enabled -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "lagoon-remote.storageCalculator.fullname" . }} + labels: + {{- include "lagoon-remote.storageCalculator.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "lagoon-remote.storageCalculator.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ include "lagoon-remote.storageCalculator.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/lagoon-remote/templates/storage-calculator.deployment.yaml b/charts/lagoon-remote/templates/storage-calculator.deployment.yaml index 49dcd6dfb..be6711971 100644 --- a/charts/lagoon-remote/templates/storage-calculator.deployment.yaml +++ b/charts/lagoon-remote/templates/storage-calculator.deployment.yaml @@ -35,14 +35,15 @@ spec: command: - /manager args: - - "--metrics-bind-address=0.0.0.0:8080" + - "--metrics-bind-address=:8443" + - "--leader-elect=true" - "--prometheus-metrics=true" {{- with .Values.storageCalculator.extraArgs }} {{- toYaml . | nindent 8 }} {{- end }} ports: - - name: metrics - containerPort: 8080 + - containerPort: 8443 + name: https env: {{- range $name, $value := .Values.storageCalculator.extraEnvs }} - name: {{ .name }} diff --git a/charts/lagoon-remote/templates/storage-calculator.role.yaml b/charts/lagoon-remote/templates/storage-calculator.role.yaml new file mode 100644 index 000000000..1fbf4b66f --- /dev/null +++ b/charts/lagoon-remote/templates/storage-calculator.role.yaml @@ -0,0 +1,40 @@ +{{- if .Values.storageCalculator.enabled -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "lagoon-remote.storageCalculator.fullname" . }}-leader-election + labels: + {{- include "lagoon-remote.storageCalculator.labels" . | nindent 4 }} +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +{{- end }} diff --git a/charts/lagoon-remote/templates/storage-calculator.rolebinding.yaml b/charts/lagoon-remote/templates/storage-calculator.rolebinding.yaml index 0ea9f30e6..9b156132a 100644 --- a/charts/lagoon-remote/templates/storage-calculator.rolebinding.yaml +++ b/charts/lagoon-remote/templates/storage-calculator.rolebinding.yaml @@ -1,14 +1,14 @@ {{- if .Values.storageCalculator.enabled -}} apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding +kind: RoleBinding metadata: - name: {{ include "lagoon-remote.storageCalculator.fullname" . }} + name: {{ include "lagoon-remote.storageCalculator.fullname" . }}-leader-election labels: {{- include "lagoon-remote.storageCalculator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ include "lagoon-remote.storageCalculator.fullname" . }} + kind: Role + name: {{ include "lagoon-remote.storageCalculator.fullname" . }}-leader-election subjects: - kind: ServiceAccount name: {{ include "lagoon-remote.storageCalculator.serviceAccountName" . }} diff --git a/charts/lagoon-remote/templates/storage-calculator.service.yaml b/charts/lagoon-remote/templates/storage-calculator.service.yaml index 8a73bfdf9..a2c5a02d7 100644 --- a/charts/lagoon-remote/templates/storage-calculator.service.yaml +++ b/charts/lagoon-remote/templates/storage-calculator.service.yaml @@ -10,8 +10,9 @@ spec: type: {{ .Values.storageCalculator.metricsService.type }} ports: - port: {{ .Values.storageCalculator.metricsService.ports.metrics }} - targetPort: metrics - name: metrics + targetPort: https + protocol: TCP + name: https selector: {{- include "lagoon-remote.storageCalculator.selectorLabels" . | nindent 4 }} {{- end }} diff --git a/charts/lagoon-remote/templates/storage-calculator.servicemonitor.yaml b/charts/lagoon-remote/templates/storage-calculator.servicemonitor.yaml index fc339b513..33b14443d 100644 --- a/charts/lagoon-remote/templates/storage-calculator.servicemonitor.yaml +++ b/charts/lagoon-remote/templates/storage-calculator.servicemonitor.yaml @@ -7,7 +7,7 @@ metadata: {{- include "lagoon-remote.storageCalculator.labels" . | nindent 4 }} spec: endpoints: - - port: metrics + - port: https namespaceSelector: matchNames: - {{ .Release.Namespace }} diff --git a/charts/lagoon-remote/values.yaml b/charts/lagoon-remote/values.yaml index 05b7f29eb..af7028ba0 100644 --- a/charts/lagoon-remote/values.yaml +++ b/charts/lagoon-remote/values.yaml @@ -439,7 +439,7 @@ storageCalculator: metricsService: type: ClusterIP ports: - metrics: 9912 + metrics: 8443 serviceMonitor: enabled: true @@ -448,7 +448,7 @@ storageCalculator: repository: uselagoon/remote-calculator pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: v0.6.0 + tag: v0.7.0 # sysctlConfigure is used to configure sysctl options on nodes for use by elasticsearch/opensearch pods used in lagoon # https://github.com/uselagoon/lagoon/issues/2588