Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lovemycodesnippets/39e479490370114f444f0384d1e52142 to your computer and use it in GitHub Desktop.
Save lovemycodesnippets/39e479490370114f444f0384d1e52142 to your computer and use it in GitHub Desktop.
pods, err := clientset.CoreV1().Pods("default").List(ctx, metav1.ListOptions{})
if err != nil {
panic(err)
}
for _, pod := range pods.Items {
fmt.Println("Pod:", pod.Name)
}
deployments, err := clientset.AppsV1().Deployments("default").List(ctx, metav1.ListOptions{})
if err != nil {
panic(err)
}
for _, deploy := range deployments.Items {
fmt.Println("Deployment:", deploy.Name)
}
services, err := clientset.CoreV1().Services("default").List(ctx, metav1.ListOptions{})
if err != nil {
panic(err)
}
for _, svc := range services.Items {
fmt.Println("Service:", svc.Name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment