Customizing Argo Rollouts analysis with Prometheus metrics
TypeScriptTo customize Argo Rollouts analysis with Prometheus metrics using Pulumi, you would typically define resources that represent a Prometheus setup as well as Argo Rollouts resources, both configured to work together.
However, as of my last update, Pulumi does not provide a dedicated package for Argo CD or Argo Rollouts resources directly within its packages. You would ordinarily use a Kubernetes package (like
pulumi/kubernetes
) to define Kubernetes resources in a generic way.To move forward, you would first ensure that you have a Kubernetes cluster available and set up, along with a Prometheus instance that is ready to collect metrics. The
pulumi/kubernetes
package allows you to deploy Kubernetes resources, and you would define your Rollouts and Prometheus-related resources using this package.In the provided program below, I'm assuming that you already have Argo CD/Rollouts and Prometheus installed on your Kubernetes cluster. If not, these applications should be set up beforehand, which can also be done using Pulumi by applying available Helm charts or Kubernetes manifests.
Here's a Pulumi TypeScript program that demonstrates how you might define a simple Argo Rollouts analysis object that makes use of Prometheus metrics for analysis:
import * as k8s from "@pulumi/kubernetes"; // This is a TypeScript program that demonstrates how to set up an Argo Rollouts AnalysisTemplate // to use Prometheus metrics for making rollout decisions. It assumes role-based access // to a Kubernetes cluster and the existence of a Prometheus instance. // Example namespace where Argo Rollouts is installed const namespace = "argo-rollouts"; // Define the AnalysisTemplate resource that uses Prometheus metrics. const analysisTemplate = new k8s.apiextensions.CustomResource("prometheus-analysis-template", { apiVersion: "argoproj.io/v1alpha1", kind: "AnalysisTemplate", metadata: { namespace: namespace, name: "prometheus-analysis-template", }, spec: { metrics: [{ name: "success-rate", interval: "1m", // This is where you specify how the data is queried from Prometheus. provider: { prometheus: { // This is a placeholder URL; replace with your Prometheus server's address. address: "http://prometheus-server.monitoring.svc.cluster.local", query: "rate(http_requests_total{status=~'2..'}[5m])", } } }] } }, {dependsOn: [/* any dependent resources such as Prometheus configuration */]}); // To reference this AnalysisTemplate in an Argo Rollout, you'd use its name in the Rollout spec's // strategy section, under the analysis section. export const analysisTemplateName = analysisTemplate.metadata.name;
This program defines an
AnalysisTemplate
resource for Argo Rollouts, a Kubernetes custom resource used by Argo to define the criteria for analyzing a new version of an application. In this case, we're looking at the success rate of HTTP requests using a Prometheus query.Keep in mind that to successfully run this program, you need:
- An existing Kubernetes cluster with kubeconfig properly configured for Pulumi's access.
- Argo CD and Argo Rollouts installed in the cluster in the given namespace.
- Prometheus set up and configured to collect the metrics required for the analysis.
Pulumi will take this program and create the resources defined by it in your cluster, allowing you to use these
AnalysisTemplates
to drive more sophisticated rollout strategies with Argo Rollouts, powered by real-time metrics from Prometheus.