kubectl

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentContext

func CurrentContext() (string, error)

func GetConfigMapKeyValue

func GetConfigMapKeyValue(ref *KeyRef, namespace string) (string, error)

func GetSecretKeyValue

func GetSecretKeyValue(ref *KeyRef, namespace string) (string, error)

func IstioIngress

func IstioIngress() (string, error)

func ListLabels

func ListLabels(resources string, namespace string, allNamespaces bool) ([]string, error)

func ListResources

func ListResources(resources, namespace string, allNamespaces bool) ([]string, error)

func Logs

func Logs(container *Container, since string, previous bool) ([]byte, error)

func MeshesHosts

func MeshesHosts() ([]string, error)

func RemoveLabels

func RemoveLabels(resources string, label string, namespace string, allNamespaces bool) error

func SaveLogs

func SaveLogs(containers *Containers, since string, previous bool)

func SaveResourcesManifests

func SaveResourcesManifests(resources []*resource, keepStatus, decodeSecrets bool) error

func SelectLabel

func SelectLabel(resources string, namespace string, allNamespaces bool) (string, error)

func SelectResources

func SelectResources(resources, namespace string, allNamespaces bool) ([]*resource, error)

Types

type ConfigMap

type ConfigMap struct {
	Data     map[string]string `json:"data"`
	Kind     string            `json:"kind"`
	Metadata struct {
		Labels    map[string]string `json:"labels"`
		Name      string            `json:"name"`
		Namespace string            `json:"namespace"`
	} `json:"metadata"`
}

type ConfigMaps

type ConfigMaps struct {
	Items []*ConfigMap `json:"items"`
}

func ListConfigMaps

func ListConfigMaps() (*ConfigMaps, error)

func SearchConfigMap

func SearchConfigMap(label string) (*ConfigMaps, error)

func (*ConfigMaps) Get

func (m *ConfigMaps) Get(name string) *ConfigMap

func (*ConfigMaps) Names

func (m *ConfigMaps) Names() []string

func (*ConfigMaps) SelectOne

func (m *ConfigMaps) SelectOne() (*ConfigMap, error)

func (*ConfigMaps) SingleResult

func (m *ConfigMaps) SingleResult() (*ConfigMap, error)

type Container

type Container struct {
	Namespace       string
	Pod             string
	PodTemplateHash string
	Single          bool
	Name            string `json:"name"`
	Ports           []*struct {
		ContainerPort int    `json:"containerPort"`
		Name          string `json:"name"`
		Protocol      string `json:"protocol"`
	} `json:"ports"`
	Args            []string `json:"args"`
	Command         []string `json:"command"`
	Env             []*Env   `json:"env"`
	Image           string   `json:"image"`
	ImagePullPolicy string   `json:"imagePullPolicy"`
	Resources       struct {
		Limits struct {
			CPU    string `json:"cpu"`
			Memory string `json:"memory"`
		} `json:"limits"`
		Requests struct {
			CPU    string `json:"cpu"`
			Memory string `json:"memory"`
		} `json:"requests"`
	} `json:"resources"`
	SecurityContext struct {
		AllowPrivilegeEscalation bool `json:"allowPrivilegeEscalation"`
		Capabilities             struct {
			Drop []string `json:"drop"`
		} `json:"capabilities"`
		ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
		RunAsGroup             int  `json:"runAsGroup"`
		RunAsNonRoot           bool `json:"runAsNonRoot"`
		RunAsUser              int  `json:"runAsUser"`
	} `json:"securityContext"`
	TerminationMessagePath   string `json:"terminationMessagePath"`
	TerminationMessagePolicy string `json:"terminationMessagePolicy"`
	VolumeMounts             []*struct {
		MountPath string `json:"mountPath"`
		Name      string `json:"name"`
		ReadOnly  bool   `json:"readOnly,omitempty"`
	} `json:"volumeMounts"`
	LivenessProbe struct {
		FailureThreshold    *int `json:"failureThreshold"`
		InitialDelaySeconds *int `json:"initialDelaySeconds"`
		PeriodSeconds       *int `json:"periodSeconds"`
		SuccessThreshold    *int `json:"successThreshold"`
		TimeoutSeconds      *int `json:"timeoutSeconds"`
	} `json:"livenessProbe"`
	ReadinessProbe struct {
		FailureThreshold    *int `json:"failureThreshold"`
		InitialDelaySeconds *int `json:"initialDelaySeconds"`
		PeriodSeconds       *int `json:"periodSeconds"`
		SuccessThreshold    *int `json:"successThreshold"`
		TimeoutSeconds      *int `json:"timeoutSeconds"`
	} `json:"readinessProbe"`
	Status *ContainerStatus
}

