I\'m looking for the solution of how to get logs from a pod in Kubernetes cluster using golang. I\'ve looked at \"https://github.com/kubernetes/client-go\" and \"https://god
@Emixam23
I believe you will find this snippet useful.
How to get the dynamic name of a pod?
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labelSelector := metav1.LabelSelector{MatchLabels: map[string]string{: }}
listOptions := metav1.ListOptions{
LabelSelector: labels.Set(labelSelector.MatchLabels).String(),
}
pod, err := k8sClient.CoreV1().Pods().List(listOptions)
podName := pod.Items[0].ObjectMeta.Name