Skip to content

Commit

Permalink
test argo/prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
pli01 committed Apr 2, 2024
1 parent bf25346 commit 7dd3cbe
Show file tree
Hide file tree
Showing 39 changed files with 938 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lint: repos
repos:
@helmfile -e $(HELMFILE_ENVIRONMENT) repos
template:
@helmfile -e $(HELMFILE_ENVIRONMENT) template
@helmfile -e $(HELMFILE_ENVIRONMENT) template --include-crds --include-needs --include-transitive-needs -q
diff:
@helmfile -e $(HELMFILE_ENVIRONMENT) diff
sync:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ A top-level helmfile directory, contains dependencies release files and director
All the yaml files under the specified directory are processed in the alphabetical order.
Each files defines an ordered list of releases to deploy.

- 01-core-apps.yaml: for core applications (example ingress, observability, cert-manager...)
- 01-core-apps.yaml: for core applications (example ingress,cert-manager, argocd...)
- 01-loki.yaml: logs aggregator
- 01-prometheus-stack.yaml: observability (grafana,prometheus)
- 01-promtail.yaml: logs shipping
- 02-sample-apps.yaml: other applications

#### bases
Expand Down
21 changes: 21 additions & 0 deletions charts/raw/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
6 changes: 6 additions & 0 deletions charts/raw/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
appVersion: 0.2.3
name: raw
home: https://github.com/helm/charts/blob/master/incubator/raw
description: A place for all the Kubernetes resources which don't already have a home.
version: 0.3.0
6 changes: 6 additions & 0 deletions charts/raw/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
approvers:
- josdotso
- mumoshu
reviewers:
- josdotso
- mumoshu
129 changes: 129 additions & 0 deletions charts/raw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# incubator/raw

The `incubator/raw` chart takes a list of Kubernetes resources and
merges each resource with a default `metadata.labels` map and installs
the result.

The Kubernetes resources can be "raw" ones defined under the `resources` key, or "templated" ones defined under the `templates` key.

Some use cases for this chart include Helm-based installation and
maintenance of resources of kinds:
- LimitRange
- PriorityClass
- Secret

## Usage

### Raw resources

#### STEP 1: Create a yaml file containing your raw resources.

```
# raw-priority-classes.yaml
resources:
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: common-critical
value: 100000000
globalDefault: false
description: "This priority class should only be used for critical priority common pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: common-high
value: 90000000
globalDefault: false
description: "This priority class should only be used for high priority common pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: common-medium
value: 80000000
globalDefault: false
description: "This priority class should only be used for medium priority common pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: common-low
value: 70000000
globalDefault: false
description: "This priority class should only be used for low priority common pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: app-critical
value: 100000
globalDefault: false
description: "This priority class should only be used for critical priority app pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: app-high
value: 90000
globalDefault: false
description: "This priority class should only be used for high priority app pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: app-medium
value: 80000
globalDefault: true
description: "This priority class should only be used for medium priority app pods."
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: app-low
value: 70000
globalDefault: false
description: "This priority class should only be used for low priority app pods."
```

#### STEP 2: Install your raw resources.

```
helm install --name raw-priority-classes incubator/raw -f raw-priority-classes.yaml
```

### Templated resources

#### STEP 1: Create a yaml file containing your templated resources.

```
# values.yaml
templates:
- |
apiVersion: v1
kind: Secret
metadata:
name: common-secret
stringData:
mykey: {{ .Values.mysecret }}
```

The yaml file containing `mysecret` should be encrypted with a tool like [helm-secrets](https://github.com/futuresimple/helm-secrets)

```
# secrets.yaml
mysecret: abc123
```

```
$ helm secrets enc secrets.yaml
```

#### STEP 2: Install your templated resources.

```
helm secrets install --name mysecret incubator/raw -f values.yaml -f secrets.yaml
```
8 changes: 8 additions & 0 deletions charts/raw/ci/resources-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resources:
- apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
name: common-critical
value: 100000000
globalDefault: false
description: "This priority class should only be used for critical priority common pods."
6 changes: 6 additions & 0 deletions charts/raw/ci/templates-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
templates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: raw
18 changes: 18 additions & 0 deletions charts/raw/ci/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resources:
- apiVersion: v1
kind: Secret
metadata:
name: common
stringData:
foo: bar

mysecret: abc134

templates:
- |
apiVersion: v1
kind: Secret
metadata:
name: common-secret
stringData:
mykey: "{{ .Values.mysecret }}"
Empty file added charts/raw/templates/NOTES.txt
Empty file.
45 changes: 45 additions & 0 deletions charts/raw/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "raw.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 "raw.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 "raw.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
raw.resource will create a resource template that can be
merged with each item in `.Values.resources`.
*/}}
{{- define "raw.resource" -}}
metadata:
labels:
app: {{ template "raw.name" . }}
chart: {{ template "raw.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/raw/templates/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- $template := fromYaml (include "raw.resource" .) -}}
{{- range .Values.resources }}
---
{{ toYaml (merge . $template) -}}
{{- end }}
{{- range $i, $t := .Values.templates }}
---
{{ toYaml (merge (tpl $t $ | fromYaml) $template) -}}
{{- end }}
80 changes: 80 additions & 0 deletions charts/raw/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
resources: []
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: common-critical
# value: 100000000
# globalDefault: false
# description: "This priority class should only be used for critical priority common pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: common-high
# value: 90000000
# globalDefault: false
# description: "This priority class should only be used for high priority common pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: common-medium
# value: 80000000
# globalDefault: false
# description: "This priority class should only be used for medium priority common pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: common-low
# value: 70000000
# globalDefault: false
# description: "This priority class should only be used for low priority common pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: app-critical
# value: 100000
# globalDefault: false
# description: "This priority class should only be used for critical priority app pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: app-high
# value: 90000
# globalDefault: false
# description: "This priority class should only be used for high priority app pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: app-medium
# value: 80000
# globalDefault: true
# description: "This priority class should only be used for medium priority app pods."
#
# - apiVersion: scheduling.k8s.io/v1beta1
# kind: PriorityClass
# metadata:
# name: app-low
# value: 70000
# globalDefault: false
# description: "This priority class should only be used for low priority app pods."

templates: []
# - |
# apiVersion: v1
# kind: ConfigMap
# metadata:
# name: raw
#
# - |
# apiVersion: v1
# kind: Secret
# metadata:
# name: common-secret
# stringData:
# mykey: {{ .Values.mysecret }}
11 changes: 11 additions & 0 deletions helmfile.d/01-loki.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
bases:
- bases/helmDefaults.yaml
- bases/environments.yaml

helmfiles:
- path: releases/loki/helmfile.yaml
values:
- {{ toYaml .Values | nindent 4 }}

missingFileHandler: Warn
11 changes: 11 additions & 0 deletions helmfile.d/01-prometheus-stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
bases:
- bases/helmDefaults.yaml
- bases/environments.yaml

helmfiles:
- path: releases/prometheus-stack/helmfile.yaml
values:
- {{ toYaml .Values | nindent 4 }}

missingFileHandler: Warn
11 changes: 11 additions & 0 deletions helmfile.d/01-promtail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
bases:
- bases/helmDefaults.yaml
- bases/environments.yaml

helmfiles:
- path: releases/promtail/helmfile.yaml
values:
- {{ toYaml .Values | nindent 4 }}

missingFileHandler: Warn
Loading

0 comments on commit 7dd3cbe

Please sign in to comment.