func (*Container) GetEnv

func (c *Container) GetEnv(key string) string

func (*Container) GetState

func (c *Container) GetState() ContainerStateEvent

func (*Container) LastUpdateTime

func (c *Container) LastUpdateTime() *time.Time

type ContainerState

type ContainerState struct {
	Running    *ContainerStateRunning    `json:"running"`
	Terminated *ContainerStateTerminated `json:"terminated"`
	Waiting    *ContainerStateWaiting    `json:"waiting"`
}

func (*ContainerState) Event

type ContainerStateEvent

type ContainerStateEvent interface {
	GetColor() string
	GetReason() string
	GetTime() *time.Time
}

type ContainerStateRunning

type ContainerStateRunning struct {
	StartedAt *time.Time `json:"startedAt"`
}

func (*ContainerStateRunning) GetColor

func (c *ContainerStateRunning) GetColor() string

func (*ContainerStateRunning) GetReason

func (c *ContainerStateRunning) GetReason() string

func (*ContainerStateRunning) GetTime

func (c *ContainerStateRunning) GetTime() *time.Time

type ContainerStateTerminated

type ContainerStateTerminated struct {
	ContainerID string     `json:"containerID"`
	ExitCode    int        `json:"exitCode"`
	FinishedAt  *time.Time `json:"finishedAt"`
	Message     string     `json:"message"`
	Reason      string     `json:"reason"`
	Signal      int        `json:"signal"`
	StartedAt   *time.Time `json:"startedAt"`
}

func (*ContainerStateTerminated) GetColor

func (c *ContainerStateTerminated) GetColor() string

func (*ContainerStateTerminated) GetReason

func (c *ContainerStateTerminated) GetReason() string

func (*ContainerStateTerminated) GetTime

func (c *ContainerStateTerminated) GetTime() *time.Time

type ContainerStateWaiting

type ContainerStateWaiting struct {
	Message string `json:"message"`
	Reason  string `json:"reason"`
}

func (*ContainerStateWaiting) GetColor

func (c *ContainerStateWaiting) GetColor() string

func (*ContainerStateWaiting) GetReason

func (c *ContainerStateWaiting) GetReason() string

func (*ContainerStateWaiting) GetTime

func (c *ContainerStateWaiting) GetTime() *time.Time

type ContainerStatus

type ContainerStatus struct {
	ContainerID  string          `json:"containerID"`
	Image        string          `json:"image"`
	ImageID      string          `json:"imageID"`
	Name         string          `json:"name"`
	Ready        bool            `json:"ready"`
	RestartCount int             `json:"restartCount"`
	Started      bool            `json:"started"`
	LastState    *ContainerState `json:"lastState"`
	State        *ContainerState `json:"state"`
}

func (*ContainerStatus) CurrentState

func (cs *ContainerStatus) CurrentState() ContainerStateEvent

type Containers

type Containers struct {
	Items []*Container
}

func ListContainers

func ListContainers(namespace string, allNamespaces bool, selector string) (*Containers, error)

func ListContainersByDeployment

func ListContainersByDeployment(deploy *Deployment) (*Containers, error)

func (*Containers) Contains

func (c *Containers) Contains(containerName string) bool

func (*Containers) CountByPod

func (c *Containers) CountByPod(pod string) int

func (*Containers) FilterExposed

