Skip to content

Commit

Permalink
Rename motel to kof
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlexx committed Jan 6, 2025
1 parent 3eda42c commit c5e3e27
Show file tree
Hide file tree
Showing 127 changed files with 131 additions and 126 deletions.
79 changes: 40 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ REGISTRY_IS_OCI = $(shell echo $(REGISTRY_REPO) | grep -q oci && echo true || ec

TEMPLATE_FOLDERS = $(patsubst $(TEMPLATES_DIR)/%,%,$(wildcard $(TEMPLATES_DIR)/*))

COLLECTORS_VERSION=$(shell $(YQ) '.version' $(TEMPLATES_DIR)/motel-collectors/Chart.yaml)
STORAGE_VERSION=$(shell $(YQ) '.version' $(TEMPLATES_DIR)/motel-storage/Chart.yaml)
COLLECTORS_VERSION=$(shell $(YQ) '.version' $(TEMPLATES_DIR)/kof-collectors/Chart.yaml)
STORAGE_VERSION=$(shell $(YQ) '.version' $(TEMPLATES_DIR)/kof-storage/Chart.yaml)
USER_EMAIL=$(shell git config user.email)

STORAGE_DOMAIN = $(USER)-storage.$(MOTEL_DNS)
MOTEL_STORAGE_NAME = motel-storage
MOTEL_STORAGE_NS = motel
STORAGE_DOMAIN = $(USER)-storage.$(KOF_DNS)
KOF_STORAGE_NAME = kof-storage
KOF_STORAGE_NG = kof

dev:
mkdir -p dev
Expand All @@ -42,6 +42,7 @@ package-chart-%: lint-chart-%

.PHONY: helm-package
helm-package: $(CHARTS_PACKAGE_DIR) $(EXTENSION_CHARTS_PACKAGE_DIR)
rm -rf $(CHARTS_PACKAGE_DIR)
@make $(patsubst %,package-chart-%,$(TEMPLATE_FOLDERS))

.PHONY: helm-push
Expand Down Expand Up @@ -78,66 +79,66 @@ helm-push: helm-package
done

.PHONY: dev-operators-deploy
dev-operators-deploy: dev ## Deploy motel-operators helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/motel-operators/values.yaml dev/operators-values.yaml
$(HELM) upgrade -i motel-operators ./charts/motel-operators --create-namespace -n motel -f dev/operators-values.yaml
dev-operators-deploy: dev ## Deploy kof-operators helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/kof-operators/values.yaml dev/operators-values.yaml
$(HELM) upgrade -i kof-operators ./charts/kof-operators --create-namespace -n kof -f dev/operators-values.yaml

.PHONY: dev-collectors-deploy
dev-collectors-deploy: dev ## Deploy motel-collector helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/motel-collectors/values.yaml dev/collectors-values.yaml
@$(YQ) eval -i '.motel.logs.endpoint = "http://$(MOTEL_STORAGE_NAME)-victoria-logs-single-server.$(MOTEL_STORAGE_NS):9428/insert/opentelemetry/v1/logs"' dev/collectors-values.yaml
@$(YQ) eval -i '.motel.metrics.endpoint = "http://vminsert-cluster.$(MOTEL_STORAGE_NS):8480/insert/0/prometheus/api/v1/write"' dev/collectors-values.yaml
@$(YQ) eval -i '.opencost.opencost.prometheus.external.url = "http://vmselect-cluster.$(MOTEL_STORAGE_NS):8481/select/0/prometheus"' dev/collectors-values.yaml
$(HELM) upgrade -i motel-collectors ./charts/motel-collectors --create-namespace -n motel -f dev/collectors-values.yaml
dev-collectors-deploy: dev ## Deploy kof-collector helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/kof-collectors/values.yaml dev/collectors-values.yaml
@$(YQ) eval -i '.kof.logs.endpoint = "http://$(KOF_STORAGE_NAME)-victoria-logs-single-server.$(KOF_STORAGE_NG):9428/insert/opentelemetry/v1/logs"' dev/collectors-values.yaml
@$(YQ) eval -i '.kof.metrics.endpoint = "http://vminsert-cluster.$(KOF_STORAGE_NG):8480/insert/0/prometheus/api/v1/write"' dev/collectors-values.yaml
@$(YQ) eval -i '.opencost.opencost.prometheus.external.url = "http://vmselect-cluster.$(KOF_STORAGE_NG):8481/select/0/prometheus"' dev/collectors-values.yaml
$(HELM) upgrade -i kof-collectors ./charts/kof-collectors --create-namespace -n kof -f dev/collectors-values.yaml

.PHONY: dev-storage-deploy
dev-storage-deploy: dev ## Deploy motel-storage helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/motel-storage/values.yaml dev/storage-values.yaml
dev-storage-deploy: dev ## Deploy kof-storage helm chart to the K8s cluster specified in ~/.kube/config
cp -f $(TEMPLATES_DIR)/kof-storage/values.yaml dev/storage-values.yaml
@$(YQ) eval -i '.grafana.ingress.enabled = false' dev/storage-values.yaml
@$(YQ) eval -i '.victoriametrics.vmcluster.replicaCount = 1' dev/storage-values.yaml
@$(YQ) eval -i '.global.storageClass = "standard"' dev/storage-values.yaml
@$(YQ) eval -i '.["victoria-logs-single"].server.persistentVolume.storageClassName = "standard"' dev/storage-values.yaml
$(HELM) upgrade -i $(MOTEL_STORAGE_NAME) ./charts/motel-storage --create-namespace -n $(MOTEL_STORAGE_NS) -f dev/storage-values.yaml
$(HELM) upgrade -i $(KOF_STORAGE_NAME) ./charts/kof-storage --create-namespace -n $(KOF_STORAGE_NG) -f dev/storage-values.yaml

.PHONY: dev-ms-deploy-aws
dev-ms-deploy-aws: dev ## Deploy Mothership helm chart to the K8s cluster specified in ~/.kube/config for a remote storage cluster
cp -f $(TEMPLATES_DIR)/motel-mothership/values.yaml dev/mothership-values.yaml
@$(YQ) eval -i '.hmc.installTemplates = true' dev/mothership-values.yaml
cp -f $(TEMPLATES_DIR)/kof-mothership/values.yaml dev/mothership-values.yaml
@$(YQ) eval -i '.kcm.installTemplates = true' dev/mothership-values.yaml
@$(YQ) eval -i '.grafana.logSources = [{"name": "$(USER)-storage", "url": "https://vmauth.$(STORAGE_DOMAIN)/vls", "type": "victoriametrics-logs-datasource", "auth": {"credentials_secret_name": "grafana-admin-credentials"}}]' dev/mothership-values.yaml
@$(YQ) eval -i '.promxy.config.serverGroups = [{"clusterName": "$(USER)-storage", "targets": ["vmauth.$(STORAGE_DOMAIN):443"], "auth": {"credentials_secret_name": "grafana-admin-credentials"}}]' dev/mothership-values.yaml

@$(YQ) eval -i '.hmc.motel.charts.collectors.version = "$(COLLECTORS_VERSION)"' dev/mothership-values.yaml
@$(YQ) eval -i '.hmc.motel.charts.storage.version = "$(STORAGE_VERSION)"' dev/mothership-values.yaml
@$(YQ) eval -i '.kcm.kof.charts.collectors.version = "$(COLLECTORS_VERSION)"' dev/mothership-values.yaml
@$(YQ) eval -i '.kcm.kof.charts.storage.version = "$(STORAGE_VERSION)"' dev/mothership-values.yaml
@if [ "$(REGISTRY_REPO)" = "oci://127.0.0.1:$(REGISTRY_PORT)/charts" ]; then \
$(YQ) eval -i '.hmc.motel.repo.url = "oci://$(REGISTRY_NAME):5000/charts"' dev/mothership-values.yaml; \
$(YQ) eval -i '.hmc.motel.repo.insecure = true' dev/mothership-values.yaml; \
$(YQ) eval -i '.hmc.motel.repo.type = "oci"' dev/mothership-values.yaml; \
$(YQ) eval -i '.kcm.kof.repo.url = "oci://$(REGISTRY_NAME):5000/charts"' dev/mothership-values.yaml; \
$(YQ) eval -i '.kcm.kof.repo.insecure = true' dev/mothership-values.yaml; \
$(YQ) eval -i '.kcm.kof.repo.type = "oci"' dev/mothership-values.yaml; \
else \
$(YQ) eval -i '.hmc.motel.repo.url = "$(REGISTRY_REPO)"' dev/mothership-values.yaml; \
$(YQ) eval -i '.kcm.kof.repo.url = "$(REGISTRY_REPO)"' dev/mothership-values.yaml; \
fi; \
$(HELM) upgrade -i motel ./charts/motel-mothership -n motel --create-namespace -f dev/mothership-values.yaml
$(HELM) upgrade -i kof ./charts/kof-mothership -n kof --create-namespace -f dev/mothership-values.yaml

.PHONY: dev-storage-deploy-aws
dev-storage-deploy-aws: dev ## Deploy Regional Managed cluster using HMC
dev-storage-deploy-aws: dev ## Deploy Regional Managed cluster using KCM
cp -f demo/cluster/aws-storage.yaml dev/aws-storage.yaml
@$(YQ) eval -i '.metadata.name = "$(USER)-aws-storage"' dev/aws-storage.yaml
@$(YQ) '.spec.services[] | select(.name == "motel-storage") | .values' dev/aws-storage.yaml > dev/motel-storage-values.yaml
@$(YQ) eval -i '.["cert-manager"].email = "$(USER_EMAIL)"' dev/motel-storage-values.yaml
@$(YQ) eval -i '.victoriametrics.vmauth.ingress.host = "vmauth.$(STORAGE_DOMAIN)"' dev/motel-storage-values.yaml
@$(YQ) eval -i '.grafana.ingress.host = "grafana.$(STORAGE_DOMAIN)"' dev/motel-storage-values.yaml
@$(YQ) eval -i '.["external-dns"].enabled = true' dev/motel-storage-values.yaml
@$(YQ) eval -i '(.spec.services[] | select(.name == "motel-storage")).values |= load_str("dev/motel-storage-values.yaml")' dev/aws-storage.yaml
@$(YQ) '.spec.services[] | select(.name == "kof-storage") | .values' dev/aws-storage.yaml > dev/kof-storage-values.yaml
@$(YQ) eval -i '.["cert-manager"].email = "$(USER_EMAIL)"' dev/kof-storage-values.yaml
@$(YQ) eval -i '.victoriametrics.vmauth.ingress.host = "vmauth.$(STORAGE_DOMAIN)"' dev/kof-storage-values.yaml
@$(YQ) eval -i '.grafana.ingress.host = "grafana.$(STORAGE_DOMAIN)"' dev/kof-storage-values.yaml
@$(YQ) eval -i '.["external-dns"].enabled = true' dev/kof-storage-values.yaml
@$(YQ) eval -i '(.spec.services[] | select(.name == "kof-storage")).values |= load_str("dev/kof-storage-values.yaml")' dev/aws-storage.yaml
kubectl apply -f dev/aws-storage.yaml

.PHONY: dev-managed-deploy-aws
dev-managed-deploy-aws: dev ## Deploy Regional Managed cluster using HMC
dev-managed-deploy-aws: dev ## Deploy Regional Managed cluster using KCM
cp -f demo/cluster/aws-managed.yaml dev/aws-managed.yaml
@$(YQ) eval -i '.metadata.name = "$(USER)-aws-managed"' dev/aws-managed.yaml
@$(YQ) '.spec.services[] | select(.name == "motel-collectors") | .values' dev/aws-managed.yaml > dev/motel-managed-values.yaml
@$(YQ) eval -i '.opencost.opencost.prometheus.external.url = "https://vmauth.$(STORAGE_DOMAIN)/vm/select/0/prometheus"' dev/motel-managed-values.yaml
@$(YQ) eval -i '.motel.logs.endpoint = "https://vmauth.$(STORAGE_DOMAIN)/vls/insert/opentelemetry/v1/logs"' dev/motel-managed-values.yaml
@$(YQ) eval -i '.motel.metrics.endpoint = "https://vmauth.$(STORAGE_DOMAIN)/vm/insert/0/prometheus/api/v1/write"' dev/motel-managed-values.yaml
@$(YQ) eval -i '(.spec.services[] | select(.name == "motel-collectors")).values |= load_str("dev/motel-managed-values.yaml")' dev/aws-managed.yaml
@$(YQ) '.spec.services[] | select(.name == "kof-collectors") | .values' dev/aws-managed.yaml > dev/kof-managed-values.yaml
@$(YQ) eval -i '.opencost.opencost.prometheus.external.url = "https://vmauth.$(STORAGE_DOMAIN)/vm/select/0/prometheus"' dev/kof-managed-values.yaml
@$(YQ) eval -i '.kof.logs.endpoint = "https://vmauth.$(STORAGE_DOMAIN)/vls/insert/opentelemetry/v1/logs"' dev/kof-managed-values.yaml
@$(YQ) eval -i '.kof.metrics.endpoint = "https://vmauth.$(STORAGE_DOMAIN)/vm/insert/0/prometheus/api/v1/write"' dev/kof-managed-values.yaml
@$(YQ) eval -i '(.spec.services[] | select(.name == "kof-collectors")).values |= load_str("dev/kof-managed-values.yaml")' dev/aws-managed.yaml
kubectl apply -f dev/aws-managed.yaml

## Tool Binaries
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Mirantis OpenTelemery
This repo contains 4 charts to deploy a monitoring stack using HMC and get metrics into storage clusters, data from which is then aggregated into single grafana interface.
# K0rdent Observability and FinOps
This repo contains 4 charts to deploy an observability stack using [k0rdent](https://github.com/K0rdent/kcm) and get [OpenTelemetry](https://opentelemetry.io/) data into storage clusters aggregated into single grafana interface.

![alt text](docs/otel.png)

## Mothership chart
* central grafana interface
* promxy to forward calls to multiple downstream regional metrics servers
* local victoriametrics storage for alerting record rules
* hmc helmchart definitions and service templates to deploy storage and collectors charts into managedclusters
* k0rdent helmchart definitions and service templates to deploy storage and collectors charts into managedclusters

### Demo deployment
In `demo/demo-mothership-values.yaml` set your target ingress names that you are going to use for your regional clusters, but they can always be changed after the fact
In `demo/demo-mothership-values.yaml` set your target ingress names that you are going to use for your storage clusters, but they can always be changed after the fact

Create secrets for grafana admin user and storage clusters datasources endpoint access. By default the secret below be reused everywhere, but it is customizable.

Expand All @@ -19,21 +20,24 @@ kind: Secret
apiVersion: v1
metadata:
name: grafana-admin-credentials
namespace: motel
namespace: kof
stringData:
GF_SECURITY_ADMIN_USER: username # Grafana username
GF_SECURITY_ADMIN_PASSWORD: password # Grafana password
type: Opaque
```
```bash
helm repo add motel https://mirantis.github.io/motel/
helm repo add kof https://mirantis.github.io/kof/
helm repo update
helm upgrade -i motel motel/motel-mothership -n motel -f demo/demo-mothership-values.yaml
helm upgrade -i kof-mothership kof/kof-mothership -n kof -f demo/demo-mothership-values.yaml
```

## Storage chart
* Grafana - region-specific Grafana instance, deployed and configured with grafana-operator

Deploys metrics and logs [VictoriaMetrics](https://victoriametrics.com/) storages.

* Grafana - storage-cluster scoped Grafana instance, deployed and configured with grafana-operator
* vmcluster - metrics storage, ingestion, querying
* vmlogs - logs storage
* vmauth - auth frontend for metrics and logs ingestion and query services
Expand All @@ -42,15 +46,15 @@ helm upgrade -i motel motel/motel-mothership -n motel -f demo/demo-mothership-va
- cert-manager
- ingress-nginx

To deploy storage `managedcluster` configure desired ingress names for vmauth and regional Grafana in it's values for the `motel-storage` template.
To deploy storage `clusterdeployment` configure desired ingress names for vmauth and regional Grafana in it's values for the `kof-storage` template.
`demo/cluster/aws-storage.yaml` contains example definitions

```bash
kubectl apply -f demo/cluster/aws-storage.yaml
# you can check helm chart deployment status using ClusterSummary object:
kubectl get clustersummaries.config.projectsveltos.io -n hmc-system
```
Once the storage managedcluster is ready - retrieve its kubeconfig and get loadbalancer IP/DNS name for your ingress-nginx service.
Once the storage clusterdeploymet is ready - retrieve its kubeconfig and get loadbalancer IP/DNS name for your ingress-nginx service.

```bash
kubectl get secret -n hmc-system aws-storage-kubeconfig -o jsonpath={.data.value} | base64 -d > /tmp/hmc-aws-storage-kubeconfig.yaml
Expand All @@ -74,7 +78,7 @@ This chart pre-installs all required CRDs to create Opentelemetry Collectors for
## Collectors chart
* opentelemetry-collectors - [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) configured to monitor logs and metrics and send them to a storage cluster

To deploy operators and collectors to a `managedcluster` configure ingress names for storage vmauth in its values for the `motel-collectors` template.
To deploy operators and collectors to a `clusterdeployment` configure ingress names for storage vmauth in its values for the `kof-collectors` template.

```
kubectl apply -f demo/cluster/aws-managed.yaml
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: motel-collectors
name: kof-collectors
description: A Helm chart that deploys OpenTelemetryCollector resources
version: 0.0.1
appVersion: "1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- /* Basic auth extensions */ -}}
{{- define "basic_auth_extensions" -}}
{{- range tuple "metrics" "logs" }}
{{- $secret := (lookup "v1" "Secret" $.Release.Namespace (index $.Values "motel" . "credentials_secret_name")) }}
{{- $secret := (lookup "v1" "Secret" $.Release.Namespace (index $.Values "kof" . "credentials_secret_name")) }}
{{- if $secret }}
basicauth/{{ . }}:
client_auth:
username: {{ index $secret.data (index $.Values "motel" . "username_key") | b64dec | quote }}
password: {{ index $secret.data (index $.Values "motel" . "password_key") | b64dec | quote }}
username: {{ index $secret.data (index $.Values "kof" . "username_key") | b64dec | quote }}
password: {{ index $secret.data (index $.Values "kof" . "password_key") | b64dec | quote }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ spec:
exporters:
debug: {}
prometheusremotewrite:
endpoint: {{ .Values.motel.metrics.endpoint }}
endpoint: {{ .Values.kof.metrics.endpoint }}
tls:
insecure: true
auth:
authenticator: basicauth/metrics
otlphttp:
auth:
authenticator: basicauth/logs
logs_endpoint: {{ .Values.motel.logs.endpoint }}
logs_endpoint: {{ .Values.kof.logs.endpoint }}

extensions:
{{- include "basic_auth_extensions" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ spec:

exporters:
prometheusremotewrite:
endpoint: {{ .Values.motel.metrics.endpoint }}
endpoint: {{ .Values.kof.metrics.endpoint }}
tls:
insecure: true
auth:
authenticator: basicauth/metrics
otlphttp:
auth:
authenticator: basicauth/logs
logs_endpoint: {{ .Values.motel.logs.endpoint }}
logs_endpoint: {{ .Values.kof.logs.endpoint }}
debug:
verbosity: detailed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
global:
clusterLabel: clusterName
clusterName: mothership
motel:
kof:
logs:
endpoint: http://victoria-logs-single-server:9428/insert/opentelemetry/v1/logs
credentials_secret_name: grafana-admin-credentials
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: motel-mothership
name: kof-mothership
description: A Helm chart that deploys Grafana, Promxy, and VictoriaMetrics.
version: 0.1.6
appVersion: "1.0"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.hmc.installTemplates }}
{{- if .Values.kcm.installTemplates }}
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.hmc.installTemplates }}
{{- if .Values.kcm.installTemplates }}
apiVersion: hmc.mirantis.com/v1alpha1
kind: ServiceTemplate
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{{- if .Values.hmc.installTemplates }}
{{- range $name, $values := .Values.hmc.motel.charts }}
{{- if .Values.kcm.installTemplates }}
{{- range $name, $values := .Values.kcm.kof.charts }}
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmChart
metadata:
name: motel-{{ $name }}
name: kof-{{ $name }}
namespace: hmc-system
labels:
hmc.mirantis.com/managed: "true"
spec:
chart: motel-{{ $name }}
chart: kof-{{ $name }}
interval: 10m0s
reconcileStrategy: ChartVersion
sourceRef:
kind: HelmRepository
name: {{ $.Values.hmc.motel.repo.name }}
name: {{ $.Values.kcm.kof.repo.name }}
version: {{ $values.version }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/kof-mothership/templates/hmc/kof-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.kcm.installTemplates }}
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: {{ .Values.kcm.kof.repo.name }}
namespace: hmc-system
labels:
hmc.mirantis.com/managed: "true"
spec:
url: {{ .Values.kcm.kof.repo.url }}
insecure: {{ .Values.kcm.kof.repo.insecure }}
type: {{ .Values.kcm.kof.repo.type }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{- if .Values.hmc.installTemplates }}
{{- range $name, $values := .Values.hmc.motel.charts }}
{{- if .Values.kcm.installTemplates }}
{{- range $name, $values := .Values.kcm.kof.charts }}
---
apiVersion: hmc.mirantis.com/v1alpha1
kind: ServiceTemplate
metadata:
name: motel-{{ $name }}
name: kof-{{ $name }}
namespace: hmc-system
spec:
helm:
chartRef:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmChart
name: motel-{{ $name }}
name: kof-{{ $name }}
namespace: hmc-system
providers: []
{{- end }}
Expand Down
Loading

0 comments on commit c5e3e27

Please sign in to comment.