kubernetes

package
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

package kubernetes is a colletion of funtions for interactng with a live kubernetes cluster

Index

Constants

View Source
const Platform = "kubernetes"

Platform - kubernetes

Variables

This section is empty.

Functions

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.

func FindKubeConfigPath

func FindKubeConfigPath(path ...string) (string, error)

FindKubeConfigPath checks will return a path for the kubernetes config file

func GetClusterRoleBindingSpec

func GetClusterRoleBindingSpec(ctx context.Context, cs kubernetes.Clientset) (clusterRoleBinding []string, err error)

GetClusterRoleBindingSpec provide a list an of JSON Cluster Role Binding specs from the clientset

func GetDeploymentSpec

func GetDeploymentSpec(ctx context.Context, cs kubernetes.Clientset, namespace string) (deploy []string, err error)

GetDeploymentSpec provide a list an of JSON Deployment specs from the clientset

func GetFormattedJSON

func GetFormattedJSON(source string) (result string)

GetFormattedJSON takes a source string and outputs a formatted JSON string using 2 space characters as the indent

func GetIngressSpec

func GetIngressSpec(ctx context.Context, cs kubernetes.Clientset, namespace string) (ingress []string, err error)

GetIngressSpec provide a list an of JSON Ingress specs from the clientset /!\ The only rule we currently have doesn't seem to be triggerable /!\ K8S-IN-0001: https://github.com/reliablyhq/opa-policies/blob/main/kubernetes/ingress.rego /!\ It looks for identical Ingress hosts in different namespaces, and we are currently working /!\ in only one namespace, passed as a parameter. /!\ Probably a TODO here.

func GetKubernetesClientSet

func GetKubernetesClientSet(kubeconfigPath, context string) (*kubernetes.Clientset, error)

GetKubernetesClientSet uses the default kubectl config file to create a Clientset for the default config

func GetNodeSpec added in v0.6.0

func GetNodeSpec(ctx context.Context, cs kubernetes.Clientset) (nodes []string, err error)

GetNodeSpec returns the list of JSON Nodes specs from the clientset

func GetPodSecurityPolicySpec

func GetPodSecurityPolicySpec(ctx context.Context, cs kubernetes.Clientset) (podSecPol []string, err error)

GetPodSecurityPolicySpec provide a list an of JSON Pod Security Policy specs from the clientset

func GetPodSpec

func GetPodSpec(ctx context.Context, cs kubernetes.Clientset, namespace string) (po []string, err error)

GetPodSpec provide a list an of JSON Pod specs from the clientset

func GetResourceList

func GetResourceList(ctx context.Context, cs kubernetes.Clientset, namespace string) []string

Types

type KubernetesAPI

type KubernetesAPI struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   struct {
		Annotations struct {
		} `json:"annotations"`
		Labels struct {
			App string `json:"app"`
		} `json:"labels"`
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	} `json:"metadata"`
	Spec struct {
		Containers []struct {
			Image string `json:"image"`
			Name  string `json:"name"`
		} `json:"containers"`
		RestartPolicy string `json:"restartPolicy"`
	} `json:"spec"`
}

func GetHeaderInfo

func GetHeaderInfo(content string) (*KubernetesAPI, error)

func (KubernetesAPI) URI

func (m KubernetesAPI) URI() string

Jump to

Keyboard shortcuts

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