grafana.ts


Overview

The `grafana.ts` file is a Pulumi infrastructure-as-code module that defines Kubernetes resources necessary to expose a Grafana monitoring dashboard with secure ingress and TLS certificates. It primarily handles:

This file abstracts the deployment details of Grafana ingress-related Kubernetes resources into a reusable Pulumi `ComponentResource` named `Ingress`, enabling easy integration into a larger monitoring infrastructure stack.


Classes and Interfaces

Interface: deploymentArgs

Defines the arguments required for the `Ingress` class constructor.

Property

Type

Description

`namespace`

`pulumi.Input`

Kubernetes namespace where Grafana and ingress resources reside.

`domain`

`string`

Primary domain name used to construct Grafana monitoring URLs (e.g., `example.com`).

`additionalDomain?`

`string` (optional)

Optional secondary domain for ingress routing, allowing multi-domain support.


Class: Ingress

A Pulumi `ComponentResource` encapsulating the creation of Kubernetes ingress resources and TLS certificates for the Grafana service.

Constructor

constructor(name: string, args: deploymentArgs, opts?: pulumi.ComponentResourceOptions)
Parameters

Parameter

Type

Description

`name`

`string`

Logical name prefix for all created Kubernetes resources.

`args`

`deploymentArgs`

Configuration options including namespace and domain information.

`opts`

`pulumi.ComponentResourceOptions` (optional)

Optional Pulumi resource options (e.g., parent resource, dependsOn).

Behavior
Usage Example
import { Ingress, deploymentArgs } from './grafana'
import * as pulumi from '@pulumi/pulumi'

const args: deploymentArgs = {
  namespace: 'unchained-monitoring',
  domain: 'example.com',
  additionalDomain: 'example.org',
}

const grafanaIngress = new Ingress('unchained', args)

This example creates ingress resources for Grafana accessible via `monitoring.example.com` and `monitoring.example.org` in the `unchained-monitoring` namespace.


Implementation Details

TLS Certificate Provisioning

Traefik IngressRoute Setup

Kubernetes Ingress Fallback

Pulumi Resource Options


Interactions with Other System Components


Summary

`grafana.ts` provides a clean abstraction for setting up secure, multi-domain ingress for a Grafana monitoring dashboard within a Kubernetes cluster using Pulumi. It automates TLS certificate management via cert-manager, traffic routing via Traefik, and fallback ingress for broader compatibility. This modular design helps ensure consistent, repeatable deployment of Grafana ingress resources as part of the overall monitoring infrastructure.


Mermaid Class Diagram

classDiagram
    class deploymentArgs {
        +namespace: pulumi.Input<string>
        +domain: string
        +additionalDomain?: string
    }

    class Ingress {
        +constructor(name: string, args: deploymentArgs, opts?: pulumi.ComponentResourceOptions)
        -secretName: string
        -domains: string
    }

    Ingress --> deploymentArgs : uses
    Ingress ..> pulumi.ComponentResource : extends

End of Documentation for grafana.ts