Skip to content

Connect Kubernetes and PagerDuty

Two read only integrations add context to your services. Kubernetes shows which workloads each service runs on. PagerDuty shows who is on call for it and which team owns it. Both write to Skep’s service graph, so owners carry through to findings and recommendations.

  • Plan: any plan.
  • Role: an organization admin, signed in as a person. Agents and API keys cannot create or change integrations.
  • A read only credential for each system, described below. Skep stores it encrypted and never shows it again.

Every five minutes, Skep reads a cluster’s namespaces and workloads (deployments, statefulsets, daemonsets and cronjobs) and adds them to the graph:

  • which workloads each service runs on, with desired and ready replicas;
  • the team that owns each workload, from its labels and annotations;
  • workload, namespace and cluster entities that match the ones your collectors’ k8s_attributes processor reports, so the two sources meet on one entity instead of two.

It only reads. It never reads pods, secrets or config maps, and it never changes the cluster.

Skep must reach the cluster’s API server over HTTPS. For a private cluster, expose the API server to Skep.

  1. Create a read only service account. Apply this manifest. It can only get, list and watch the resources the integration reads, and it gets a long-lived token:

    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: skep-reader
    namespace: kube-system
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
    name: skep-reader
    rules:
    - apiGroups: [""]
    resources: ["namespaces"]
    verbs: ["get", "list", "watch"]
    - apiGroups: ["apps"]
    resources: ["deployments", "statefulsets", "daemonsets"]
    verbs: ["get", "list", "watch"]
    - apiGroups: ["batch"]
    resources: ["cronjobs"]
    verbs: ["get", "list", "watch"]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
    name: skep-reader
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: skep-reader
    subjects:
    - kind: ServiceAccount
    name: skep-reader
    namespace: kube-system
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: skep-reader-token
    namespace: kube-system
    annotations:
    kubernetes.io/service-account.name: skep-reader
    type: kubernetes.io/service-account-token

    watch is granted for a future streaming mode. Today the integration only lists. To limit it to some namespaces, set Namespaces in step 3, then replace the ClusterRoleBinding with a RoleBinding in each namespace. Keep cluster-wide get on namespaces.

  2. Read the token and the cluster CA:

    Terminal window
    kubectl -n kube-system get secret skep-reader-token -o jsonpath='{.data.token}' | base64 -d
    kubectl -n kube-system get secret skep-reader-token -o jsonpath='{.data.ca\.crt}' | base64 -d
  3. Add the integration. Open Integrations, choose Add integration, then Kubernetes. Choose the Skep environment the cluster’s collectors report into. Create one integration per cluster. Paste the token and fill in:

    Setting Required Meaning
    API server Yes The API server URL. Must be https (http only for localhost, such as kubectl proxy)
    Cluster name Yes The k8s.cluster.name your collectors set, so both sides name the cluster the same way
    Cluster CA (PEM) No The token Secret’s ca.crt. When set, it replaces the system roots. TLS verification is never turned off
    Namespaces No Only these namespaces. Empty means every namespace
    Owner label and annotation keys No Keys that name the owning team, in order. Default: app.kubernetes.io/part-of, team, owner
    Service name keys No Keys that name the service, in order. Default: resource.opentelemetry.io/service.name, app.kubernetes.io/name

A workload maps to the services already observed on it through resource attributes, plus the service its metadata names. The name comes from the first service name key found on the workload’s annotations or labels, then its pod template’s. If resource.opentelemetry.io/service.namespace is set, it must match the service’s service.namespace. Otherwise:

  • a name that matches one observed service maps to it;
  • if several match, the one whose service.namespace equals the Kubernetes namespace wins;
  • anything still ambiguous is never guessed, and is listed under ambiguous_workloads in the sync stats.

When a workload leaves the cluster, the links only this integration reported are turned off. A link your telemetry also reports stays.

Two clusters in one Skep environment that both have a namespace with the same name share one namespace entity. Skep flags it as ambiguous and lists it under namespaces_shared_with_other_clusters. Put the clusters in separate environments if that matters to you.

Every five minutes, Skep reads services, teams, escalation policies and current on-calls from PagerDuty, and links each PagerDuty service to the Skep services it covers. Each linked service shows:

  • its PagerDuty service, with a link;
  • who is on call now, by escalation level;
  • the owning team, which becomes the owner of the service and of its new findings.

There is one PagerDuty integration per organization, and it covers every environment. Agents see the same data in get_service. On-call is as fresh as the last sync, at most five minutes old. Page people from PagerDuty, not from Skep.

  1. Create a read only key. In PagerDuty, open Integrations, then API Access Keys, and create a key with Read-only API Key checked. A user token from someone who can see every service and schedule works too.

  2. Add the integration. Open Integrations, choose Add integration, then PagerDuty. Paste the key.

  3. Map services if names differ. Service mapping is JSON from a PagerDuty service ID or name to a Skep service:

    {"PABC123": "shop/checkout", "Cart API": "svc:shop/cart"}

    svc:shop/checkout or shop/checkout names one namespace. A bare checkout means that name in any namespace. Skep looks up the ID before the name.

  4. Leave Match unmapped services by name on to link the rest by name. Matching lowercases the name, keeps only letters and digits, and drops a trailing service or svc, so Checkout Service, checkout-svc and checkout all match.

  5. For an EU account, set API URL to https://api.eu.pagerduty.com.

Skep calls only GET /services, GET /teams, GET /escalation_policies and GET /oncalls.

Where a name would match several services in one environment (shop/cart and legacy/cart), Skep skips that environment rather than guess, and lists it under ambiguous_matches. Add a mapping with a namespace to resolve it.

Several sources can name a service’s owner. When they disagree, Skep picks the first in this order:

  1. PagerDuty, because it is who gets paged.
  2. The team.name resource attribute in your telemetry.
  3. CODEOWNERS, from GitHub or GitLab.
  4. Kubernetes labels and annotations.

Team names match only when they are spelled the same: Payments and payments are two teams. When a source stops naming a team, ownership falls back to the next source.

  • The integration shows Last sync with a recent time and its sync stats. Kubernetes: workloads, workloads mapped to services, workloads with an owner. PagerDuty: PagerDuty services, services linked, on-calls.
  • A service’s detail page lists its Kubernetes workloads and its PagerDuty service with who is on call.
  • Services under Data show an owner with the source kubernetes or pagerduty.
What you see Why What to do
Kubernetes: last sync failed with 401 The token was rejected Read the token again from the Secret and update the integration
Kubernetes: last sync failed with 403 The service account lacks a permission Apply the manifest above, or add the missing rule
Kubernetes: the sync cannot connect Skep cannot reach the API server, or the CA does not match Check the API server URL, network access and the Cluster CA
Workloads without a service No service name key is set on the workload, and no observed service runs on it Add app.kubernetes.io/name or the OpenTelemetry Operator annotation, or set Service name keys
PagerDuty services that link to nothing No mapping and no name match The sync stats list PagerDuty services without a Skep service. Add mappings for them
The wrong team owns a service A higher source names another team Check the order above. PagerDuty wins over the others

To sync now instead of waiting five minutes, choose Sync now on the integration.

Skep · Security · Changelog · Privacy