Azure Kubernetes Cluster Logs
Overview
This Azure DevOps extension retrieves logs from all pods, describes deployments and services in a specified Kubernetes namespace, and saves them as separate text files named after each resource. Authentication is handled using Azure CLI.
Features
- Authenticates to an Azure Kubernetes Service (AKS) cluster using Azure CLI.
- Retrieves logs of all pods in a given namespace.
- Describes deployments and services within the specified namespace.
- Saves each log or description as a separate file named after the respective pod, deployment, or service.
- All logs are saved at Build.ArtifactStagingDirectory
Prerequisites
Before using this extension, ensure you have the following:
- An Azure subscription with an existing AKS cluster.
- Azure CLI installed and authenticated.
kubectl
installed and configured.
- An Azure DevOps service connection with appropriate permissions to access the AKS cluster.
This extension requires the following inputs:
Parameter |
Required |
Description |
azureSubscription |
Yes |
Azure subscription ID for authentication. |
resourceGroup |
Yes |
The resource group containing the AKS cluster. |
clusterName |
Yes |
The name of the target AKS cluster. |
namespace |
No |
The Kubernetes namespace to target (default: default ). |
Installation
To use this extension in your Azure DevOps pipeline:
- Add this task to your pipeline YAML.
- Configure the necessary inputs as per the above table.
- Run the pipeline to collect logs and descriptions.
Usage
This extension performs the following steps:
- Logs into Azure using service principal credentials.
- Sets the specified Azure subscription.
- Fetches credentials for the AKS cluster.
- Retrieves logs for all pods in the namespace and saves them as
<pod_name>.log
.
- Describes all deployments in the namespace and saves them as
<deployment_name>.txt
.
- Describes all services in the namespace and saves them as
<service_name>.txt
.
Example
Below is an example YAML snippet to use this extension in an Azure DevOps pipeline:
steps:
- task: <Extension Full Name>@<Extension Version>
displayName: 'Collect AKS Logs and Descriptions'
inputs:
azureSubscription: 'MyAzureSubscription'
resourceGroup: 'MyResourceGroup'
clusterName: 'MyAKSCluster'
namespace: 'mynamespace'
Support
For issues, feature requests, or questions, please create an issue in the GitHub repository or reach out at info@akhilsharma.top.
Contributing
This extension is maintained by Akhil Sharma. While the extension is free to use, any modifications, copies, or reuse of its code or functionality require prior written approval from the author.