func (c *Containers) FilterExposed() *Containers

func (*Containers) Names

func (c *Containers) Names() []string

func (*Containers) Namespaces

func (c *Containers) Namespaces() []string

func (*Containers) Pods

func (c *Containers) Pods() []string

func (*Containers) SelectMany

func (c *Containers) SelectMany() (*Containers, error)

type Deployment

type Deployment struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   struct {
		Annotations struct {
			DeploymentKubernetesIoRevision              string `json:"deployment.kubernetes.io/revision"`
			KubectlKubernetesIoLastAppliedConfiguration string `json:"kubectl.kubernetes.io/last-applied-configuration"`
		} `json:"annotations"`
		CreationTimestamp time.Time `json:"creationTimestamp"`
		Generation        int       `json:"generation"`
		Labels            struct {
			App     string `json:"app"`
			Release string `json:"release"`
			Version string `json:"version"`
		} `json:"labels"`
		Name            string `json:"name"`
		Namespace       string `json:"namespace"`
		ResourceVersion string `json:"resourceVersion"`
		SelfLink        string `json:"selfLink"`
		UID             string `json:"uid"`
	} `json:"metadata"`
	Spec struct {
		Replicas int `json:"replicas"`
		Selector struct {
			MatchLabels map[string]string `json:"matchLabels"`
		} `json:"selector"`
		Template struct {
			Metadata struct {
				Annotations map[string]string `json:"annotations"`
				Labels      map[string]string `json:"labels"`
			} `json:"metadata"`
			Spec struct {
				Containers []*Container `json:"containers"`
			} `json:"spec"`
		} `json:"template"`
	} `json:"spec"`
	Status struct {
		AvailableReplicas  int                `json:"availableReplicas"`
		Conditions         []*StatusCondition `json:"conditions"`
		ObservedGeneration int                `json:"observedGeneration"`
		ReadyReplicas      int                `json:"readyReplicas"`
		Replicas           int                `json:"replicas"`
		UpdatedReplicas    int                `json:"updatedReplicas"`
	} `json:"status"`
}

func (*Deployment) GetContainer

func (d *Deployment) GetContainer(name string) *Container

func (*Deployment) HasIstioSidecar

func (d *Deployment) HasIstioSidecar() bool

func (*Deployment) IsInjectable

func (d *Deployment) IsInjectable() bool

func (*Deployment) LastUpdateTime

func (d *Deployment) LastUpdateTime() *time.Time

func (*Deployment) StatusColor

func (d *Deployment) StatusColor() string

type Deployments

type Deployments struct {
	Items []*Deployment `json:"items"`
}

func ListAllDeployments

func ListAllDeployments() (*Deployments, error)

func ListDeployments

func ListDeployments(namespace string, allNamespaces bool) (*Deployments, error)

func (*Deployments) FilterInjectable

func (d *Deployments) FilterInjectable() *Deployments

func (*Deployments) FilterInjected

func (d *Deployments) FilterInjected() *Deployments

func (*Deployments) FilterUninjected

func (d *Deployments) FilterUninjected() *Deployments

func (*Deployments) FullNames

func (d *Deployments) FullNames() []string

func (*Deployments) Get

func (d *Deployments) Get(name string) *Deployment

func (*Deployments) ListContainers

func (d *Deployments) ListContainers() (*Containers, error)

func (*Deployments) Names

func (d *Deployments) Names() []string

func (*Deployments) Namespaces

func (d *Deployments) Namespaces() []string

func (*Deployments) Rollout

func (d *Deployments) Rollout() error

func (*Deployments) SelectContainers

func (d *Deployments) SelectContainers() (*Containers, error)

func (*Deployments) SelectMany

func (d *Deployments) SelectMany() (*Deployments, error)

func (*Deployments) SelectOne

func (d *Deployments) SelectOne() (*Deployment, error)

type Env

type Env struct {
	Name      string     `json:"name,omitempty"`
	Value     string     `json:"value,omitempty"`
	ValueFrom *ValueFrom `json:"valueFrom,omitempty"`
}

