k8sutil

package
v1.108.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 49 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT_K8S_CLIENT_QPS   = 100
	DEFAULT_K8S_CLIENT_BURST = 100
)
View Source
const (
	KotsadmIDConfigMapName = "kotsadm-id"
)

Variables

View Source
var (
	ErrWaitForPodTimeout = errors.New("timeout waiting for pod")
)

Functions

func AddFlags

func AddFlags(flags *flag.FlagSet)

func CreateKotsadmIDConfigMap

func CreateKotsadmIDConfigMap(clientset kubernetes.Interface, kotsadmID string) error

func DeleteKotsadm

func DeleteKotsadm(ctx context.Context, clientset *kubernetes.Clientset, namespace string, isKurl bool) error

func FindFreePort added in v1.85.0

func FindFreePort(clientset kubernetes.Interface) (int, error)

func FindKotsadm

func FindKotsadm(clientset *kubernetes.Clientset, namespace string) (string, error)

func FindKotsadmImage

func FindKotsadmImage(namespace string) (string, error)

func GenerateBootstrapToken

func GenerateBootstrapToken(client kubernetes.Interface, ttl time.Duration) (string, error)

GenerateBootstrapToken will generate a node join token for kubeadm. ttl defines the time to live for this token.

func GenerateK0sBootstrapToken added in v1.105.0

func GenerateK0sBootstrapToken(client kubernetes.Interface, ttl time.Duration, role string) (string, error)

func GetClientset

func GetClientset() (*kubernetes.Clientset, error)

func GetClusterCaCert added in v1.105.0

func GetClusterCaCert(ctx context.Context, client kubernetes.Interface) (string, error)

func GetClusterConfig

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

func GetCurrentRules

func GetCurrentRules(deployOptions kotsadmtypes.DeployOptions, clientset *kubernetes.Clientset) ([]rbacv1.PolicyRule, error)

func GetDynamicClient added in v1.98.3

func GetDynamicClient() (dynamic.Interface, error)

func GetDynamicResourceInterface added in v1.100.0

func GetDynamicResourceInterface(gvk *schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error)

func GetK8sMinorVersion added in v1.101.1

func GetK8sMinorVersion(clientset kubernetes.Interface) (int, error)

func GetK8sVersion

func GetK8sVersion(clientset kubernetes.Interface) (string, error)

func GetKotsadmID added in v1.103.2

func GetKotsadmID(clientset kubernetes.Interface) string

func GetKotsadmIDConfigMap

func GetKotsadmIDConfigMap(clientset kubernetes.Interface) (*corev1.ConfigMap, error)

func GetOpenShiftPodSecurityContext

func GetOpenShiftPodSecurityContext(kotsadmNamespace string, strictSecurityContext bool) (*corev1.PodSecurityContext, error)

GetOpenShiftPodSecurityContext returns a PodSecurityContext object that has: User set to the minimum value in the "openshift.io/sa.scc.uid-range" annotation. Group set to the minimum value in the "openshift.io/sa.scc.supplemental-groups" annotation if exists, else falls back to the minimum value in the "openshift.io/sa.scc.uid-range" annotation.

func GetPodLogs

func GetPodLogs(ctx context.Context, clientset kubernetes.Interface, pod *corev1.Pod, follow bool, maxLines *int64) ([]byte, error)

func InitHelmCapabilities

func InitHelmCapabilities() error

func IsGKEAutopilot added in v1.91.1

func IsGKEAutopilot(clientset kubernetes.Interface) bool

IsGKEAutopilot returns true if the cluster is positively identified as being an autopilot cluster in GKE

func IsKotsadmClusterScoped

func IsKotsadmClusterScoped(ctx context.Context, clientset kubernetes.Interface, namespace string) bool

IsKotsadmClusterScoped will check if kotsadm has cluster scope access or not

func IsKotsadmIDConfigMapPresent

func IsKotsadmIDConfigMapPresent() (bool, error)

func IsOpenShift

func IsOpenShift(clientset kubernetes.Interface) bool

IsOpenShift returns true if the cluster is positively identified as being an openshift cluster

func IsPortAvailable

func IsPortAvailable(clientset kubernetes.Interface, port int) (bool, error)

func MergeEnvVars

func MergeEnvVars(desired []corev1.EnvVar, existing []corev1.EnvVar, override bool) []corev1.EnvVar

func MergeImagePullSecrets added in v1.94.0

func MergeImagePullSecrets(desired []corev1.LocalObjectReference, existing []corev1.LocalObjectReference, override bool) []corev1.LocalObjectReference

func MergeVolumeMounts added in v1.94.0

func MergeVolumeMounts(desired []corev1.VolumeMount, existing []corev1.VolumeMount, override bool) []corev1.VolumeMount

func MergeVolumes added in v1.94.0

func MergeVolumes(desired []corev1.Volume, existing []corev1.Volume, override bool) []corev1.Volume

func PodsHaveTheSameOwner

func PodsHaveTheSameOwner(pods []corev1.Pod) bool

func PortForward

func PortForward(localPort int, remotePort int, namespace string, getPodName func() (string, error), pollForAdditionalPorts bool, stopCh <-chan struct{}, log *logger.CLILogger) (int, chan error, error)

PortForward starts a local port forward to a pod in the cluster if localport is set, it will attempt to use that port locally. always check the port number returned though, because a port conflict could cause a different port to be used

func ReadKustomizationFromFile

func ReadKustomizationFromFile(file string) (*kustomizetypes.Kustomization, error)

func RestartKotsadm added in v1.89.0

func RestartKotsadm(ctx context.Context, clientset *kubernetes.Clientset, namespace string, timeout time.Duration) error

func ScaleDownDeployment

func ScaleDownDeployment(ctx context.Context, clientset kubernetes.Interface, namespace string, deploymentName string) error

func SecureContainerContext added in v1.98.0

func SecureContainerContext(isStrict bool) *corev1.SecurityContext

func SecurePodContext added in v1.98.0

func SecurePodContext(user int64, group int64, isStrict bool) *corev1.PodSecurityContext

func ServiceForward

func ServiceForward(clientset *kubernetes.Clientset, cfg *rest.Config, localPort int, remotePort int, namespace string, serviceName string) (chan struct{}, error)

func UpdateKotsadmIDConfigMap

func UpdateKotsadmIDConfigMap(clientset kubernetes.Interface, kotsadmID string) error

func WaitForDeploymentReady

func WaitForDeploymentReady(ctx context.Context, clientset kubernetes.Interface, namespace string, deploymentName string, timeout time.Duration) error

func WaitForKotsadm

func WaitForKotsadm(clientset kubernetes.Interface, namespace string, timeoutWaitingForWeb time.Duration) (string, error)

func WaitForPod

func WaitForPod(ctx context.Context, clientset kubernetes.Interface, namespace string, podName string, timeoutWaitingForPod time.Duration) error

func WaitForStatefulSetReady

func WaitForStatefulSetReady(ctx context.Context, clientset kubernetes.Interface, namespace string, statefulSetName string, timeout time.Duration) error

func WriteKustomizationToFile

func WriteKustomizationToFile(kustomization kustomizetypes.Kustomization, file string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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