k8sutil

package
v1.75.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 42 Imported by: 2

Documentation

Index

Constants

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(kotsadmID string) error

func DeleteKotsadm

func DeleteKotsadm(ctx context.Context, clientset *kubernetes.Clientset, namespace string, isKurl bool) 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 GetClientset

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

func GetClusterConfig

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

func GetCurrentRules

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

func GetK8sVersion

func GetK8sVersion() (string, error)

func GetKotsadmIDConfigMap

func GetKotsadmIDConfigMap() (*corev1.ConfigMap, error)

func GetOpenShiftPodSecurityContext

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

GetOpenShiftPodSecurityContext returns a PodSecurityContext object that has: RunAsUser set to the minimum value in the "openshift.io/sa.scc.uid-range" annotation. FSGroup 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 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(port int) bool

func OpenShiftVersion

func OpenShiftVersion() (string, error)

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 ScaleDownDeployment

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

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(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.Clientset, 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.

Jump to

Keyboard shortcuts

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