How giantswarm/cluster-api-monitoring-app works
Project Type and Purpose
• The project is a Helm chart for deploying a custom fork of kube-state-metrics with additional support for exposing metrics from ClusterAPI custom resources. Its goal is to enable collection of metrics from these CRs (such as those from Flux) in a management cluster.
• The README explains that this app (or “chart”) is used to install a dedicated kube-state-metrics (KSM) instance with the alpha CustomResourceStateMetrics feature enabled and further extended to monitor additional CRs by parsing configuration files.
Main Architectural Components
a. CI/CD Pipeline Components:
• CircleCI and GitHub Actions – the .circleci and .github directories hold configuration files, workflows, build scripts, and release tools.
• Renovate configuration for dependency updates.
b. The Helm Chart Itself:
• The helm/cluster-api-monitoring directory is central. It contains:
• Chart.yaml: The chart metadata.
• configuration directory: Multiple YAML files for CR configurations that enable metrics collection for various ClusterAPI and Flux related resources.
• templates directory: Kubernetes resource templates (like deployments, service accounts, ConfigMaps, PodMonitors, etc.).
• values.yaml and values.schema.json: Default configuration and schema definitions.
c. The Application Domain:
• The deployed application will run inside a Kubernetes (management) cluster.
• It acts as an independent instance of kube-state-metrics with custom enhancements for ClusterAPI custom resources.
• It interfaces with Kubernetes API servers and CRDs to extract state metrics.
Relationships and Interactions
• CI/CD Workflows → Build & Release: Your GitHub Actions and CircleCI pipelines trigger tasks like linting, building container images, verifying configuration schema, and creating releases. These pipelines ensure that every change to the Helm chart is validated and released seamlessly.
• Helm Chart → Kubernetes Cluster Deployment: The Helm chart (comprising templates, configurations, and values files) is used to install the monitoring application into a management cluster. Configurations (found under the “configuration” directory) define how different monitored resources are handled.
• Data Flow within the Application: When installed, the kube-state-metrics fork reads Kubernetes CRs based on the configuration specified (for example, using custom YAML files for flux resources) and then exports the corresponding metrics. This data flow can be depicted as “Kubernetes API Call → CR Data Extraction → Metrics Generation.”
Architectural Patterns and Design Principles
• Separation of Concerns: Notice the clear separation between configuration (under configuration/), templating (under templates/), and CI/CD integration (under .circleci and .github). This modularization makes it easier to maintain.
• Infrastructure as Code: The use of Helm charts to declare desired Kubernetes states.
• Declarative Configuration: YAML configuration and templating emphasize a declarative approach that is typical in Kubernetes-centric applications.