Skip to content

Commit

Permalink
chore: adding tracetest-monitor-operator chart
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbdias committed Jul 17, 2024
1 parent 90ee231 commit 9a82cda
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 6 deletions.
23 changes: 23 additions & 0 deletions charts/tracetest-monitor-operator/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
30 changes: 30 additions & 0 deletions charts/tracetest-monitor-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v2
name: tracetest-monitor-operator
description: A Helm chart for Tracetest Cloud API

home: https://github.com/kubeshop/tracetest-cloud-charts

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: v1.4.3
dependencies:
- name: tracetest-common
version: v1.0.0
repository: file://../tracetest-common
51 changes: 51 additions & 0 deletions charts/tracetest-monitor-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "tracetest-monitor-operator.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 "tracetest-monitor-operator.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 "tracetest-monitor-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "tracetest-monitor-operator.labels" -}}
helm.sh/chart: {{ include "tracetest-monitor-operator.chart" . }}
{{ include "tracetest-monitor-operator.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "tracetest-monitor-operator.selectorLabels" -}}
app.kubernetes.io/name: {{ include "tracetest-monitor-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/tracetest-monitor-operator/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "tracetest-monitor-operator.fullname" . }}-config
labels:
{{- include "tracetest-monitor-operator.labels" . | nindent 4 }}
data:
TRACETEST_NATS_ENDPOINT: "{{ .Values.config.natsEndpoint }}"
TRACETEST_TARGET_NAMESPACE: "{{ .Values.config.targetNamespace }}"
TRACETEST_TARGET_SERVERURL: {{ include "tracetest-common.url" .Values.global.urls.web }}
TRACETEST_TRACING_COLLECTORENDPOINT: "collector-opentelemetry-collector.otel:4317"
56 changes: 56 additions & 0 deletions charts/tracetest-monitor-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "tracetest-monitor-operator.fullname" . }}
labels:
{{- include "tracetest-monitor-operator.labels" . | nindent 4 }}
spec:
# the numbers for replicas and max surge/unavailable are set to speed up deployments.
# The idea is that there is one "old" version running and one "new" version in parallel
# and once that works the old version is scaled down and the new version is scaled up.
# This timeline avoids the need to wait for new nodes to be started to satisfy requirements.
replicas: {{ .Values.deployment.replicas }}
strategy:
{{- toYaml .Values.deployment.strategy | nindent 4 }}

selector:
matchLabels:
{{- include "tracetest-monitor-operator.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "tracetest-monitor-operator.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "tracetest-monitor-operator.fullname" . }}
imagePullSecrets:
- name: {{ .Values.imagePullSecrets }}
containers:
- name: tracetestcloud
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
env:
- name: TRACETEST_NATS_ENDPOINT
valueFrom:
configMapKeyRef:
name: {{ include "tracetest-monitor-operator.fullname" . }}-config
key: TRACETEST_NATS_ENDPOINT
- name: TRACETEST_TARGET_NAMESPACE
valueFrom:
configMapKeyRef:
name: {{ include "tracetest-monitor-operator.fullname" . }}-config
key: TRACETEST_TARGET_NAMESPACE
- name: TRACETEST_TARGET_SERVERURL
valueFrom:
configMapKeyRef:
name: {{ include "tracetest-monitor-operator.fullname" . }}-config
key: TRACETEST_TARGET_SERVERURL
- name: TRACETEST_TRACING_COLLECTORENDPOINT
valueFrom:
configMapKeyRef:
name: {{ include "tracetest-monitor-operator.fullname" . }}-config
key: TRACETEST_TRACING_COLLECTORENDPOINT

imagePullPolicy: Always
resources:
{{- toYaml .Values.deployment.resources | nindent 12 }}
27 changes: 27 additions & 0 deletions charts/tracetest-monitor-operator/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "tracetest-monitor-operator.fullname" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "tracetest-monitor-operator.fullname" . }}
rules:
- apiGroups: ["batch"]
resources: ["cronjobs"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "tracetest-monitor-operator.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "tracetest-monitor-operator.fullname" . }}
namespace: {{.Release.Namespace}}
roleRef:
kind: ClusterRole
name: {{ include "tracetest-monitor-operator.fullname" . }}
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: "{{ .Values.config.targetNamespace }}"
labels:
{{- include "tracetest-monitor-operator.labels" . | nindent 4 }}
25 changes: 25 additions & 0 deletions charts/tracetest-monitor-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
config:
natsEndpoint: "nats://nats-headless.external:4222"
targetNamespace: monitors
targetServerUrl: "http://tracetest-cloud.tracetest-cloud:8090"

deployment:
replicas: 1

strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1

resources:
limits:
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi

image:
repository: ghcr.io/kubeshop/tracetest-monitor-operator
tag: v1.4.3

3 changes: 3 additions & 0 deletions charts/tracetest-onprem/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ dependencies:
- name: tracetest-agent-operator
version: v1.4.0
repository: file://../tracetest-agent-operator
- name: tracetest-monitor-operator
version: v1.0.0
repository: file://../tracetest-monitor-operator
- name: tracetest-auth
version: v1.11.0
repository: file://../tracetest-auth
Expand Down
15 changes: 9 additions & 6 deletions scripts/setup_kind_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ set -e
function show_help() {
echo "Usage: setup_kind_cluster.sh [OPTIONS]"
echo "Options:"
echo " --reset Reset the existing kind cluster"
echo " --private Use private repositories. Requires a PAT with read:packages scope."
echo " --help Show this help message"
echo " --reset Reset the existing kind cluster"
echo " --private Use private repositories. Requires a PAT with read:packages scope."
echo " --build-deps Build dependencies for all charts"
echo " --help Show this help message"
}

if [[ "$@" == *"--help"* ]]; then
Expand All @@ -22,12 +23,12 @@ ENV_FILE=$PROJECT_ROOT/cluster.env
SETUP_CLUSTER=false

if [[ "$@" == *"--reset"* ]]; then
printf "\e[41m\e[1mDeleting existing cluster\e[0m\e[0m\n"
printf "\n\e[41m\e[1mDeleting existing cluster\e[0m\e[0m\n"
kind delete cluster --name tracetest
fi

if ! kind get clusters | grep -q tracetest; then
printf "\e[42m\e[1mCreate new cluster\e[0m\e[0m\n"
printf "\n\e[42m\e[1mCreate new cluster\e[0m\e[0m\n"
SETUP_CLUSTER=true
kind create cluster \
--name tracetest \
Expand All @@ -46,7 +47,7 @@ source $ENV_FILE

if [[ "$SETUP_CLUSTER" == true ]]; then
if [[ "$@" == *"--private"* ]]; then
printf "\e[41mPrivate version requested. Please provide your credentials.\e[0m\n"
printf "\n\e[41mPrivate version requested. Please provide your credentials.\e[0m\n"

$PROJECT_ROOT/scripts/create_image_pull_secret.sh
fi
Expand All @@ -70,6 +71,8 @@ if [[ "$@" == *"--build-deps"* ]]; then
done
fi

echo "Starting Tracetest OnPrem installation on Kind"

helm upgrade --install ttdeps $PROJECT_ROOT/charts/tracetest-dependencies -f $PROJECT_ROOT/values-kind.yaml
helm upgrade --install tt $PROJECT_ROOT/charts/tracetest-onprem -f $PROJECT_ROOT/values-kind.yaml

Expand Down
7 changes: 7 additions & 0 deletions scripts/update_chart_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
echo "Add helm repositories"
echo ""

helm repo add traefik https://traefik.github.io/charts
helm repo add ory https://k8s.ory.sh/helm/charts
helm repo add jetstack https://charts.jetstack.io
helm repo add nats https://nats-io.github.io/k8s/helm/charts/

0 comments on commit 9a82cda

Please sign in to comment.