k8sapi

package
v0.0.0-...-97303f7 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnected = errors.New("client is not connected to etcd")

ErrNotConnected is returned when the client is not connected to etcd.

Functions

func GetKubeConfigPath

func GetKubeConfigPath() (string, error)

GetKubeConfigPath returns the path to the kubeconfig file.

Types

type Client

type Client struct {
	Client kubernetes.Interface

	RestConfig *rest.Config

	SharedStore store.Store
	// contains filtered or unexported fields
}

Client is the struct used to access kubernetes helpers.

func NewClient

func NewClient(logger *zap.Logger) (kubeClient *Client, err error)

NewClient returns a new kuberenetes client-go wrapper. if no kubeconfig path is given we use the service account token.

func (*Client) AddDataToConfigMap

func (k *Client) AddDataToConfigMap(ctx context.Context, namespace, mapName, key, value string) error

AddDataToConfigMap adds data do a given configmap.

func (*Client) ConnectToStoreExternal

func (k *Client) ConnectToStoreExternal(creds *config.EtcdCredentials, endpoints []string) error

ConnectToStoreExternal connects to the etcd store.

func (*Client) ConnectToStoreInternal

func (k *Client) ConnectToStoreInternal() error

GetStore returns a store backed by kube etcd. Its only supposed to used within a kubernetes pod. Before calling this the installer needs to populate a config map with the respective credentials. Furthermore a serviceaccount must be set up for the namespace and it needs to be attached to the running pod.

func (*Client) CreateClusterRoleBinding

func (k *Client) CreateClusterRoleBinding(ctx context.Context, namespace, name string) error

CreateClusterRoleBinding creates a clusterRoleBinding.

func (*Client) CreateConfigMap

func (k *Client) CreateConfigMap(ctx context.Context, namespace, name string) error

CreateConfigMap creates a configmap.

func (*Client) CreateExecInPod

func (k *Client) CreateExecInPod(ctx context.Context, namespace, podName, command string, stdin io.Reader, stdout io.Writer, stderr io.Writer, resizeQueue remotecommand.TerminalSizeQueue, tty bool) error

CreateExecInPod creates a shell on the specified pod.

func (*Client) CreateGraderDeployment

func (k *Client) CreateGraderDeployment(ctx context.Context, namespace, deploymentName string, replicas int32) error

CreateGraderDeployment creates a Grade Server deployment.

func (*Client) CreateHeadlessService

func (k *Client) CreateHeadlessService(ctx context.Context, identifier *config.KubeRessourceIdentifier) error

CreateHeadlessService creates a service.

func (*Client) CreateIngress

func (k *Client) CreateIngress(ctx context.Context, namespace string) error

CreateIngress creates an ingress.

func (*Client) CreateNamespace

func (k *Client) CreateNamespace(ctx context.Context, namespace string) error

CreateNamespace creates a namespace.

func (*Client) CreatePersistentVolume

func (k *Client) CreatePersistentVolume(ctx context.Context, identifier *config.KubeRessourceIdentifier) error

CreatePersistentVolume creates a persistent volume.

func (*Client) CreatePersistentVolumeClaim

func (k *Client) CreatePersistentVolumeClaim(ctx context.Context, identifier *config.KubeRessourceIdentifier) error

CreatePersistentVolumeClaim creates a persistent volume claim.

func (*Client) CreatePodPortForward

func (k *Client) CreatePodPortForward(ctx context.Context, namespace, podName, podPort string, channel ssh.Channel) error

CreatePodPortForward creates a port forward to a pod.

func (*Client) CreateSSHDeployment

func (k *Client) CreateSSHDeployment(ctx context.Context, namespace, deploymentName string, replicas int32) error

CreateSSHDeployment creates a SSH Server deployment.

func (*Client) CreateSecret

func (k *Client) CreateSecret(ctx context.Context, name string) error

CreateSecret creates a secret.

func (*Client) CreateServiceAccount

func (k *Client) CreateServiceAccount(ctx context.Context, namespace, serviceAccountName string) error

CreateServiceAccount creates a serviceAccount.

func (*Client) CreateServiceClusterIP

func (k *Client) CreateServiceClusterIP(ctx context.Context, namespace, serviceName string, portNum int) error

CreateServiceClusterIP creates a ClusterIP service.

func (*Client) CreateServiceLoadBalancer

func (k *Client) CreateServiceLoadBalancer(ctx context.Context, namespace, serviceName string, portNum int) error

CreateServiceLoadBalancer creates a LoadBalancer service.

func (*Client) CreateStorageClass

func (k *Client) CreateStorageClass(ctx context.Context, name string, reclaimPolicy coreAPI.PersistentVolumeReclaimPolicy) error

CreateStorageClass creates a persistent volume claim.

func (*Client) CreateUserRessources

func (k *Client) CreateUserRessources(ctx context.Context, identifier *config.KubeRessourceIdentifier) error

CreateUserRessources creates want waits for the statefulSet.

func (*Client) CreateUserStatefulSet

func (k *Client) CreateUserStatefulSet(ctx context.Context, identifier *config.KubeRessourceIdentifier) error

CreateUserStatefulSet creates a statefulset.

func (*Client) DownloadSSHServerPrivKey

func (k *Client) DownloadSSHServerPrivKey(privKey []byte) (err error)

DownloadSSHServerPrivKey downloads the ssh server private key from the store.

func (*Client) GetConfigMapData

func (k *Client) GetConfigMapData(ctx context.Context, namespace, mapName string) (map[string]string, error)

GetConfigMapData gets data from a given configmap.

func (*Client) GetPod

func (k *Client) GetPod(ctx context.Context, namespace, podName string) (*v1.Pod, error)

GetPod gets a pod.

func (*Client) GetService

func (k *Client) GetService(ctx context.Context, namespace, serviceName string) (*coreAPI.Service, error)

GetService gets a service.

func (*Client) GetStore

func (k *Client) GetStore() (store.Store, error)

func (*Client) GetStoreUserData

func (k *Client) GetStoreUserData() (data *config.UserConfiguration, err error)

GetStoreUserData saves the relevant store data to a config file.

func (*Client) ListPods

func (k *Client) ListPods(ctx context.Context, namespace string) error

ListPods list all running pods in the "kube-system" namespace.

func (*Client) NamespaceExists

func (k *Client) NamespaceExists(ctx context.Context, namespace string) (bool, error)

NamespaceExists creates a namespace.

func (*Client) UploadSSHServerPrivKey

func (k *Client) UploadSSHServerPrivKey(privKey []byte) (err error)

UploadSSHServerPrivKey uploads the ssh server private key to the store.

func (*Client) UserRessourcesExist

func (k *Client) UserRessourcesExist(ctx context.Context, namespace, statefulSetName string) (bool, error)

UserRessourcesExist checks if the statefulset exists.

func (*Client) WaitForPodRunning

func (k *Client) WaitForPodRunning(ctx context.Context, namespace, podName string, timeout time.Duration) error

WaitForPodRunning waits for a pod to be running.

func (*Client) WaitForStatefulSet

func (k *Client) WaitForStatefulSet(ctx context.Context, namespace, statefulSetName string, timeout time.Duration) error

WaitForStatefulSet waits for a statefulSet to be active.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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