Skip to content

Commit 8d44703

Browse files
committed
make charts PACKAGE=rancher-monitoring
1 parent 7fe69e2 commit 8d44703

16 files changed

+1014
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ $(TARGETS):
3131
@./scripts/pull-scripts
3232
@./bin/charts-build-scripts $@
3333

34-
.PHONY: $(TARGETS)
34+
.PHONY: $(TARGETS)
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
annotations:
2+
catalog.cattle.io/certified: rancher
3+
catalog.cattle.io/display-name: Prometheus Federator
4+
catalog.cattle.io/kube-version: '>= 1.28.0-0 < 1.32.0-0'
5+
catalog.cattle.io/namespace: cattle-monitoring-system
6+
catalog.cattle.io/os: linux,windows
7+
catalog.cattle.io/permits-os: linux,windows
8+
catalog.cattle.io/provides-gvr: helm.cattle.io.projecthelmchart/v1alpha1
9+
catalog.cattle.io/rancher-version: '>= 2.10.0-0 < 2.11.0-0'
10+
catalog.cattle.io/release-name: prometheus-federator
11+
apiVersion: v2
12+
appVersion: v2.0.0-rc.2
13+
description: Prometheus Federator - installs rancher-project-monitoring in project
14+
namespaces.
15+
icon: file://assets/logos/prometheus-federator.svg
16+
keywords:
17+
- prometheus
18+
- monitoring
19+
- project-monitoring
20+
maintainers:
21+
22+
name: Alexandre
23+
24+
name: Dan
25+
26+
name: Julia
27+
name: prometheus-federator
28+
version: 105.2.0+up2.0.0-rc.2

charts/prometheus-federator/105.2.0+up2.0.0-rc.2/README.md

