Skip to content

About

Observe Stack with AWS integrations (PodIdentity for OpenCost, etc)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

aws-observe-stack

Deploys the ObserveStack with AWS Pod Identity for OpenCost billing access.

Overview

Composes the base hops.ops.com.ai/ObserveStack XRD with aws.hops.ops.com.ai/PodIdentity. Automatically provisions IAM role and Pod Identity association for OpenCost's service account with Cost Explorer, Pricing, CUR, and EC2 describe permissions.

Usage

apiVersion: aws.hops.ops.com.ai/v1alpha1
kind: ObserveStack
metadata:
  name: observe
  namespace: default
spec:
  clusterName: my-cluster
  aws:
    region: us-east-1

Default storage is pvc-backed (storage.type: pvc) for both Loki and Tempo with auto-created gp3 StorageClasses (loki, tempo). When storage.type: s3 is enabled, the stack creates a component bucket, lifecycle policy, default SSE-KMS bucket encryption with a dedicated KMS key, and the PodIdentity S3/KMS permissions required by the workload.

You can set global StorageClass behavior and override per component:

spec:
  storageClassDefaults:
    reclaimPolicy: Retain
  loki:
    storage:
      type: pvc
      size: 20Gi
      storageClass:
        name: logs
  tempo:
    storage:
      type: pvc
      storageClass:
        name: traces

With custom values:

apiVersion: aws.hops.ops.com.ai/v1alpha1
kind: ObserveStack
metadata:
  name: observe
  namespace: default
spec:
  clusterName: production-cluster
  namespace: monitoring
  kubePrometheusStack:
    storage:
      size: 10Gi
      retentionDays: 30
      # Leaves capacity for WAL replay and compaction.
      retentionSize: 8GB
  loki:
    storage:
      type: s3
      retentionDays: 30
  tempo:
    storage:
      type: s3
      retentionDays: 14
  k8sMonitoring:
    values:
      opencost:
        enabled: true
  aws:
    region: us-west-2
    rolePrefix: prod-

Alloy is the default metrics collector and remote-writes to Prometheus. To have Prometheus scrape an additional ServiceMonitor or PodMonitor directly, label it with hops.ops.com.ai/scrape-directly: prometheus.

Adopt existing Prometheus and Metrics Server releases

Set addonsEnabled: false to run Prometheus with direct scrapes and omit the other bundled components. Metrics Server remains opt-in. Pin the installed chart versions in chartVersions and set each component's maxHistory to preserve its Helm history limit. Use overrideAllValues to retain the exact values of each existing deployment, including any Prometheus PVC settings. For the initial handoff use managementPolicies: [Observe] and match the existing Release names and namespaces. Prometheus and Metrics Server example

Goldilocks dashboard

Goldilocks is installed with a cluster-only dashboard. Opt into a browser route with the shared OAuth2 proxy and existing observability permissions:

spec:
  exposure:
    enabled: true
    domain: ops.example.com
    gatewayRef:
      name: private
      namespace: istio-ingress
      sectionNames: [https-monitoring]
    routeAnnotations:
      external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
    goldilocks:
      enabled: true
      host: goldilocks.ops.example.com

The shared exposure prerequisites (OIDC project/provider, cookie Secret and Istio extension provider) still apply. Set spec.auth.issuerURL, spec.auth.awsSecretsManagerPath, spec.auth.zitadelProjectId, and spec.exposure.oauth2Proxy.cookieSecretRef.name when exposure is enabled. The selected Gateway, namespace admission and certificate must cover this hostname. DNS-only controls proxying; the Gateway's network placement determines whether a VPN is required.

The route uses the dashboard's named http port through a waypoint-enabled sister Service. Its CUSTOM authorization policy is observed in the target cluster before the route is created; a transient Ready failure does not remove an existing route. Ready-gated Usages remain during exposure disablement and keep the authorization policy, dashboard, backend Service, waypoint and OAuth deployment until the route is deleted. Existing component identities and OAuth signing/session Secrets are retained; the shared OIDC client gains the exact callback/logout URLs for this host. status.exposure.goldilocks.ready includes observed route/backend/policy, Goldilocks, waypoint, OAuth bridge and OIDC readiness. servicePort configures the sister Service port; use podSelector if dashboard pod labels differ from the chart defaults.

Routing and independent component upgrades

Use spec.exposure.gatewayRef to select a public or private Gateway listener. spec.exposure.routeAnnotations adds metadata to all enabled dashboard HTTPRoutes, including provider-specific DNS controls:

spec:
  exposure:
    routeAnnotations:
      external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"

These annotations apply to the HTTPRoutes, preserving the Crossplane Object wrappers and the existing Grafana OIDC / waypoint authorization behavior. The gateway, certificate and namespace attachment permissions remain platform configuration. DNS-only records alone do not make an endpoint private.

Pin individual component charts with spec.chartVersions when adopting an API improvement independently of workload upgrades. Omitted components retain the packaged defaults; Helm values and workload image overrides remain separate.

spec:
  chartVersions:
    kubePrometheusStack: "82.18.0"
    loki: "6.55.0"

Supported keys: kubePrometheusStack, loki, tempo, k8sMonitoring, grafanaOperator, vpa, and goldilocks.

Easy HA Mode

Enable HA safety defaults for observe workloads:

spec:
  ha:
    enabled: true

When enabled:

  • Prometheus, Alertmanager, Grafana, and oauth2-proxy default to 2 replicas where they are managed by the XR
  • Grafana HA composes an embedded PSQLCluster named {observe-name}-grafana-pg and switches Grafana to Postgres before scaling replicas
  • Prometheus, Alertmanager, Loki, and oauth2-proxy get zone topology spread defaults where the chart or XR directly supports them
  • PodDisruptionBudgets are created for Prometheus, Alertmanager, Grafana, OpenCost, Loki, Tempo, and exposure bridge workloads
  • Loki and Tempo stay single-replica on PVC storage; they are only auto-scaled by HA mode when their storage type is already s3

