bad_pods

package
v0.77.0-dev-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "bad-pods",
	Short:   "Get bad pods (all pods without them with Phase in: Running, Succeeded",
	Aliases: []string{"bp"},
	Args:    cobra.NoArgs,
	Run: func(c *cobra.Command, args []string) {
		clientset, defaultNamespace, _ := k8s.KubernetesClient()

		namespace := defaultNamespace
		if FlagNamespace != "" {
			namespace = FlagNamespace
		}

		if FlagAllNamespaces {
			namespace = ""
		}

		podClient := clientset.CoreV1().Pods(namespace)
		pods, err := podClient.List(context.TODO(), metav1.ListOptions{})
		if err != nil {
			log.Fatal(err)
		}
		for _, pod := range pods.Items {
			if pod.Status.Phase == "Running" {
				continue
			}
			if pod.Status.Phase == "Succeeded" {
				continue
			}
			fmt.Println(pod.Namespace, pod.Name, pod.Status.Phase)
		}
	},
}
View Source
var FlagAllNamespaces bool
View Source
var FlagNamespace string

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL