diff --git a/kubernetes/talos-flux/apps/observability/kromgo/app/helm-release.yaml b/kubernetes/talos-flux/apps/observability/kromgo/app/helm-release.yaml new file mode 100644 index 000000000..aaa6de778 --- /dev/null +++ b/kubernetes/talos-flux/apps/observability/kromgo/app/helm-release.yaml @@ -0,0 +1,112 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2beta2.schema.json +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: &app kromgo +spec: + interval: 30m + chart: + spec: + chart: app-template + version: 3.1.0 + sourceRef: + kind: HelmRepository + name: bjw-s-charts + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + strategy: rollback + retries: 3 + values: + controllers: + kromgo: + replicas: 2 + strategy: RollingUpdate + annotations: + reloader.stakater.com/auto: "true" + containers: + app: + image: + repository: ghcr.io/kashalls/kromgo + tag: 0.3.1@sha256:5ba40b2fda00ab7adb039c0be955161b84febfe9e9e7816d5f1f87d9ab41f173 + env: + PROMETHEUS_URL: http://prometheus-thanos-discovery.observability.svc.cluster.local:10902 + PORT: &port 80 + probes: + liveness: &probes + enabled: true + custom: true + spec: + httpGet: + path: /-/ready + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + readiness: *probes + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL + resources: + requests: + cpu: 10m + limits: + memory: 64Mi + pod: + securityContext: + runAsUser: 568 + runAsGroup: 568 + runAsNonRoot: true + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: *app + service: + app: + controller: kromgo + ports: + http: + port: *port + ingress: + app: + className: traefik + annotations: + cert-manager.io/cluster-issuer: letsencrypt-production + kubernetes.io/tls-acme: "true" + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/affinity: "true" + traefik.ingress.kubernetes.io/router.tls: "true" + # external-dns.alpha.kubernetes.io/target: "${SECRET_CLOUDFLARE_TUNNEL_ID}.cfargotunnel.com" + # hajimari.io/icon: video-input-antenna + # hajimari.io/enable: "true" + hosts: + - host: &host "{{ .Release.Name }}.techtales.io" + paths: + - path: / + service: + identifier: app + port: http + tls: + - hosts: + - *host + secretName: "{{ .Release.Name }}-tls" + persistence: + config-file: + type: configMap + name: kromgo-configmap + globalMounts: + - path: /kromgo/config.yaml + subPath: config.yaml + readOnly: true diff --git a/kubernetes/talos-flux/apps/observability/kromgo/app/kustomization.yaml b/kubernetes/talos-flux/apps/observability/kromgo/app/kustomization.yaml new file mode 100644 index 000000000..ec8229572 --- /dev/null +++ b/kubernetes/talos-flux/apps/observability/kromgo/app/kustomization.yaml @@ -0,0 +1,21 @@ +--- +# yaml-language-server: $schema=https://json.schemastore.org/kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helm-release.yaml +configMapGenerator: + - name: kromgo-configmap + files: + - config.yaml=./resources/config.yaml +generatorOptions: + disableNameSuffixHash: true + labels: + app.kubernetes.io/name: kromgo + app.kubernetes.io/instance: kromgo + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/component: kromgo + app.kubernetes.io/part-of: observability +commonLabels: + app.kubernetes.io/name: kromgo + app.kubernetes.io/instance: kromgo diff --git a/kubernetes/talos-flux/apps/observability/kromgo/app/resources/config.yaml b/kubernetes/talos-flux/apps/observability/kromgo/app/resources/config.yaml new file mode 100644 index 000000000..f6486e43a --- /dev/null +++ b/kubernetes/talos-flux/apps/observability/kromgo/app/resources/config.yaml @@ -0,0 +1,67 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/kashalls/kromgo/main/config.schema.json +metrics: + - name: talos_version + query: node_os_info{cluster="main", name="Talos"} + label: version_id + + - name: kubernetes_version + query: kubernetes_build_info{cluster="main", service="kubernetes"} + label: git_version + + - name: cluster_node_count + query: count(count by (node) (kube_node_status_condition{cluster="main", condition="Ready"})) + colors: + - { color: "green", min: 0, max: 9999 } + + - name: cluster_pod_count + query: sum(kube_pod_status_phase{cluster="main", phase="Running"}) + colors: + - { color: "green", min: 0, max: 9999 } + + - name: cluster_cpu_usage + query: round(avg(instance:node_cpu_utilisation:rate5m{cluster="main"}) * 100, 0.1) + suffix: "%" + colors: + - { color: "green", min: 0, max: 35 } + - { color: "orange", min: 36, max: 75 } + - { color: "red", min: 76, max: 9999 } + + - name: cluster_memory_usage + query: round(sum(node_memory_MemTotal_bytes{cluster="main"} - node_memory_MemAvailable_bytes{cluster="main"}) / sum(node_memory_MemTotal_bytes{cluster="main"}) * 100, 0.1) + suffix: "%" + colors: + - { color: green, min: 0, max: 35 } + - { color: orange, min: 36, max: 75 } + - { color: red, min: 76, max: 9999 } + + - name: cluster_power_usage + query: round(upsHighPrecOutputCurrent * upsHighPrecOutputVoltage * 0.01, 0.1) + suffix: "w" + colors: + - { color: "green", min: 0, max: 400 } + - { color: "orange", min: 401, max: 750 } + - { color: "red", min: 751, max: 9999 } + + - name: cluster_age_days + query: round((time() - min(kube_node_created{cluster="main"}) ) / 86400) + suffix: "d" + colors: + - { color: "green", min: 0, max: 180 } + - { color: "orange", min: 181, max: 360 } + - { color: "red", min: 361, max: 9999 } + + - name: cluster_uptime_days + query: round(avg(node_time_seconds{cluster="main"} - node_boot_time_seconds{cluster="main"}) / 86400) + suffix: "d" + colors: + - { color: "green", min: 0, max: 180 } + - { color: "orange", min: 181, max: 360 } + - { color: "red", min: 361, max: 9999 } + + - name: prometheus_active_alerts + query: count(ALERTS{alertstate="firing"}) + colors: + - { color: "green", min: 0, max: 1 } + - { color: "orange", min: 2, max: 4 } + - { color: "red", min: 5, max: 9999 } diff --git a/kubernetes/talos-flux/apps/observability/kromgo/flux-sync.yaml b/kubernetes/talos-flux/apps/observability/kromgo/flux-sync.yaml new file mode 100644 index 000000000..615a12f6c --- /dev/null +++ b/kubernetes/talos-flux/apps/observability/kromgo/flux-sync.yaml @@ -0,0 +1,21 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: apps-kromgo + namespace: flux-system +spec: + interval: 10m + path: ./kubernetes/talos-flux/apps/observability/kromgo/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + targetNamespace: observability + commonMetadata: + labels: + app.kubernetes.io/name: kromgo + wait: true + dependsOn: + - name: apps-kube-prometheus-stack diff --git a/kubernetes/talos-flux/apps/observability/kustomization.yaml b/kubernetes/talos-flux/apps/observability/kustomization.yaml index a648af62e..ffb02a9a4 100644 --- a/kubernetes/talos-flux/apps/observability/kustomization.yaml +++ b/kubernetes/talos-flux/apps/observability/kustomization.yaml @@ -7,6 +7,7 @@ resources: - ./alertmanager-discord/flux-sync.yaml - ./botkube/flux-sync.yaml - ./grafana/flux-sync.yaml + - ./kromgo/flux-sync.yaml - ./kube-prometheus-stack/flux-sync.yaml - ./loki/flux-sync.yaml - ./promtail/flux-sync.yaml