Lines changed: 120 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Prometheus Federator
2+
3+
This chart deploys an operator that manages Project Monitoring Stacks composed of the following set of resources that are scoped to project namespaces:
4+
- [Prometheus](https://prometheus.io/) (managed externally by [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator))
5+
- [Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/) (managed externally by [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator))
6+
- [Grafana](https://github.com/helm/charts/tree/master/stable/grafana) (deployed via an embedded Helm chart)
7+
- Default PrometheusRules and Grafana dashboards based on the collection of community-curated resources from [kube-prometheus](https://github.com/prometheus-operator/kube-prometheus/)
8+
- Default ServiceMonitors that watch the deployed Prometheus, Grafana, and Alertmanager
9+
10+
Since this Project Monitoring Stack deploys Prometheus Operator CRs, an existing Prometheus Operator instance must already be deployed in the cluster for Prometheus Federator to successfully be able to deploy Project Monitoring Stacks. It is recommended to use [`rancher-monitoring`](https://rancher.com/docs/rancher/v2.6/en/monitoring-alerting/) for this. For more information on how the chart works or advanced configurations, please read the `README.md`.
11+
12+
## Upgrading to Kubernetes v1.25+
13+
14+
Starting in Kubernetes v1.25, [Pod Security Policies](https://kubernetes.io/docs/concepts/security/pod-security-policy/) have been removed from the Kubernetes API.
15+
16+
As a result, **before upgrading to Kubernetes v1.25** (or on a fresh install in a Kubernetes v1.25+ cluster), users are expected to perform an in-place upgrade of this chart with `global.cattle.psp.enabled` set to `false` if it has been previously set to `true`.
17+
18+
> **Note:**
19+
> In this chart release, any previous field that was associated with any PSP resources have been removed in favor of a single global field: `global.cattle.psp.enabled`.
20+
21+
> **Note:**
22+
> If you upgrade your cluster to Kubernetes v1.25+ before removing PSPs via a `helm upgrade` (even if you manually clean up resources), **it will leave the Helm release in a broken state within the cluster such that further Helm operations will not work (`helm uninstall`, `helm upgrade`, etc.).**
23+
>
24+
> If your charts get stuck in this state, please consult the Rancher docs on how to clean up your Helm release secrets.
25+
Upon setting `global.cattle.psp.enabled` to false, the chart will remove any PSP resources deployed on its behalf from the cluster. This is the default setting for this chart.
26+
27+
As a replacement for PSPs, [Pod Security Admission](https://kubernetes.io/docs/concepts/security/pod-security-admission/) should be used. Please consult the Rancher docs for more details on how to configure your chart release namespaces to work with the new Pod Security Admission and apply Pod Security Standards.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
questions:
2+
- variable: global.cattle.psp.enabled
3+
default: "false"
4+
description: "Flag to enable or disable the installation of PodSecurityPolicies by this chart in the target cluster. If the cluster is running Kubernetes 1.25+, you must update this value to false."
5+
label: "Enable PodSecurityPolicies"
6+
type: boolean
7+
group: "Security Settings"
8+
- variable: helmProjectOperator.helmController.enabled
9+
label: Enable Embedded Helm Controller
10+
description: 'Note: If you are running Prometheus Federator in an RKE2 / K3s cluster before v1.23.14 / v1.24.8 / v1.25.4, this should be disabled.'
11+
type: boolean
12+
group: Helm Controller
13+
- variable: helmProjectOperator.helmLocker.enabled
14+
label: Enable Embedded Helm Locker
15+
type: boolean
16+
group: Helm Locker
17+
- variable: helmProjectOperator.projectReleaseNamespaces.labelValue
18+
label: Project Release Namespace Project ID
19+
description: By default, the System Project is selected. This can be overriden to a different Project (e.g. p-xxxxx)
20+
type: string
21+
required: false
22+
group: Namespaces
23+
- variable: helmProjectOperator.releaseRoleBindings.clusterRoleRefs.admin
24+
label: Admin ClusterRole
25+
description: By default, admin selects Project Owners. This can be overridden to a different ClusterRole (e.g. rt-xxxxx)
26+
type: string
27+
default: admin
28+
required: false
29+
group: RBAC
30+
- variable: helmProjectOperator.releaseRoleBindings.clusterRoleRefs.edit
31+
label: Edit ClusterRole
32+
description: By default, edit selects Project Members. This can be overridden to a different ClusterRole (e.g. rt-xxxxx)
33+
type: string
34+
default: edit
35+
required: false
36+
group: RBAC
37+
- variable: helmProjectOperator.releaseRoleBindings.clusterRoleRefs.view
38+
label: View ClusterRole
39+
description: By default, view selects Read-Only users. This can be overridden to a different ClusterRole (e.g. rt-xxxxx)
40+
type: string
41+
default: view
42+
required: false
43+
group: RBAC
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ $.Chart.Name }} has been installed. Check its status by running:
2+
kubectl --namespace {{ template "prometheus-federator.namespace" . }} get pods -l "release={{ $.Release.Name }}"
3+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Rancher
2+
{{- define "system_default_registry" -}}
3+
{{- if .Values.global.cattle.systemDefaultRegistry -}}
4+
{{- printf "%s/" .Values.global.cattle.systemDefaultRegistry -}}
5+
{{- end -}}
6+
{{- end -}}
7+
8+
{{/* Define the image registry to use; either values, or systemdefault if set, or nothing */}}
9+
{{- define "prometheus-federator.imageRegistry" -}}
10+
{{- if and .Values.image .Values.image.registry }}{{- printf "%s/" .Values.image.registry -}}
11+
{{- else if .Values.helmProjectOperator.image.registry }}{{- printf "%s/" .Values.helmProjectOperator.image.registry -}}
12+
{{- else }}{{ template "system_default_registry" . }}
13+
{{- end }}
14+
{{- end }}
15+
16+
{{- define "prometheus-federator.imageRepository" -}}
17+
{{- if and .Values.image .Values.image.repository }}{{ .Values.image.repository }}
18+
{{- else if .Values.helmProjectOperator.image.repository }}{{ .Values.helmProjectOperator.image.repository }}
19+
{{- end }}
20+
{{- end }}
21+
22+
{{- define "prometheus-federator.imageTag" -}}
23+
{{- if and .Values.image .Values.image.tag -}}{{- .Values.image.tag -}}
24+
{{- else if and .Values.helmProjectOperator.image.tag -}}{{- .Values.helmProjectOperator.image.tag -}}
25+
{{- else -}}{{- .Chart.AppVersion -}}
26+
{{- end -}}
27+
{{- end -}}
28+
29+
# Windows Support
30+
31+
{{/*
32+
Windows cluster will add default taint for linux nodes,
33+
add below linux tolerations to workloads could be scheduled to those linux nodes
34+
*/}}
35+
36+
{{- define "linux-node-tolerations" -}}
37+
- key: "cattle.io/os"
38+
value: "linux"
39+
effect: "NoSchedule"
40+
operator: "Equal"
41+
{{- end -}}
42+
43+
{{- define "linux-node-selector" -}}
44+
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
45+
beta.kubernetes.io/os: linux
46+
{{- else -}}
47+
kubernetes.io/os: linux
48+
{{- end -}}
49+
{{- end -}}
50+
51+
# Helm Project Operator
52+
53+
{{/* vim: set filetype=mustache: */}}
54+
{{/* Expand the name of the chart. This is suffixed with -alertmanager, which means subtract 13 from longest 63 available */}}
55+
{{- define "prometheus-federator.name" -}}
56+
{{- default .Chart.Name (default .Values.helmProjectOperator.nameOverride .Values.nameOverride) | trunc 50 | trimSuffix "-" -}}
57+
{{- end }}
58+
59+
{{/*
60+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
61+
*/}}
62+
{{- define "prometheus-federator.namespace" -}}
63+
{{- if .Values.namespaceOverride -}}
64+
{{- .Values.namespaceOverride -}}
65+
{{- else if .Values.helmProjectOperator.namespaceOverride -}}
66+
{{- .Values.helmProjectOperator.namespaceOverride -}}
67+
{{- else -}}
68+
{{- .Release.Namespace -}}
69+
{{- end -}}
70+
{{- end -}}
71+
72+
{{/* Create chart name and version as used by the chart label. */}}
73+
{{- define "prometheus-federator.chartref" -}}
74+
{{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}}
75+
{{- end }}
76+
77+
{{/* Generate basic labels */}}
78+
{{- define "prometheus-federator.labels" }}
79+
app.kubernetes.io/managed-by: {{ .Release.Service }}
80+
app.kubernetes.io/instance: {{ .Release.Name }}
81+
app.kubernetes.io/version: "{{ replace "+" "_" .Chart.Version }}"
82+
app.kubernetes.io/part-of: {{ template "prometheus-federator.name" . }}
83+
chart: {{ template "prometheus-federator.chartref" . }}
84+
release: {{ $.Release.Name | quote }}
85+
heritage: {{ $.Release.Service | quote }}
86+
{{- if .Values.commonLabels}}
87+
{{ toYaml .Values.commonLabels }}
88+
{{- end }}
89+
{{- end }}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: {{ template "prometheus-federator.name" . }}-cleanup
5+
namespace: {{ template "prometheus-federator.namespace" . }}
6+
labels: {{ include "prometheus-federator.labels" . | indent 4 }}
7+
app: {{ template "prometheus-federator.name" . }}
8+
annotations:
9+
"helm.sh/hook": pre-delete
10+
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
11+
spec:
12+
template:
13+
metadata:
14+
name: {{ template "prometheus-federator.name" . }}-cleanup
15+
labels: {{ include "prometheus-federator.labels" . | indent 8 }}
16+
app: {{ template "prometheus-federator.name" . }}
17+
spec:
18+
serviceAccountName: {{ template "prometheus-federator.name" . }}
19+
{{- if .Values.helmProjectOperator.cleanup.securityContext }}
20+
securityContext: {{ toYaml .Values.helmProjectOperator.cleanup.securityContext | nindent 8 }}
21+
{{- end }}
22+
initContainers:
23+
- name: add-cleanup-annotations
24+
image: {{ template "system_default_registry" . }}{{ .Values.helmProjectOperator.cleanup.image.repository }}:{{ .Values.helmProjectOperator.cleanup.image.tag }}
25+
imagePullPolicy: "{{ .Values.helmProjectOperator.image.pullPolicy }}"
26+
command:
27+
- /bin/sh
28+
- -c
29+
- >
30+
echo "Labeling all ProjectHelmCharts with helm.cattle.io/helm-project-operator-cleanup=true";
31+
EXPECTED_HELM_API_VERSION={{ .Values.helmProjectOperator.helmApiVersion }};
32+
IFS=$'\n';
33+
for namespace in $(kubectl get namespaces -l helm.cattle.io/helm-project-operated=true --no-headers -o=custom-columns=NAME:.metadata.name); do
34+
for projectHelmChartAndHelmApiVersion in $(kubectl get projecthelmcharts -n ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name,HELMAPIVERSION:.spec.helmApiVersion); do
35+
projectHelmChartAndHelmApiVersion=$(echo ${projectHelmChartAndHelmApiVersion} | xargs);
36+
projectHelmChart=$(echo ${projectHelmChartAndHelmApiVersion} | cut -d' ' -f1);
37+
helmApiVersion=$(echo ${projectHelmChartAndHelmApiVersion} | cut -d' ' -f2);
38+
if [[ ${helmApiVersion} != ${EXPECTED_HELM_API_VERSION} ]]; then
39+
echo "Skipping marking ${namespace}/${projectHelmChart} with cleanup annotation since spec.helmApiVersion: ${helmApiVersion} is not ${EXPECTED_HELM_API_VERSION}";
40+
continue;
41+
fi;
42+
kubectl label projecthelmcharts -n ${namespace} ${projectHelmChart} helm.cattle.io/helm-project-operator-cleanup=true --overwrite;
43+
done;
44+
done;
45+
{{- if .Values.helmProjectOperator.cleanup.resources }}
46+
resources: {{ toYaml .Values.helmProjectOperator.cleanup.resources | nindent 12 }}
47+
{{- end }}
48+
{{- if .Values.helmProjectOperator.cleanup.containerSecurityContext }}
49+
securityContext: {{ toYaml .Values.helmProjectOperator.cleanup.containerSecurityContext | nindent 12 }}
50+
{{- end }}
51+
containers:
52+
- name: ensure-subresources-deleted
53+
image: {{ template "system_default_registry" . }}{{ .Values.helmProjectOperator.cleanup.image.repository }}:{{ .Values.helmProjectOperator.cleanup.image.tag }}
54+
imagePullPolicy: IfNotPresent
55+
command:
56+
- /bin/sh
57+
- -c
58+
- |
59+
echo "Checking if HelmCharts and HelmReleases CRDs exist...";
60+
CRD_HELMCHARTS=$(kubectl get crd helmcharts.helm.cattle.io --ignore-not-found)
61+
CRD_HELMRELEASES=$(kubectl get crd helmreleases.helm.cattle.io --ignore-not-found)
62+
if [ -z "$CRD_HELMCHARTS" ] && [ -z "$CRD_HELMRELEASES" ]; then
63+
echo "Neither HelmCharts nor HelmReleases CRDs exist in cluster, nothing to clean.";
64+
exit 0;
65+
fi
66+
RESOURCE_LIST=""
67+
if [ -n "$CRD_HELMCHARTS" ]; then
68+
RESOURCE_LIST="helmcharts"
69+
fi
70+
if [ -n "$CRD_HELMRELEASES" ]; then
71+
if [ -n "$RESOURCE_LIST" ]; then
72+
RESOURCE_LIST="$RESOURCE_LIST,"
73+
fi
74+
RESOURCE_LIST="${RESOURCE_LIST}helmreleases"
75+
fi
76+
SYSTEM_NAMESPACE={{ .Release.Namespace }}
77+
EXPECTED_HELM_API_VERSION={{ .Values.helmProjectOperator.helmApiVersion }};
78+
HELM_API_VERSION_TRUNCATED=$(echo ${EXPECTED_HELM_API_VERSION} | cut -d'/' -f0);
79+
echo "Ensuring HelmCharts and HelmReleases are deleted from ${SYSTEM_NAMESPACE}...";
80+
while [[ "$(kubectl get ${RESOURCE_LIST} -l helm.cattle.io/helm-api-version=${HELM_API_VERSION_TRUNCATED} -n ${SYSTEM_NAMESPACE} 2>&1)" != "No resources found in ${SYSTEM_NAMESPACE} namespace." ]]; do
81+
echo "waiting for HelmCharts and HelmReleases to be deleted from ${SYSTEM_NAMESPACE}... sleeping 3 seconds";
82+
sleep 3;
83+
done;
84+
echo "Successfully deleted all HelmCharts and HelmReleases in ${SYSTEM_NAMESPACE}!";
85+
{{- if .Values.helmProjectOperator.cleanup.resources }}
86+
resources: {{ toYaml .Values.helmProjectOperator.cleanup.resources | nindent 12 }}
87+
{{- end }}
88+
{{- if .Values.helmProjectOperator.cleanup.containerSecurityContext }}
89+
securityContext: {{ toYaml .Values.helmProjectOperator.cleanup.containerSecurityContext | nindent 12 }}
90+
{{- end }}
91+
restartPolicy: OnFailure
92+
nodeSelector: {{ include "linux-node-selector" . | nindent 8 }}
93+
{{- if .Values.helmProjectOperator.cleanup.nodeSelector }}
94+
{{- toYaml .Values.helmProjectOperator.cleanup.nodeSelector | nindent 8 }}
95+
{{- end }}
96+
tolerations: {{ include "linux-node-tolerations" . | nindent 8 }}
97+
{{- if .Values.helmProjectOperator.cleanup.tolerations }}
98+
{{- toYaml .Values.helmProjectOperator.cleanup.tolerations | nindent 8 }}
99+
{{- end }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{{- if and .Values.global.rbac.create .Values.global.rbac.userRoles.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ template "prometheus-federator.name" . }}-admin
6+
labels: {{ include "prometheus-federator.labels" . | indent 4 }}
7+
{{- if .Values.global.rbac.userRoles.aggregateToDefaultRoles }}
8+
rbac.authorization.k8s.io/aggregate-to-admin: "true"
9+
{{- end }}
10+
rules:
11+
- apiGroups:
12+
- helm.cattle.io
13+
resources:
14+
- projecthelmcharts
15+
- projecthelmcharts/finalizers
16+
- projecthelmcharts/status
17+
verbs:
18+
- '*'
19+
---
20+
apiVersion: rbac.authorization.k8s.io/v1
21+
kind: ClusterRole
22+
metadata:
23+
name: {{ template "prometheus-federator.name" . }}-edit
24+
labels: {{ include "prometheus-federator.labels" . | indent 4 }}
25+
{{- if .Values.global.rbac.userRoles.aggregateToDefaultRoles }}
26+
rbac.authorization.k8s.io/aggregate-to-edit: "true"
27+
{{- end }}
28+
rules:
29+
- apiGroups:
30+
- helm.cattle.io
31+
resources:
32+
- projecthelmcharts
33+
- projecthelmcharts/status
34+
verbs:
35+
- 'get'
36+
- 'list'
37+
- 'watch'
38+
---
39+
apiVersion: rbac.authorization.k8s.io/v1
40+
kind: ClusterRole
41+
metadata:
42+
name: {{ template "prometheus-federator.name" . }}-view
43+
labels: {{ include "prometheus-federator.labels" . | indent 4 }}
44+
{{- if .Values.global.rbac.userRoles.aggregateToDefaultRoles }}
45+
rbac.authorization.k8s.io/aggregate-to-view: "true"
46+
{{- end }}
47+
rules:
48+
- apiGroups:
49+
- helm.cattle.io
50+
resources:
51+
- projecthelmcharts
52+
- projecthelmcharts/status
53+
verbs:
54+
- 'get'
55+
- 'list'
56+
- 'watch'
57+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Note: If you add another entry to this ConfigMap, make sure a corresponding env var is set
2+
## in the deployment of the operator to ensure that a Helm upgrade will force the operator
3+
## to reload the values in the ConfigMap and redeploy
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: {{ template "prometheus-federator.name" . }}-config
8+
namespace: {{ template "prometheus-federator.namespace" . }}
9+
labels: {{ include "prometheus-federator.labels" . | indent 4 }}
10+
data:
11+
hardened.yaml: |-
12+
{{ .Values.helmProjectOperator.hardenedNamespaces.configuration | toYaml | indent 4 }}
13+
values.yaml: |-
14+
{{ .Values.helmProjectOperator.valuesOverride | toYaml | indent 4 }}

0 commit comments

Comments
 (0)