Skip to content

Commit ea96c5b

Browse files
make charts
Signed-off-by: Alexandre Lamarre <[email protected]>
1 parent 8867eb3 commit ea96c5b

File tree

582 files changed

+105308
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+105308
-0
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
annotations:
2+
catalog.cattle.io/certified: rancher
3+
catalog.cattle.io/hidden: "true"
4+
catalog.cattle.io/namespace: cattle-monitoring-system
5+
catalog.cattle.io/release-name: rancher-monitoring-crd
6+
apiVersion: v2
7+
description: Installs the CRDs for rancher-monitoring.
8+
name: rancher-monitoring-crd
9+
type: application
10+
version: 103.2.2-rc.1+up57.0.3
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# rancher-monitoring-crd
2+
A Rancher chart that installs the CRDs used by rancher-monitoring.
3+
4+
## How does this chart work?
5+
6+
This chart marshalls all of the CRD files placed in the `crd-manifest` directory into a ConfigMap that is installed onto a cluster alongside relevant RBAC (ServiceAccount, ClusterRoleBinding, ClusterRole, and PodSecurityPolicy).
7+
8+
Once the relevant dependent resourcees are installed / upgraded / rolled back, this chart executes a post-install / post-upgrade / post-rollback Job that:
9+
- Patches any existing versions of the CRDs contained within the `crd-manifest` on the cluster to set `spec.preserveUnknownFields=false`; this step is required since, based on [Kubernetes docs](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-pruning) and a [known workaround](https://github.com/kubernetes-sigs/controller-tools/issues/476#issuecomment-691519936), such CRDs cannot be upgraded normally from `apiextensions.k8s.io/v1beta1` to `apiextensions.k8s.io/v1`.
10+
- Runs a `kubectl apply` on the CRDs that are contained within the crd-manifest ConfigMap to upgrade CRDs in the cluster
11+
12+
On an uninstall, this chart executes a separate post-delete Job that:
13+
- Patches any existing versions of the CRDs contained within `crd-manifest` on the cluster to set `metadata.finalizers=[]`
14+
- Runs a `kubectl delete` on the CRDs that are contained within the crd-manifest ConfigMap to clean up the CRDs from the cluster
15+
16+
Note: If the relevant CRDs already existed in the cluster at the time of install, this chart will absorb ownership of the lifecycle of those CRDs; therefore, on a `helm uninstall`, those CRDs will also be removed from the cluster alongside this chart.
17+
18+
## Why can't we just place the CRDs in the templates/ directory of the main chart?
19+
20+
In Helm today, you cannot declare a CRD and declare a resource of that CRD's kind in templates/ without encountering a failure on render.
21+
22+
## [Helm 3] Why can't we just place the CRDs in the crds/ directory of the main chart?
23+
24+
The Helm 3 `crds/` directory only supports the installation of CRDs, but does not support the upgrade and removal of CRDs, unlike what this chart facilitiates.
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Rancher
2+
3+
{{- define "system_default_registry" -}}
4+
{{- if .Values.global.cattle.systemDefaultRegistry -}}
5+
{{- printf "%s/" .Values.global.cattle.systemDefaultRegistry -}}
6+
{{- end -}}
7+
{{- end -}}
8+
9+
# Windows Support
10+
11+
{{/*
12+
Windows cluster will add default taint for linux nodes,
13+
add below linux tolerations to workloads could be scheduled to those linux nodes
14+
*/}}
15+
16+
{{- define "linux-node-tolerations" -}}
17+
- key: "cattle.io/os"
18+
value: "linux"
19+
effect: "NoSchedule"
20+
operator: "Equal"
21+
{{- end -}}
22+
23+
{{- define "linux-node-selector" -}}
24+
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
25+
beta.kubernetes.io/os: linux
26+
{{- else -}}
27+
kubernetes.io/os: linux
28+
{{- end -}}
29+
{{- end -}}
30+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: {{ .Chart.Name }}-create
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app: {{ .Chart.Name }}
8+
annotations:
9+
"helm.sh/hook": post-install, post-upgrade, post-rollback
10+
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
11+
spec:
12+
template:
13+
metadata:
14+
name: {{ .Chart.Name }}-create
15+
labels:
16+
app: {{ .Chart.Name }}
17+
spec:
18+
serviceAccountName: {{ .Chart.Name }}-manager
19+
securityContext:
20+
runAsNonRoot: false
21+
runAsUser: 0
22+
containers:
23+
- name: create-crds
24+
image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
25+
imagePullPolicy: IfNotPresent
26+
command:
27+
- /bin/sh
28+
- -c
29+
- >
30+
echo "Applying CRDs...";
31+
mkdir -p /etc/crd;
32+
base64 -d /etc/config/crd-manifest.tgz.b64 | tar -xzv -C /etc/crd;
33+
kubectl replace -Rf /etc/crd || kubectl create -Rf /etc/crd;
34+
echo "Done!"
35+
volumeMounts:
36+
- name: crd-manifest
37+
readOnly: true
38+
mountPath: /etc/config
39+
restartPolicy: OnFailure
40+
nodeSelector: {{ include "linux-node-selector" . | nindent 8 }}
41+
{{- if .Values.nodeSelector }}
42+
{{- toYaml .Values.nodeSelector | nindent 8 }}
43+
{{- end }}
44+
tolerations: {{ include "linux-node-tolerations" . | nindent 8 }}
45+
{{- if .Values.tolerations }}
46+
{{- toYaml .Values.tolerations | nindent 8 }}
47+
{{- end }}
48+
volumes:
49+
- name: crd-manifest
50+
configMap:
51+
name: {{ .Chart.Name }}-manifest
52+
---
53+
apiVersion: batch/v1
54+
kind: Job
55+
metadata:
56+
name: {{ .Chart.Name }}-delete
57+
namespace: {{ .Release.Namespace }}
58+
labels:
59+
app: {{ .Chart.Name }}
60+
annotations:
61+
"helm.sh/hook": pre-delete
62+
"helm.sh/hook-delete-policy": before-hook-creation, hook-succeeded, hook-failed
63+
spec:
64+
template:
65+
metadata:
66+
name: {{ .Chart.Name }}-delete
67+
labels:
68+
app: {{ .Chart.Name }}
69+
spec:
70+
serviceAccountName: {{ .Chart.Name }}-manager
71+
securityContext:
72+
runAsNonRoot: false
73+
runAsUser: 0
74+
containers:
75+
- name: delete-crds
76+
image: {{ template "system_default_registry" . }}{{ .Values.image.repository }}:{{ .Values.image.tag }}
77+
imagePullPolicy: IfNotPresent
78+
command:
79+
- /bin/sh
80+
- -c
81+
- >
82+
echo "Deleting CRDs...";
83+
mkdir -p /etc/crd;
84+
base64 -d /etc/config/crd-manifest.tgz.b64 | tar -xzv -C /etc/crd;
85+
kubectl delete --ignore-not-found=true -Rf /etc/crd;
86+
volumeMounts:
87+
- name: crd-manifest
88+
readOnly: true
89+
mountPath: /etc/config
90+
restartPolicy: OnFailure
91+
nodeSelector: {{ include "linux-node-selector" . | nindent 8 }}
92+
{{- if .Values.nodeSelector }}
93+
{{- toYaml .Values.nodeSelector | nindent 8 }}
94+
{{- end }}
95+
tolerations: {{ include "linux-node-tolerations" . | nindent 8 }}
96+
{{- if .Values.tolerations }}
97+
{{- toYaml .Values.tolerations | nindent 8 }}
98+
{{- end }}
99+
volumes:
100+
- name: crd-manifest
101+
configMap:
102+
name: {{ .Chart.Name }}-manifest
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ .Chart.Name }}-manifest
5+
namespace: {{ .Release.Namespace }}
6+
data:
7+
crd-manifest.tgz.b64:
8+
{{- .Files.Get "files/crd-manifest.tgz" | b64enc | indent 4 }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: {{ .Chart.Name }}-manager
5+
labels:
6+
app: {{ .Chart.Name }}-manager
7+
rules:
8+
- apiGroups:
9+
- apiextensions.k8s.io
10+
resources:
11+
- customresourcedefinitions
12+
verbs: ['create', 'get', 'patch', 'delete', 'update', 'list']
13+
{{- if .Values.global.cattle.psp.enabled }}
14+
- apiGroups: ['policy']
15+
resources: ['podsecuritypolicies']
16+
verbs: ['use']
17+
resourceNames:
18+
- {{ .Chart.Name }}-manager
19+
{{- end }}
20+
---
21+
apiVersion: rbac.authorization.k8s.io/v1
22+
kind: ClusterRoleBinding
23+
metadata:
24+
name: {{ .Chart.Name }}-manager
25+
labels:
26+
app: {{ .Chart.Name }}-manager
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: ClusterRole
30+
name: {{ .Chart.Name }}-manager
31+
subjects:
32+
- kind: ServiceAccount
33+
name: {{ .Chart.Name }}-manager
34+
namespace: {{ .Release.Namespace }}
35+
---
36+
apiVersion: v1
37+
kind: ServiceAccount
38+
metadata:
39+
name: {{ .Chart.Name }}-manager
40+
namespace: {{ .Release.Namespace }}
41+
labels:
42+
app: {{ .Chart.Name }}-manager
43+
---
44+
{{- if .Values.global.cattle.psp.enabled }}
45+
apiVersion: policy/v1beta1
46+
kind: PodSecurityPolicy
47+
metadata:
48+
name: {{ .Chart.Name }}-manager
49+
namespace: {{ .Release.Namespace }}
50+
labels:
51+
app: {{ .Chart.Name }}-manager
52+
spec:
53+
privileged: false
54+
allowPrivilegeEscalation: false
55+
hostNetwork: false
56+
hostIPC: false
57+
hostPID: false
58+
runAsUser:
59+
rule: 'RunAsAny'
60+
seLinux:
61+
rule: 'RunAsAny'
62+
supplementalGroups:
63+
rule: 'MustRunAs'
64+
ranges:
65+
- min: 1
66+
max: 65535
67+
fsGroup:
68+
rule: 'MustRunAs'
69+
ranges:
70+
- min: 1
71+
max: 65535
72+
readOnlyRootFilesystem: false
73+
volumes:
74+
- 'configMap'
75+
- 'secret'
76+
{{- end }}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#{{- if gt (len (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "")) 0 -}}
2+
#{{- if .Values.global.cattle.psp.enabled }}
3+
#{{- if not (.Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy") }}
4+
#{{- fail "The target cluster does not have the PodSecurityPolicy API resource. Please disable PSPs in this chart before proceeding." -}}
5+
#{{- end }}
6+
#{{- end }}
7+
#{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Default values for rancher-monitoring-crd.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
global:
6+
cattle:
7+
psp:
8+
enabled: false
9+
systemDefaultRegistry: ""
10+
11+
image:
12+
repository: rancher/shell
13+
tag: v0.2.1
14+
15+
nodeSelector: {}
16+
17+
tolerations: []
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[files/dashboards/*.json]
4+
indent_size = 2
5+
indent_style = space
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
# helm/charts
23+
OWNERS
24+
hack/
25+
ci/
26+
kube-prometheus-*.tgz
27+
28+
unittests/
29+
files/dashboards/

0 commit comments

Comments
 (0)