type GenericResource

type GenericResource struct {
	Kind     string `json:"kind"`
	Metadata struct {
		Labels    map[string]string `json:"labels"`
		Name      string            `json:"name"`
		Namespace string            `json:"namespace"`
	} `json:"metadata"`
}

type GenericResources

type GenericResources struct {
	Items []*GenericResource `json:"items"`
}

type Ingress

type Ingress extensions.Ingress

func ListIngresses

func ListIngresses() ([]*Ingress, error)

func (*Ingress) ExternalIP

func (i *Ingress) ExternalIP() string

type IngressIP

type IngressIP struct {
	Hostname string `json:"hostname"`
	IP       string `json:"ip"`
}

type Ingresses

type Ingresses struct {
	Items []*Ingress `json:"items"`
}

func SearchIngress

func SearchIngress(label string) (*Ingresses, error)

type IstioGateway

type IstioGateway struct {
	Metadata struct {
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	} `json:"metadata"`
	Spec struct {
		Selector map[string]string `json:"selector"`
		Servers  []struct {
			Hosts []string `json:"hosts"`
		} `json:"servers"`
	} `json:"spec"`
}

func ListAllIstioGateways

func ListAllIstioGateways() ([]*IstioGateway, error)

type IstioGateways

type IstioGateways struct {
	Items []*IstioGateway `json:"items"`
}

type Item

type Item struct {
	APIVersion string   `json:"apiVersion"`
	Kind       string   `json:"kind"`
	Metadata   Metadata `json:"metadata"`
	Dependents int      `json:"-"`
}

func ListResourcesOwners

func ListResourcesOwners(resources, namespace string, allNamespaces bool) ([]Item, error)

type KeyRef

type KeyRef struct {
	Key      string `json:"key,omitempty"`
	Name     string `json:"name,omitempty"`
	Optional bool   `json:"optional,omitempty"`
}

type LoadBalancer

type LoadBalancer struct {
	Ingresses []*IngressIP `json:"ingress"`
}

type Metadata

type Metadata struct {
	Labels          map[string]string `json:"labels"`
	Name            string            `json:"name"`
	Namespace       string            `json:"namespace"`
	Generation      int               `json:"generation"`
	ResourceVersion string            `json:"resourceVersion"`
	UID             string            `json:"uid"`
	OwnerReferences []*OwnerReference `json:"ownerReferences"`
}

type Namespace

type Namespace struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   struct {
		CreationTimestamp time.Time         `json:"creationTimestamp"`
		Name              string            `json:"name"`
		ResourceVersion   string            `json:"resourceVersion"`
		SelfLink          string            `json:"selfLink"`
		UID               string            `json:"uid"`
		Labels            map[string]string `json:"labels"`
	} `json:"metadata"`
	Spec struct {
		Finalizers []string `json:"finalizers"`
	} `json:"spec"`
	Status struct {
		Phase string `json:"phase"`
	} `json:"status"`
}

type Namespaces

type Namespaces struct {
	Items []*Namespace `json:"items"`
}

func ListNamespaces

func ListNamespaces() (*Namespaces, error)

func (*Namespaces) Get

func (n *Namespaces) Get(name string) *Namespace

func (*Namespaces) Names

func (n *Namespaces) Names() []string

func (*Namespaces) SelectMany

func (n *Namespaces) SelectMany() (*Namespaces, error)

func (*Namespaces) SelectOne

func (n *Namespaces) SelectOne() (*Namespace, error)

type OwnerReference

type OwnerReference struct {
	APIVersion         string `json:"apiVersion"`
	BlockOwnerDeletion bool   `json:"blockOwnerDeletion"`
	Controller         bool   `json:"controller"`
	Kind               string `json:"kind"`
	Name               string `json:"name"`
	UID                string `json:"uid"`
}

type Pod

type Pod struct {
	Metadata struct {
		Labels            map[string]string `json:"labels"`
		Name              string            `json:"name"`
		Namespace         string            `json:"namespace"`
		OwnerReferences   []*OwnerReference `json:"ownerReferences"`
		CreationTimestamp time.Time         `json:"creationTimestamp"`
	} `json:"metadata"`
	Spec struct {
		Containers     []*Container `json:"containers"`
		InitContainers []*Container `json:"initContainers"`
	} `json:"spec"`
	Status struct {
		Conditions []struct {
			LastTransitionTime time.Time `json:"lastTransitionTime"`
			Status             string    `json:"status"`
			Type               string    `json:"type"`
		} `json:"conditions"`
		ContainerStatuses     []*ContainerStatus `json:"containerStatuses"`
		HostIP                string             `json:"hostIP"`
		InitContainerStatuses []*ContainerStatus `json:"initContainerStatuses"`
		Phase                 string             `json:"phase"`
		PodIP                 string             `json:"podIP"`
		PodIPs                []struct {
			IP string `json:"ip"`
		} `json:"podIPs"`
		QosClass  string    `json:"qosClass"`
		StartTime time.Time `json:"startTime"`
	} `json:"status"`
}

func (*Pod) ContainsLabels

func (p *Pod) ContainsLabels(labels map[string][]string) bool

func (*Pod) CurrentStatus

func (p *Pod) CurrentStatus() string

func (*Pod) EnvironmentVariables

func (p *Pod) EnvironmentVariables() []*Env

func (*Pod) GetContainerStatus

func (p *Pod) GetContainerStatus(container string) *ContainerStatus

func (*Pod) HasIstioSidecar

func (p *Pod) HasIstioSidecar() bool

func (*Pod) IsJob

func (p *Pod) IsJob() bool

func (*Pod) LastState

func (p *Pod) LastState() ContainerStateEvent

func (*Pod) LastUpdate

func (p *Pod) LastUpdate() *time.Time

func (*Pod) Ready

func (p *Pod) Ready() string

func (*Pod) RestartCount

func (p *Pod) RestartCount() int

func (*Pod) SelectContainerPort

func (p *Pod) SelectContainerPort() (int, error)

func (*Pod) StatusColor

func (p *Pod) StatusColor() string

type Pods

type Pods struct {
	Items []*Pod `json:"items"`
}

func ListAllPods

func ListAllPods() (*Pods, error)

func ListPods

func ListPods(namespace string, allNamespaces bool, selector string) (*Pods, error)

func (*Pods) Containers

func (s *Pods) Containers() *Containers

func (*Pods) Labels

func (s *Pods) Labels() map[string][]string

func (*Pods) Namespaces

func (s *Pods) Namespaces(labels map[string][]string) []string

func (*Pods) Pods

func (s *Pods) Pods(namespace string, labels map[string][]string) []*Pod

func (*Pods) SelectContainerPort

func (s *Pods) SelectContainerPort(namespace string, labels map[string][]string) (int, error)

func (*Pods) SelectLabels

func (s *Pods) SelectLabels() (map[string][]string, error)

func (*Pods) SelectMany

func (s *Pods) SelectMany() (*Pods, error)

func (*Pods) SelectNamespace

func (s *Pods) SelectNamespace(labels map[string][]string) (string, error)

func (*Pods) SelectOne

func (s *Pods) SelectOne() (*Pod, error)

type ResourceDefinition

type ResourceDefinition struct {
	Name       string
	ShortNames []string
	APIGroup   string
	Namespaced bool
	Kind       string
	Verbs      []string
}

func NewResourceDefinition

func NewResourceDefinition(line string, indexes []int) (*ResourceDefinition, error)

func (*ResourceDefinition) String

func (r *ResourceDefinition) String() string

type ResourcesDefinitions

type ResourcesDefinitions struct {
	Items []*ResourceDefinition
}

func ListResourceDefinitions

func ListResourceDefinitions() (*ResourcesDefinitions, error)

func (*ResourcesDefinitions) APIGroups

func (r *ResourcesDefinitions) APIGroups() []string

func (*ResourcesDefinitions) FilterAPIGroup

func (r *ResourcesDefinitions) FilterAPIGroup(group string) *ResourcesDefinitions

func (*ResourcesDefinitions) FilterNamespaced

func (r *ResourcesDefinitions) FilterNamespaced() *ResourcesDefinitions

func (*ResourcesDefinitions) FilterVerbs

func (r *ResourcesDefinitions) FilterVerbs(verb string) *ResourcesDefinitions

func (*ResourcesDefinitions) SelectGroups

func (r *ResourcesDefinitions) SelectGroups() ([]string, error)

func (*ResourcesDefinitions) String

func (r *ResourcesDefinitions) String() string

type Rule

type Rule struct {
	Host string `json:"host"`
}

type Secret

type Secret struct {
	Data     map[string]string `json:"data"`
	Kind     string            `json:"kind"`
	Metadata struct {
		Labels    map[string]string `json:"labels"`
		Name      string            `json:"name"`
		Namespace string            `json:"namespace"`
	} `json:"metadata"`
}

type Secrets

type Secrets struct {
	Items []*Secret `json:"items"`
}

func ListSecrets

func ListSecrets() (*Secrets, error)

func ListTLSSecrets

func ListTLSSecrets() (*Secrets, error)

func SearchSecret

func SearchSecret(label string) (*Secrets, error)

func (*Secrets) FullNames

func (m *Secrets) FullNames() []string

func (*Secrets) Get

func (m *Secrets) Get(name string) *Secret

func (*Secrets) Names

func (m *Secrets) Names() []string

func (*Secrets) SelectMany

func (m *Secrets) SelectMany() (*Secrets, error)

func (*Secrets) SelectOne

func (m *Secrets) SelectOne() (*Secret, error)

func (*Secrets) SingleResult

func (m *Secrets) SingleResult() (*Secret, error)

type Service

type Service struct {
	Metadata struct {
		Labels    map[string]string `json:"labels"`
		Name      string            `json:"name"`
		Namespace string            `json:"namespace"`
	} `json:"metadata"`
	Spec struct {
		Ports []struct {
			NodePort int    `json:"nodePort"`
			Port     int    `json:"port"`
			Protocol string `json:"protocol"`
		} `json:"ports"`
		Selector map[string]string `json:"selector"`
		Type     string            `json:"type"`
	} `json:"spec"`
	Status struct {
		LoadBalancer struct {
			Ingresses []struct {
				Hostname string `json:"hostname"`
				IP       string `json:"ip"`
			} `json:"ingress"`
		} `json:"loadBalancer"`
	} `json:"status"`
}

func (*Service) ExternalIP

func (s *Service) ExternalIP() string

type Services

type Services struct {
	Items []*Service `json:"items"`
}

func ListServices

func ListServices() (*Services, error)

func (*Services) FilterByType

func (s *Services) FilterByType(t string) *Services

func (*Services) LabelKeys

func (s *Services) LabelKeys() []string

func (*Services) Labels

func (s *Services) Labels() map[string][]string

func (*Services) Namespaces

func (s *Services) Namespaces(labels map[string][]string) []string

func (*Services) SelectLabels

func (s *Services) SelectLabels() (map[string][]string, error)

type Spec

type Spec struct {
	Rules []*Rule `json:"rules"`
}

type Status

type Status struct {
	LoadBalancer LoadBalancer `json:"loadBalancer"`
}

type StatusCondition

type StatusCondition struct {
	LastTransitionTime time.Time `json:"lastTransitionTime"`
	LastUpdateTime     time.Time `json:"lastUpdateTime"`
	Message            string    `json:"message"`
	Reason             string    `json:"reason"`
	Status             string    `json:"status"`
	Type               string    `json:"type"`
}

type ValueFrom

type ValueFrom struct {
	ConfigMapKeyRef *KeyRef `json:"configMapKeyRef,omitempty"`
	SecretKeyRef    *KeyRef `json:"secretKeyRef,omitempty"`
}

Jump to

Keyboard shortcuts

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