How do I configure a Kubernetes operator.victoriametrics.com vmservicescrape with Pulumi?
In this guide, we will configure a Kubernetes vmservicescrape
resource from the operator.victoriametrics.com
API using Pulumi. This resource is used to define how VictoriaMetrics should scrape metrics from a set of Kubernetes services.
Key Points:
- We will create a
vmservicescrape
resource. - This resource will define the scraping configuration for services in the Kubernetes cluster.
- We will use Pulumi to manage this configuration.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
// Define the namespace where the vmservicescrape will be created
const namespace = new k8s.core.v1.Namespace("monitoring", {
metadata: { name: "monitoring" },
});
// Create the vmservicescrape resource
const vmServiceScrape = new k8s.apiextensions.CustomResource("vmservicescrape", {
apiVersion: "operator.victoriametrics.com/v1beta1",
kind: "VMServiceScrape",
metadata: {
name: "example-vmservicescrape",
namespace: namespace.metadata.name,
},
spec: {
selector: {
matchLabels: {
app: "my-app",
},
},
endpoints: [
{
port: "metrics",
path: "/metrics",
interval: "30s",
},
],
namespaceSelector: {
matchNames: [namespace.metadata.name],
},
},
});
// Export the name of the vmservicescrape resource
export const vmServiceScrapeName = vmServiceScrape.metadata.name;
Summary
In this guide, we configured a vmservicescrape
resource in Kubernetes using Pulumi. This resource specifies how VictoriaMetrics should scrape metrics from services labeled with app: my-app
in the monitoring
namespace. The scraping configuration includes the metrics endpoint, path, and scrape interval.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.