k8sutil

package
v0.0.0-...-6c868a8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints"

Variables

This section is empty.

Functions

func AddOwnerRefToObject

func AddOwnerRefToObject(o metav1.Object, r metav1.OwnerReference)

func CascadeDeleteOptions

func CascadeDeleteOptions(gracePeriodSeconds int64) *metav1.DeleteOptions

func ClusterListOpt

func ClusterListOpt(clusterName string) metav1.ListOptions

We are using internal api types for cluster related.

func CreateAndWaitPod

func CreateAndWaitPod(kubecli kubernetes.Interface, ns string, pod *v1.Pod, timeout time.Duration) (*v1.Pod, error)

CreateAndWaitPod is a workaround for self hosted and util for testing. We should eventually get rid of this in critical code path and move it to test util.

func CreateCRD

func CreateCRD(clientset apiextensionsclient.Interface, crdName, rkind, rplural, shortName string) error

func CreateOrUpdateService

func CreateOrUpdateService(sclient clientv1.ServiceInterface, svc *v1.Service) error

func CreatePatch

func CreatePatch(o, n, datastruct interface{}) ([]byte, error)

func ExecCommandInContainer

func ExecCommandInContainer(context *ExecContext, namespace string, podName string, containerName string, cmd ...string) (string, string, error)

ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error

func ExecCommandInPod

func ExecCommandInPod(context *ExecContext,
	namespace string, podName string, cmd ...string) (string, string, error)

func ExecWithOptions

func ExecWithOptions(context *ExecContext, options ExecOptions) (string, string, error)

ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.

func FakeClusterConfig

func FakeClusterConfig() (*rest.Config, error)

func GetClusterList

func GetClusterList(restcli rest.Interface, ns string) (*api.ReplicatedStatefulSetList, error)

func GetOutput

func GetOutput(pReader *io.PipeReader, result *bytes.Buffer, wg *sync.WaitGroup, tag string)

func GetPodNames

func GetPodNames(pods []*v1.Pod) []string

func GetPodsForStatefulSet

func GetPodsForStatefulSet(cli kubernetes.Interface, sts *apps.StatefulSet) (*api.PodList, error)

func GetStatefulSet

func GetStatefulSet(cli kubernetes.Interface, namespace string, setName string) (*apps.StatefulSet, error)

func ImageName

func ImageName(baseImage, version string) string

func InClusterConfig

func InClusterConfig() (*rest.Config, error)

func IsKubernetesResourceAlreadyExistError

func IsKubernetesResourceAlreadyExistError(err error) bool

func IsKubernetesResourceNotFoundError

func IsKubernetesResourceNotFoundError(err error) bool

func IsNodeReady

func IsNodeReady(n v1.Node) bool

IsNodeReady checks if the Node condition is ready.

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

IsPodReady returns false if the Pod Status is nil

func LabelsForActiveCluster

func LabelsForActiveCluster(clusterName string) map[string]string

func LabelsForCluster

func LabelsForCluster(clusterName string) map[string]string

func MemberRemoveEvent

func MemberRemoveEvent(memberName string, cl *api.ReplicatedStatefulSet) *v1.Event

func MemberUpgradedEvent

func MemberUpgradedEvent(memberName, oldVersion, newVersion string, cl *api.ReplicatedStatefulSet) *v1.Event

func MustNewKubeClient

func MustNewKubeClient() kubernetes.Interface

func MustNewKubeClientFromConfig

func MustNewKubeClientFromConfig(cfg *rest.Config) kubernetes.Interface

func MustNewKubeExtClient

func MustNewKubeExtClient() apiextensionsclient.Interface

func NewMemberAddEvent

func NewMemberAddEvent(memberName string, cl *api.ReplicatedStatefulSet) *v1.Event

func PatchDeployment

func PatchDeployment(kubecli kubernetes.Interface, namespace, name string, updateFunc func(*appsv1beta1.Deployment)) error

func PodSpecToPrettyJSON

func PodSpecToPrettyJSON(pod *v1.Pod) (string, error)

func PodWithNodeSelector

func PodWithNodeSelector(p *v1.Pod, ns map[string]string) *v1.Pod

func ReplacingDeadMemberEvent

func ReplacingDeadMemberEvent(memberName string, cl *api.ReplicatedStatefulSet) *v1.Event

func TestConfig

func TestConfig() (*rest.Config, error)

func WaitCRDReady

func WaitCRDReady(clientset apiextensionsclient.Interface, crdName string) error

Types

type ExecContext

type ExecContext struct {
	Logger *util.RssLogger
	Cli    *kubernetes.Interface
	Config *rest.Config
}

type ExecOptions

type ExecOptions struct {
	Command []string

	Namespace     string
	PodName       string
	ContainerName string

	Stdin         io.Reader
	StdinText     *string
	CaptureStdout bool
	CaptureStderr bool
	// If false, whitespace in std{err,out} will be removed.
	PreserveWhitespace bool

	Timeout time.Duration
}

ExecOptions passed to ExecWithOptions

type ReplicatedStatefulSetCRUpdateFunc

type ReplicatedStatefulSetCRUpdateFunc func(*api.ReplicatedStatefulSet)

ReplicatedStatefulSetCRUpdateFunc is a function to be used when atomically updating a Cluster CR.

type TLSData

type TLSData struct {
	CertData []byte
	KeyData  []byte
	CAData   []byte
}

func GetTLSDataFromSecret

func GetTLSDataFromSecret(kubecli kubernetes.Interface, ns, se string) (*TLSData, error)

Jump to

Keyboard shortcuts

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