kubereasoning

package module
v0.0.0-...-bc54a53 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 8 Imported by: 0

README

KubeReasoning

A reasoning engine for kubernetes clusters using JSONata to manage the data

It is designed to pull out all the config from a cluster - eg with kubectl get pods -A -o=json and then provide an interface to query and work with that data.

for example to get all daemonsets in the cam with a name containing kube, we would run:

    podSet.With(
		"metadata.name~>/kube/i").With(
		"metadata.namespace='cam'").With(
		"metadata.ownerReferences.kind='DaemonSet'").Evaluate()

For details of what the queries can look like, see: http://docs.jsonata.org/overview

This is early, but the extension points are:

  1. adding more convenience methods for filters (eg WithDaemonset(true) to get all daemonsets)
  2. handle more types - deploys, services, secrets, etc
  3. integrate more closely with kubernetes to get the info out - eg:
    • on the CLI using kubectl
    • using the kube client
    • connecting to the cluster this is running as a pod within

possible thngs to check

  • things being in container creating / pending for a long time

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

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

func (*Condition) HoursSince

func (c *Condition) HoursSince() int

type Job

type Job struct {
	// contains filtered or unexported fields
}

jobs

func (*Job) Counts

func (p *Job) Counts() (passedCount, failedCount int, err error)

func (*Job) GetPods

func (p *Job) GetPods() ([]Pod, error)

return the pods for this jobset

func (*Job) LastStatusChange

func (p *Job) LastStatusChange() (condition Condition, err error)

func (*Job) Name

func (p *Job) Name() string

func (*Job) NameSpace

func (p *Job) NameSpace() string

type JobResultType

type JobResultType string
const (
	JobComplete JobResultType = "Complete"
	JobFailed   JobResultType = "Failed"
)

type JobSet

type JobSet struct {
	// contains filtered or unexported fields
}

func LoadJobSetFromFile

func LoadJobSetFromFile(filename string) (*JobSet, error)

static load functions

func LoadJobsetFromKubectl

func LoadJobsetFromKubectl(pods *PodSet) (*JobSet, error)

needs pods passed n so can return the pods for the appropriate job

func (*JobSet) Evaluate

func (ps *JobSet) Evaluate() ([]Job, error)

func (*JobSet) With

func (s *JobSet) With(filter string) *JobSet

With returns a NEW JobSet with this additional filter filter needs to be a valid jsonata filter for items field, eg: "[metadata.name~>`/kube/i`]"

func (*JobSet) WithNamespace

func (ps *JobSet) WithNamespace(namespace string) *JobSet

func (*JobSet) WithType

func (ps *JobSet) WithType(t JobResultType) *JobSet

Type is the result of the job, eg: Complete or Failed

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (*Node) LastStatusChange

func (n *Node) LastStatusChange() (condition Condition, err error)

func (*Node) Name

func (n *Node) Name() string

func (*Node) Statuses

func (n *Node) Statuses() string

type NodeSet

type NodeSet struct {
	// contains filtered or unexported fields
}

func LoadNodeSetFromFile

func LoadNodeSetFromFile(filename string) (*NodeSet, error)

func LoadNodesetFromKubectl

func LoadNodesetFromKubectl() (*NodeSet, error)

func (*NodeSet) Evaluate

func (s *NodeSet) Evaluate() ([]Node, error)

func (*NodeSet) With

func (s *NodeSet) With(filter string) *NodeSet

type Pod

type Pod struct {
	// contains filtered or unexported fields
}

func (*Pod) LastStatusChange

func (p *Pod) LastStatusChange() (condition Condition, err error)

func (*Pod) Name

func (p *Pod) Name() string

func (*Pod) NameSpace

func (p *Pod) NameSpace() string

func (*Pod) Statuses

func (p *Pod) Statuses() string

type PodSet

type PodSet struct {
	// contains filtered or unexported fields
}

func LoadPodSetFromFile

func LoadPodSetFromFile(filename string) (*PodSet, error)

func LoadPodsetFromKubectl

func LoadPodsetFromKubectl() (*PodSet, error)

func (*PodSet) Evaluate

func (ps *PodSet) Evaluate() ([]Pod, error)

func (*PodSet) With

func (s *PodSet) With(filter string) *PodSet

With returns a NEW PodSet with this additional filter filter needs to be a valid jsonata filter for items field, eg: "[metadata.name~>`/kube/i`]"

func (*PodSet) WithIsHealthy

func (ps *PodSet) WithIsHealthy(healthy bool) *PodSet

func (*PodSet) WithKind

func (ps *PodSet) WithKind(kind string) *PodSet

kind can be `Pod`, `DaemonSet`, `Job` etc

func (*PodSet) WithNamespace

func (ps *PodSet) WithNamespace(namespace string) *PodSet

Directories

Path Synopsis
cmd
allClusters command
example command

Jump to

Keyboard shortcuts

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