Grafana HA requires the psql-stack configuration on the control plane and a working psql StorageClass in the target cluster. For Zitadel-backed Grafana admin access, set spec.exposure.grafana.roleAttributePath to return GrafanaAdmin and enable spec.exposure.grafana.allowAssignGrafanaAdmin.

Tune defaults globally or per component:

spec:
  ha:
    enabled: true
    replicas: 3
    components:
      grafana:
        replicas: 2
      loki:
        enabled: false

Dedicated NodePool

Isolate observe workloads on a dedicated Karpenter NodePool (opt-in):

spec:
  clusterName: my-cluster
  aws:
    region: us-east-1
  nodePool:
    enabled: true

When enabled:

  • A Karpenter NodePool (<clusterName>-observe) is created with cheap, flexible Spot selection: c/m/r/t instance categories, generation 4 or newer, Linux, and no architecture pin
  • Non-daemonset pods (Prometheus, Loki, Tempo, Grafana, OpenCost, VPA, Goldilocks) are scheduled to the NodePool via nodeSelector and tolerations
  • Alloy metrics (StatefulSet) and singleton collectors are scheduled to the observe NodePool.
  • Node-local Alloy logs and the default receiver (DaemonSets) continue to run on all nodes, including the observe NodePool.
  • When k8sMonitoring.values.alloy-receiver.controller.type is deployment or statefulset, the receiver uses the observe NodePool selector and workload toleration. With nodePool.enabled: false, it receives no custom tolerations, so it respects disruption and pressure taints. Explicit receiver controller.nodeSelector and controller.tolerations overrides (including []) take precedence; overrideAllValues bypasses these defaults.
  • Workloads that require x86 images should set nodeSelector: {kubernetes.io/arch: amd64} or equivalent affinity

Custom NodePool settings:

spec:
  nodePool:
    enabled: true
    nodeClassName: custom-nodeclass
    limits:
      nodes: 20
    requirements:
    # Example override for x86-only workloads.
    - key: kubernetes.io/arch
      operator: In
      values: [amd64]
    - key: karpenter.sh/capacity-type
      operator: In
      values: [spot]
    disruption:
      consolidationPolicy: WhenEmpty
      consolidateAfter: "120s"

Spot Instance Pricing

Enable accurate spot pricing in OpenCost by pointing it at a SpotFeed bucket:

spec:
  clusterName: my-cluster
  aws:
    region: us-east-1
  spotFeed:
    enabled: true
    bucketName: hops-root-account-spot-feed
    region: us-east-1

When enabled:

  • OpenCost PodIdentity gets S3 read permissions for the spot feed bucket
  • OpenCost exporter is configured with spot_data_bucket, spot_data_region, and spot node labels (karpenter.sh/capacity-type=spot)
  • Optional prefix field if the spot feed uses an S3 key prefix

Prerequisite: Deploy a SpotFeed XRD in the same AWS account first. See aws-spot-feed.

Cloud Costs via CUR/Athena

Enable full AWS cloud cost ingestion in OpenCost by referencing a separately managed CostReport XR:

apiVersion: aws.hops.ops.com.ai/v1alpha1
kind: CostReport
metadata:
  name: hops-root-account
  namespace: default
spec:
  accountId: "123456789012"
  region: us-east-2
---
apiVersion: aws.hops.ops.com.ai/v1alpha1
kind: ObserveStack
metadata:
  name: observe
  namespace: default
spec:
  clusterName: production
  namespace: monitoring
  aws:
    region: us-east-2
  cloudCosts:
    enabled: true
    costReportRef:
      enabled: true
      name: hops-root-account
      accountId: "123456789012"
      region: us-east-2

When enabled:

  • ObserveStack derives CUR/Athena names from the referenced CostReport
  • OpenCost is wired through the chart's native cloudIntegrationSecret support
  • The OpenCost PodIdentity gets Athena, Glue, and S3 permissions for the CUR bucket/workgroup
  • The generated cloud-integration.json uses OpenCost's legacy flat AWS format with the Athena query-results location s3://{bucketName}/athena-results

CostReport is account-level and should be managed separately, one per AWS account. If your CostReport uses non-default names, set the corresponding overrides under cloudCosts.costReportRef. The legacy manual cloudCosts fields still work as a fallback.

What Gets Created

  1. Helm Releases - Prometheus, Loki, Tempo, k8s-monitoring/OpenCost, Grafana Operator, VPA, Goldilocks
  2. PodIdentity - IAM role + Pod Identity association with billing permissions for OpenCost
  3. Usage - deletion ordering: Observe deleted before PodIdentity
  4. StorageClasses - gp3 EBS classes for Prometheus, Loki, Tempo (when using PVC storage)
  5. NodePool (opt-in) - dedicated Karpenter NodePool for observe workloads
  6. PodDisruptionBudgets (opt-in via HA mode) - safe voluntary disruption boundaries for observe workloads

Development

make render
make validate
make test

Import an existing pod identity

Use spec.aws.openCostPodIdentity to set the existing PodIdentity composite name, IAM role name and EKS association ID. Start with identity management policies set to Observe. Supply the complete inline policies and managed policy ARNs that the role should have when you enable Update. An explicit empty list replaces that policy set. Omitting either list retains the stack's defaults.

Match the cluster, namespace and service account to the existing association. Transfer the existing writer before enabling updates and verify the same role and association IDs after reconciliation. The stack keeps managing its PodIdentity and its deletion dependency. Import example

About

Observe Stack with AWS integrations (PodIdentity for OpenCost, etc)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages