How to Efficiently Access Delegate Pod Logs

image

Introduction

Harness Delegate is a powerful service that allows you to seamlessly connect your artifacts, infrastructure, collaboration, verification, and other providers with Harness Manager. By installing Harness Delegate on your local network or VPC and connecting it to third-party resources, you can easily manage all of your operations in one centralized location. For example, if you’re using Kubernetes, you can install the Delegate on your cluster.

Once the Delegate is installed, it becomes responsible for all operations, including deployment and integration. Essentially, everything runs within the Delegate, and all activities are logged in it.

How To

Here’s a step-by-step guide on how to retrieve the delegate’s label value and logs:

Step 1 - Retrieve the delegate’s label value

To retrieve the delegate’s label value, use the following command:

Non-immutable/legacy delegates

export HARNESS_DELEGATE_LABEL=`kubectl get statefulset <statefulset-name> -n <namespace> -o jsonpath='{.metadata.labels.harness\.io/name}'` 

Immutable delegates

export HARNESS_DELEGATE_LABEL=`kubectl get deployment <deployment-name> -n <namespace> -o jsonpath='{.metadata.labels.harness\.io/name}'` 

The kubectl get deployment command retrieves information about a Kubernetes Deployment resource specified by <deployment-name> within the harness-delegate namespace. The -o jsonpath='{.metadata.labels.harness\.io/name}' flag specifies that only the value of the harness.io/name label should be returned in JSON format.

Step 2 - Retrieve logs by using the label selector

To retrieve logs using the label selector, use the following command:

kubectl logs harness.io/name=$HARNESS_DELEGATE_LABEL -n <namespace> --follow

The kubectl logs command is used to retrieve the logs for a particular pod or container running within a Kubernetes cluster.

In this specific case, the command is being used to retrieve the logs for a Harness Delegate running within the Kubernetes cluster. The harness.io/name=$HARNESS_DELEGATE_LABEL part of the command specifies the label selector that will be used to identify the Delegate pod for which logs are to be retrieved. The $HARNESS_DELEGATE_LABEL variable holds the label value for the Delegate, which was obtained in the previous step.

Finally, the --follow flag is used to tail the logs in real-time. This means that new log entries will be displayed as they are generated.

By following these simple steps, you can easily retrieve the delegate’s label value and logs. This information can be incredibly useful when troubleshooting issues or analyzing your deployment processes.

Conclusion

If you have any suggestions on how to improve this article, or helpful and specific examples of permissions related issues that may be of use to others, please leave a comment with the information as this document is intended to evolve over time.
If this article cannot resolve your issue, don’t hesitate to contact us here: support@harness.io – or through the Zendesk portal in Harness SaaS.

1 Like