PowerShell Usage
If you’re using KubeBuddy via PowerShell, this guide will help you monitor and analyze your Kubernetes clusters. Below are detailed instructions and examples for various commands.
🔧 Prerequisites
Before running KubeBuddy, ensure you:
- Are connected to a Kubernetes cluster/context.
- Have kubectl installed and configured.
- Have Azure CLI (az cli) installed if using AKS features.
- Are logged into Azure and using the correct subscription for AKS monitoring.
Available Commands
The following table provides a quick reference for KubeBuddy commands:
Action | Command Example |
---|---|
Run KubeBuddy | Invoke-KubeBuddy |
Generate an HTML report | Invoke-KubeBuddy -HtmlReport |
Generate a text report | Invoke-KubeBuddy -txtReport |
Run a KubeBuddy with an AKS Best Practices Check | Invoke-KubeBuddy -aks -SubscriptionId <subscriptionID> -ResourceGroup <resourceGroup> -ClusterName <clusterName> |
Run AKS best practices check and HTML report | Invoke-KubeBuddy -HtmlReport -aks -SubscriptionId $SubscriptionId -ResourceGroup $ResourceGroup -ClusterName $ClusterName |
Run AKS best practices check and text report | Invoke-KubeBuddy -txtReport -aks -SubscriptionId $SubscriptionId -ResourceGroup $ResourceGroup -ClusterName $ClusterName |
1. Running KubeBuddy
To run KubeBuddy on your Kubernetes cluster:
Invoke-KubeBuddy
This command provides a detailed menu-driven interface that allows you to navigate through various monitoring options. It analyzes node status, resource usage, workloads, and RBAC security settings. The interactive menu lets you explore different categories, such as pod health, event summaries, and networking insights, making it easier to assess and troubleshoot your Kubernetes cluster.
2. Running KubeBuddy with an AKS Practices Check
To run KubeBuddy on your cluster and be able to run the AKS Best Practices Check:
Invoke-KubeBuddy -aks -SubscriptionId <subscriptionID> -ResourceGroup <resourceGroup> -ClusterName <clusterName>
Making sure you supply your subscription ID the Resource Group name where the AKS cluster lives, and also the cluster Name. With out these details you will not be able to run the AKS best Practices Check.
3. Generating Reports
To generate an HTML report:
Invoke-KubeBuddy -HtmlReport
For a text-based report:
Invoke-KubeBuddy -txtReport
4. Running an AKS Health Check alongside the HTML report
To check best practices for an Azure Kubernetes Service (AKS) cluster, ensure you are logged into Azure and using the correct subscription:
az login
az account set --subscription <subscription-id>
Invoke-KubeBuddy -HtmlReport -aks -SubscriptionId $SubscriptionId -ResourceGroup $ResourceGroup -ClusterName $ClusterName
5. Running an AKS Health Check alongside the txt report
To check best practices for an Azure Kubernetes Service (AKS) cluster, ensure you are logged into Azure and using the correct subscription:
az login
az account set --subscription <subscription-id>
Invoke-KubeBuddy -txtReport -aks -SubscriptionId $SubscriptionId -ResourceGroup $ResourceGroup -ClusterName $ClusterName
6. Configuring Thresholds
KubeBuddy supports customizable thresholds via the kubebuddy-config.yaml
file. You can place this file in ~/.kube/kubebuddy-config.yaml
or specify a custom path. A sample configuration looks like this:
thresholds:
cpu_warning: 50
cpu_critical: 75
mem_warning: 50
mem_critical: 75
restarts_warning: 3
restarts_critical: 5
pod_age_warning: 15
pod_age_critical: 40
stuck_job_hours: 2
failed_job_hours: 2
event_errors_warning: 10
event_errors_critical: 20
event_warnings_warning: 50
event_warnings_critical: 100
Adjust these values to suit your environment’s needs. If kubebuddy-config.yaml
is missing, KubeBuddy uses default threshold values.
7. Additional Parameters
Below are optional parameters you can use with Invoke-KubeBuddy
:
Parameter | Type | Default | Description |
---|---|---|---|
-OutputPath | String | $HOME\kubebuddy-report | Folder where report files are saved. If not present, KubeBuddy creates it automatically. |
-Aks | Switch | (N/A) | Runs AKS best practices checks. Requires -SubscriptionId , -ResourceGroup , -ClusterName . |
-SubscriptionId | String | (None) | Azure subscription ID (used with -Aks ). |
-ResourceGroup | String | (None) | Azure resource group (used with -Aks ). |
-ClusterName | String | (None) | AKS cluster name (used with -Aks ). |
-HtmlReport | Switch | (N/A) | Generates an HTML report in $OutputPath\kubebuddy-report.html . |
-txtReport | Switch | (N/A) | Generates a text report in $OutputPath\kubebuddy-report.txt . |
✅ Next Steps: Explore more commands in the PowerShell Usage Guide.