Skip to main content

Kubernetes deployment & pod monitoring with Telegram alerts

Workflow preview

Workflow preview
100%
Kubernetes deployment & pod monitoring with Telegram alerts preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

SETUP INSTRUCTIONS 1. Configure Kubeconfig Open the "Kubeconfig Setup" node Paste your entire kubeconfig file content into the variable Set your target namespace in the variable (default: 'producti...

Best for

  • SecOps automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.code, n8n-nodes-base.executecommand, n8n-nodes-base.if, n8n-nodes-base.telegram, n8n-nodes-base.writebinaryfile, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Vigh Sandor.

Original n8n.io source

1.1 Workflow description

Title
Kubernetes deployment & pod monitoring with Telegram alerts
Workflow name
Kubernetes deployment & pod monitoring with Telegram alerts

SETUP INSTRUCTIONS

1. Configure Kubeconfig

  • Open the "Kubeconfig Setup" node
  • Paste your entire kubeconfig file content into the kubeconfigContent variable
  • Set your target namespace in the namespace variable (default: 'production')

Example kubeconfig format:

apiVersion: v1
kind: Config
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUd...
    server: https://your-cluster.example.com:6443
  name: your-cluster
contexts:
- context:
    cluster: your-cluster
    user: your-user
  name: your-context
current-context: your-context
users:
- name: your-user
  user:
    token: eyJhbGciOiJSUzI1...

2. Telegram Configuration

  • Create a Telegram bot via @BotFather
  • Get your bot token and add it as a credential in n8n (Telegram API)
  • Find your chat ID:
    • Message your bot
    • Visit: https://api.telegram.org/bot<YourBotToken>/getUpdates
    • Look for "chat":{"id":...}
  • Open the "Send Telegram Alert" node
  • Replace YOUR_TELEGRAM_CHAT_ID with your actual chat ID
  • Select your Telegram API credential

3. Schedule Configuration

  • Open the "Schedule Trigger" node
  • Default: runs every 1 minute
  • Adjust the interval based on your monitoring needs:
    • Every 5 minutes: Change field to minutes and set minutesInterval to 5
    • Every hour: Change field to hours and set hoursInterval to 1
    • Cron expression: Use custom cron schedule

4. kubectl Installation

  • The workflow automatically downloads kubectl (v1.34.0) during execution
  • No pre-installation required on the n8n host
  • kubectl is downloaded and used temporarily for each execution

HOW IT WORKS

Workflow Steps

  1. Schedule Trigger

    • Runs automatically based on configured interval
    • Initiates the monitoring cycle
  2. Kubeconfig Setup

    • Loads the kubeconfig and namespace configuration
    • Passes credentials to kubectl commands
  3. Parallel Data Collection

    • Get Pods: Fetches all pods from the specified namespace
    • Get Deployments: Fetches all deployments from the specified namespace
    • Both commands run in parallel for efficiency
  4. Process & Generate Report

    • Parses pod and deployment data
    • Groups pods by their owner (Deployment, DaemonSet, StatefulSet, or Node)
    • Calculates readiness statistics for each workload
    • Detects alerts: workloads with 0 ready pods
    • Generates a comprehensive Markdown report including:
      • Deployments with replica counts and pod details
      • Other workloads (DaemonSets, StatefulSets, Static Pods)
      • Standalone pods (if any)
      • Pod-level details: status, node, restart count
  5. Has Alerts?

    • Checks if any workloads have 0 ready pods
    • Routes to appropriate action
  6. Send Telegram Alert (if alerts exist)

    • Sends formatted alert message to Telegram
    • Includes:
      • Namespace information
      • List of problematic workloads
      • Full status report
  7. Save Report

    • Saves the Markdown report to a file
    • Filename format: k8s-report-YYYY-MM-DD-HHmmss.md
    • Always executes, regardless of alert status

Security Features

  • Temporary kubectl: Downloaded and used only during execution
  • Temporary kubeconfig: Written to /tmp/kubeconfig-<random>.yaml
  • Automatic cleanup: Kubeconfig file is deleted after each kubectl command
  • No persistent credentials: Nothing stored on disk between executions

Alert Logic

Alerts are triggered when any workload has zero ready pods:

  • Deployments with readyReplicas < 1
  • DaemonSets with numberReady < 1
  • StatefulSets with readyReplicas < 1
  • Static Pods (Node-owned) with no ready instances

Report Sections

  1. Deployments: All Deployment-managed pods (via ReplicaSets)
  2. Other Workloads: DaemonSets, StatefulSets, and Static Pods (kube-system components)
  3. Standalone Pods: Pods without recognized owners (rare)
  4. Alerts: Summary of workloads requiring attention

KEY FEATURES

  • Automatic kubectl management - No pre-installation needed
  • Multi-workload support - Deployments, DaemonSets, StatefulSets, Static Pods
  • Smart pod grouping - Uses Kubernetes ownerReferences
  • Conditional alerting - Only notifies when issues detected
  • Detailed reporting - Pod-level status, node placement, restart counts
  • Secure credential handling - Temporary files, automatic cleanup
  • Markdown format - Easy to read and store

TROUBLESHOOTING

Issue: "Cannot read properties of undefined"

  • Ensure both "Get Pods" and "Get Deployments" nodes execute successfully
  • Check that kubectl can access your cluster with the provided kubeconfig

Issue: No alerts when there should be

  • Verify the namespace contains deployments or workloads
  • Check that pods are actually not ready (use kubectl get pods -n <namespace>)

Issue: Telegram message not sent

  • Verify Telegram API credential is configured correctly
  • Confirm chat ID is correct and the bot has permission to message you
  • Check that the bot was started (send /start to the bot)

Issue: kubectl download fails

  • Check internet connectivity from n8n host
  • Verify access to dl.k8s.io domain
  • Consider pre-installing kubectl on the host and removing the download commands

CUSTOMIZATION

Change Alert Threshold

Edit the Process & Generate Report node to change when alerts trigger:

// Change from "< 1" to your desired threshold
if (readyReplicas < 2) {  // Alert if less than 2 ready pods
  alerts.push({...});
}

Monitor Multiple Namespaces

  • Duplicate the workflow for each namespace
  • Or modify "Kubeconfig Setup" to loop through multiple namespaces

Custom Report Format

Edit the markdown generation in Process & Generate Report node to customize:

  • Section order
  • Information displayed
  • Formatting style

Additional Notification Channels

Add nodes after "Has Alerts?" to send notifications via:

  • Email (SMTP node)
  • Slack (Slack node)
  • Discord (Discord node)
  • Webhook (HTTP Request node)

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1

Block 2 - Kubeconfig Setup

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Get Pods

Type / Role
n8n-nodes-base.executeCommand - executeCommand
Config choices
Version 1

Block 4 - Get Deployments

Type / Role
n8n-nodes-base.executeCommand - executeCommand
Config choices
Version 1

Block 5 - Process & Generate Report

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Has Alerts?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 1

Block 7 - Send Telegram Alert

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1

Block 8 - Save Report

Type / Role
n8n-nodes-base.writeBinaryFile - writeBinaryFile
Config choices
Version 1

Block 9 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Kubernetes deployment & pod monitoring with Telegram alerts
Complexity intermediate
Nodes 14
Categories SecOps
Author Vigh Sandor
Published 14 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9613/9613.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Kubernetes deployment & pod monitoring with Telegram alerts do?

SETUP INSTRUCTIONS 1. Configure Kubeconfig Open the "Kubeconfig Setup" node Paste your entire kubeconfig file content into the variable Set your target namespace in the variable (default: 'producti...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.