Documentation ¶
Index ¶
- func CreateKubeConfig(clusterName string, ca certs.CertificateAuthority, endpoint string, ...) ([]byte, error)
- func CreateMultiKubeConfig(ca certs.CertificateAuthority, clusters map[string]string, group string, ...) ([]byte, error)
- func CreateOIDCKubeConfig(clusterName string, ca certs.CertificateAuthority, ...) ([]byte, error)
- func GetContainerStatus(pod v1.Pod) string
- func GetCurrentClusterNameFrom(kubeConfigPath string) string
- func GetLastRestartTime(pod v1.Pod) *time.Time
- func GetNodeStatus(node v1.Node) string
- func GetPodStatus(pod v1.Pod) string
- func GetUnstructuredObjects(data []byte) ([]unstructured.Unstructured, error)
- func GetValidName(name string) string
- func HasTaint(node v1.Node, name string) bool
- func IsDeleted(object metav1.Object) bool
- func IsMasterNode(node v1.Node) bool
- func IsPodCrashLoopBackoff(pod v1.Pod) bool
- func IsPodDaemonSet(pod v1.Pod) bool
- func IsPodFinished(pod v1.Pod) bool
- func IsPodHealthy(pod v1.Pod) bool
- func IsPodPending(pod v1.Pod) bool
- func IsPodReady(pod v1.Pod) bool
- func IsStaticPod(pod v1.Pod) bool
- func LowResourceRequirements() v1.ResourceRequirements
- func NewCommandJob(node, command string) v1.PodSpec
- func NewDeployment(ns, name, image string, labels map[string]string, port int32, args ...string) *apps.Deployment
- func NewObjectMeta(ns, name string) metav1.ObjectMeta
- func RemoveTaint(taints []v1.Taint, name string) []v1.Taint
- func WaitForNamespace(client kubernetes.Interface, ns string, timeout time.Duration)
- type ApplyHook
- type Client
- func (c *Client) Annotate(obj runtime.Object, annotations map[string]string) error
- func (c *Client) Apply(namespace string, objects ...runtime.Object) error
- func (c *Client) ApplyUnstructured(namespace string, objects ...*unstructured.Unstructured) error
- func (c *Client) Cordon(nodeName string) error
- func (c *Client) CreateOrUpdateConfigMap(name, ns string, data map[string]string) error
- func (c *Client) CreateOrUpdateNamespace(name string, labels, annotations map[string]string) error
- func (c *Client) CreateOrUpdateSecret(name, ns string, data map[string][]byte) error
- func (c *Client) DeleteUnstructured(namespace string, objects ...*unstructured.Unstructured) error
- func (c *Client) ExecutePodf(namespace, pod, container string, command ...string) (string, string, error)
- func (c *Client) Executef(node string, timeout time.Duration, command string, args ...interface{}) (string, error)
- func (c *Client) ExposeIngress(namespace, service string, domain string, port int, ...) error
- func (c *Client) ForceDeleteNamespace(ns string, timeout time.Duration) error
- func (c *Client) Get(namespace string, name string, obj runtime.Object) error
- func (c *Client) GetClientByKind(kind string) (dynamic.NamespaceableResourceInterface, error)
- func (c *Client) GetClientset() (*kubernetes.Clientset, error)
- func (c *Client) GetConditionsForNode(name string) (map[v1.NodeConditionType]v1.ConditionStatus, error)
- func (c *Client) GetConfigMap(namespace, name string) *map[string]string
- func (c *Client) GetDynamicClient() (dynamic.Interface, error)
- func (c *Client) GetDynamicClientFor(namespace string, obj runtime.Object) (dynamic.ResourceInterface, *schema.GroupVersionResource, ...)
- func (c *Client) GetDynamicClientForUser(namespace string, obj runtime.Object, user string) (dynamic.ResourceInterface, *schema.GroupVersionResource, ...)
- func (c *Client) GetEventsFor(kind string, object metav1.Object) ([]v1.Event, error)
- func (c *Client) GetFirstPodByLabelSelector(namespace string, labelSelector string) (*v1.Pod, error)
- func (c *Client) GetHealth() Health
- func (c *Client) GetKustomize() (*kustomize.Manager, error)
- func (c *Client) GetMasterNode() (string, error)
- func (c *Client) GetMasterNodes() ([]string, error)
- func (c *Client) GetOrCreatePVC(namespace, name, size, class string) error
- func (c *Client) GetOrCreateSecret(name, ns string, data map[string][]byte) error
- func (c *Client) GetPodReplicas(pod v1.Pod) (int, error)
- func (c *Client) GetRESTConfig() (*rest.Config, error)
- func (c *Client) GetRestClient(obj unstructured.Unstructured) (*cliresource.Helper, error)
- func (c *Client) GetRestMapper() (meta.RESTMapper, error)
- func (c *Client) GetSecret(namespace, name string) *map[string][]byte
- func (c *Client) HasConfigMap(ns, name string) bool
- func (c *Client) HasSecret(ns, name string) bool
- func (c *Client) Label(obj runtime.Object, labels map[string]string) error
- func (c *Client) PingMaster() bool
- func (c *Client) ResetConnection()
- func (c *Client) ScalePod(pod v1.Pod, replicas int32) error
- func (c *Client) StreamLogs(namespace, name string) error
- func (c *Client) Uncordon(nodeName string) error
- func (c *Client) WaitForDeployment(ns, name string, timeout time.Duration) error
- func (c *Client) WaitForNode(name string, timeout time.Duration, condition v1.NodeConditionType, ...) (map[v1.NodeConditionType]v1.ConditionStatus, error)
- func (c *Client) WaitForPod(ns, name string, timeout time.Duration, phases ...v1.PodPhase) error
- func (c *Client) WaitForPodCommand(ns, name string, container string, timeout time.Duration, command ...string) error
- func (c *Client) WaitForResource(kind, namespace, name string, timeout time.Duration) error
- func (c *Client) WaitForTaintRemoval(name string, timeout time.Duration, taintKey string) error
- type Health
- type PatchApplier
- type PatchType
- type ResourcePatch
- type TemplateManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateKubeConfig ¶
func CreateMultiKubeConfig ¶
func CreateMultiKubeConfig(ca certs.CertificateAuthority, clusters map[string]string, group string, user string, expiry time.Duration) ([]byte, error)
CreateMultiKubeConfig creates a kubeconfig file contents for a map of cluster name -> cluster API endpoint hosts, all with a shared user name, group and cert expiry. NOTE: these clusters all need to share the same plaform CA
func CreateOIDCKubeConfig ¶
func GetContainerStatus ¶
func GetCurrentClusterNameFrom ¶
GetCurrentClusterNameFrom returns the name of the cluster associated with the currentContext of the specified kubeconfig file
func GetNodeStatus ¶
func GetPodStatus ¶
func GetUnstructuredObjects ¶
func GetUnstructuredObjects(data []byte) ([]unstructured.Unstructured, error)
func GetValidName ¶
func IsMasterNode ¶
func IsPodCrashLoopBackoff ¶
func IsPodDaemonSet ¶
func IsPodFinished ¶
func IsPodHealthy ¶
func IsPodPending ¶
func IsPodReady ¶
func IsStaticPod ¶
IsStaticPod returns true if the pod is static i.e. declared in /etc/kubernetes/manifests and read directly by the kubelet
func LowResourceRequirements ¶
func LowResourceRequirements() v1.ResourceRequirements
func NewCommandJob ¶
func NewDeployment ¶
func NewObjectMeta ¶
func NewObjectMeta(ns, name string) metav1.ObjectMeta
func WaitForNamespace ¶
func WaitForNamespace(client kubernetes.Interface, ns string, timeout time.Duration)
Types ¶
type ApplyHook ¶
type ApplyHook func(namespace string, obj unstructured.Unstructured)
type Client ¶
type Client struct { logger.Logger GetKubeConfigBytes func() ([]byte, error) ApplyDryRun bool ApplyHook ApplyHook Trace bool GetKustomizePatches func() ([]string, error) // contains filtered or unexported fields }
func (*Client) ApplyUnstructured ¶
func (c *Client) ApplyUnstructured(namespace string, objects ...*unstructured.Unstructured) error
func (*Client) CreateOrUpdateConfigMap ¶
func (*Client) CreateOrUpdateNamespace ¶
func (*Client) CreateOrUpdateSecret ¶
func (*Client) DeleteUnstructured ¶
func (c *Client) DeleteUnstructured(namespace string, objects ...*unstructured.Unstructured) error
func (*Client) ExecutePodf ¶
func (c *Client) ExecutePodf(namespace, pod, container string, command ...string) (string, string, error)
ExecutePodf runs the specified shell command inside a container of the specified pod
func (*Client) Executef ¶
func (c *Client) Executef(node string, timeout time.Duration, command string, args ...interface{}) (string, error)
Executef runs the specified shell command on a node by creating a pre-scheduled pod that runs in the host namespace
func (*Client) ExposeIngress ¶
func (*Client) ForceDeleteNamespace ¶
ForceDeleteNamespace deletes a namespace forcibly by overriding it's finalizers first
func (*Client) GetClientByKind ¶
func (c *Client) GetClientByKind(kind string) (dynamic.NamespaceableResourceInterface, error)
func (*Client) GetClientset ¶
func (c *Client) GetClientset() (*kubernetes.Clientset, error)
GetClientset creates a new k8s client
func (*Client) GetConditionsForNode ¶
func (c *Client) GetConditionsForNode(name string) (map[v1.NodeConditionType]v1.ConditionStatus, error)
func (*Client) GetConfigMap ¶
GetConfigMap returns the data of a secret or nil for any error
func (*Client) GetDynamicClient ¶
GetDynamicClient creates a new k8s client
func (*Client) GetDynamicClientFor ¶
func (c *Client) GetDynamicClientFor(namespace string, obj runtime.Object) (dynamic.ResourceInterface, *schema.GroupVersionResource, *unstructured.Unstructured, error)
func (*Client) GetDynamicClientForUser ¶
func (c *Client) GetDynamicClientForUser(namespace string, obj runtime.Object, user string) (dynamic.ResourceInterface, *schema.GroupVersionResource, *unstructured.Unstructured, error)
func (*Client) GetEventsFor ¶
func (*Client) GetFirstPodByLabelSelector ¶
func (c *Client) GetFirstPodByLabelSelector(namespace string, labelSelector string) (*v1.Pod, error)
Returns the first pod found by label
func (*Client) GetMasterNode ¶
GetMasterNode returns the name of the first node found labelled as a master
func (*Client) GetMasterNodes ¶
GetMasterNode returns a list of all master nodes
func (*Client) GetOrCreatePVC ¶
func (*Client) GetOrCreateSecret ¶
func (*Client) GetRestClient ¶
func (c *Client) GetRestClient(obj unstructured.Unstructured) (*cliresource.Helper, error)
func (*Client) GetRestMapper ¶
func (c *Client) GetRestMapper() (meta.RESTMapper, error)
func (*Client) HasConfigMap ¶
func (*Client) PingMaster ¶
PingMaster attempts to connect to the API server and list nodes and services to ensure the API server is ready to accept any traffic
func (*Client) ResetConnection ¶
func (c *Client) ResetConnection()
func (*Client) StreamLogs ¶
func (*Client) WaitForDeployment ¶
WaitForDeployment waits for a deployment to have at least 1 ready replica, or returns an error if the timeout is exceeded
func (*Client) WaitForNode ¶
func (c *Client) WaitForNode(name string, timeout time.Duration, condition v1.NodeConditionType, statii ...v1.ConditionStatus) (map[v1.NodeConditionType]v1.ConditionStatus, error)
WaitForNode waits for a pod to be in the specified phase, or returns an error if the timeout is exceeded
func (*Client) WaitForPod ¶
WaitForPod waits for a pod to be in the specified phase, or returns an error if the timeout is exceeded
func (*Client) WaitForPodCommand ¶
func (c *Client) WaitForPodCommand(ns, name string, container string, timeout time.Duration, command ...string) error
WaitForPodCommand waits for a command executed in pod to succeed with an exit code of 9 error if the timeout is exceeded
func (*Client) WaitForResource ¶
type Health ¶
type Health struct {
RunningPods, PendingPods, ErrorPods, CrashLoopBackOff int
ReadyNodes, UnreadyNodes int
Error error
}
func (Health) GetNonReadyPods ¶
func (Health) IsDegradedComparedTo ¶
type PatchApplier ¶
type PatchApplier struct { Clientset *kubernetes.Clientset Log logr.Logger FuncMap template.FuncMap }
func NewPatchApplier ¶
func NewPatchApplier(clientset *kubernetes.Clientset, log logr.Logger) *PatchApplier
func (*PatchApplier) Apply ¶
func (p *PatchApplier) Apply(resource *unstructured.Unstructured, patchStr string, patchType PatchType) (*unstructured.Unstructured, error)
func (*PatchApplier) JSONPath ¶
func (p *PatchApplier) JSONPath(object interface{}, jsonpath string) string
func (*PatchApplier) KGet ¶
func (p *PatchApplier) KGet(path, jsonpath string) string
type ResourcePatch ¶
type ResourcePatch struct { Resource *unstructured.Unstructured Patch string Kind string APIVersion string PatchType PatchType }
type TemplateManager ¶
type TemplateManager struct { Client *Client kubernetes.Interface Log logr.Logger PatchApplier *PatchApplier }
func NewTemplateManager ¶
func NewTemplateManager(c *Client, log logr.Logger) *TemplateManager
func (*TemplateManager) Run ¶
func (tm *TemplateManager) Run(ctx context.Context, template *templatev1.Template) error