k8s

package module
v0.0.0-...-55b7168 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelVersion   = "app.kubernetes.io/version"
	LabelPartOf    = "app.kubernetes.io/part-of"
	LabelManagedBy = "app.kubernetes.io/managed-by"
	LabelCreatedBy = "app.kubernetes.io/created-by"
	LabelComponent = "app.kubernetes.io/component"
	LabelInstance  = "app.kubernetes.io/instance"
)

https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

View Source
const (
	LabelProjectID      = "calyptia_project_id"
	LabelAggregatorID   = "calyptia_aggregator_id"
	LabelAggregatorName = "calyptia_aggregator_name"
	LabelPipelineID     = "calyptia_pipeline_id"
	LabelPipelineName   = "calyptia_pipeline_name"
)

Variables

View Source
var (
	ErrNoContext            = fmt.Errorf("no context is currently set")
	ErrCoreOperatorNotFound = fmt.Errorf("could not find core operator across all namespaces")
)
View Source
var GetOperatorManifest = func(version string) ([]byte, error) {
	url, err := getOperatorDownloadURL(version)
	if err != nil {
		return nil, err
	}
	response, err := http.Get(url)
	if err != nil {
		return nil, fmt.Errorf("error downloading operator manifest: %w", err)
	}
	defer func(Body io.ReadCloser) {
		err := Body.Close()
		if err != nil {
			fmt.Println("Error closing response body:", err)
		}
	}(response.Body)

	manifestBytes, err := io.ReadAll(response.Body)
	if err != nil {
		return nil, err
	}

	return manifestBytes, nil
}

Functions

func FormatResourceName

func FormatResourceName(parts ...string) string

FormatResourceName returns the resource name with a prepended calyptia prefix.

func GetCurrentContextNamespace

func GetCurrentContextNamespace() (string, error)

Types

type Client

type Client struct {
	kubernetes.Interface
	Namespace    string
	ProjectToken string
	CloudBaseURL string
	LabelsFunc   func() map[string]string
	Config       *restclient.Config
}

func (*Client) CheckOperatorInstalled

func (client *Client) CheckOperatorInstalled(ctx context.Context, namespace string) (bool, error)

func (*Client) CheckOperatorVersion

func (client *Client) CheckOperatorVersion(ctx context.Context) (string, error)

func (*Client) CreateClusterRole

func (client *Client) CreateClusterRole(ctx context.Context, agg cloud.CreatedCoreInstance, dryRun bool, opts ...ClusterRoleOpt) (*rbacv1.ClusterRole, error)

func (*Client) CreateClusterRoleBinding

func (client *Client) CreateClusterRoleBinding(
	ctx context.Context,
	agg cloud.CreatedCoreInstance,
	clusterRole *rbacv1.ClusterRole,
	serviceAccount *corev1.ServiceAccount,
	dryRun bool,
) (*rbacv1.ClusterRoleBinding, error)

func (*Client) CreateDeployment

func (client *Client) CreateDeployment(
	ctx context.Context,
	image string,
	agg cloud.CreatedCoreInstance,
	coreCloudURL string,
	serviceAccount *corev1.ServiceAccount,
	tlsVerify bool,
	skipServiceCreation bool,
	dryRun bool,
) (*appsv1.Deployment, error)

func (*Client) CreateSecret

func (client *Client) CreateSecret(ctx context.Context, agg cloud.CreatedCoreInstance, dryRun bool) (*corev1.Secret, error)

CreateSecret TODO: DELETE AFTER OPERATOR LAUNCHES and create by k8s become deprecated

func (*Client) CreateSecretOperatorRSAKey

func (client *Client) CreateSecretOperatorRSAKey(ctx context.Context, agg cloud.CreatedCoreInstance, dryRun bool) (*corev1.Secret, error)

func (*Client) CreateServiceAccount

func (client *Client) CreateServiceAccount(ctx context.Context, agg cloud.CreatedCoreInstance, dryRun bool) (*corev1.ServiceAccount, error)

func (*Client) DeleteClusterRoleByLabel

func (client *Client) DeleteClusterRoleByLabel(ctx context.Context, label string) error

func (*Client) DeleteConfigMapsByLabel

func (client *Client) DeleteConfigMapsByLabel(ctx context.Context, label, ns string) error

func (*Client) DeleteCoreInstance

func (client *Client) DeleteCoreInstance(ctx context.Context, name, environment string, shouldWait bool) error

func (*Client) DeleteDaemonSetByLabel

func (client *Client) DeleteDaemonSetByLabel(ctx context.Context, label, ns string) error

func (*Client) DeleteDeploymentByLabel

func (client *Client) DeleteDeploymentByLabel(ctx context.Context, label, ns string) error

func (*Client) DeleteResources

func (client *Client) DeleteResources(ctx context.Context, resources []ResourceRollBack) ([]ResourceRollBack, error)

func (*Client) DeleteRoleBindingByLabel

func (client *Client) DeleteRoleBindingByLabel(ctx context.Context, label string) error

func (*Client) DeleteSecretByLabel

func (client *Client) DeleteSecretByLabel(ctx context.Context, label, ns string) error

func (*Client) DeleteServiceAccountByLabel

func (client *Client) DeleteServiceAccountByLabel(ctx context.Context, label, ns string) error

func (*Client) DeleteServiceByName

func (client *Client) DeleteServiceByName(ctx context.Context, name, ns string) error

func (*Client) DeployCoreOperatorSync

func (client *Client) DeployCoreOperatorSync(ctx context.Context, params DeployCoreOperatorSync) (*appsv1.Deployment, error)

func (*Client) EnsureOwnNamespace

func (client *Client) EnsureOwnNamespace(ctx context.Context) error

func (*Client) FindDeploymentByLabel

func (client *Client) FindDeploymentByLabel(ctx context.Context, label string) (*appsv1.DeploymentList, error)

func (*Client) FindDeploymentByName

func (client *Client) FindDeploymentByName(ctx context.Context, name string) (*appsv1.Deployment, error)

func (*Client) FindServicesByLabel

func (client *Client) FindServicesByLabel(ctx context.Context, label, ns string) (*corev1.ServiceList, error)

func (*Client) GetClusterInfo

func (client *Client) GetClusterInfo() (ClusterInfo, error)

func (*Client) GetNamespace

func (client *Client) GetNamespace(ctx context.Context, name string) (*corev1.Namespace, error)

GetNamespace returns the namespace if it exists.

func (*Client) IsOperatorInstalled

func (client *Client) IsOperatorInstalled(ctx context.Context) (bool, error)

func (*Client) PurgeLeftoverRBAC

func (client *Client) PurgeLeftoverRBAC(ctx context.Context) error

func (*Client) SearchManagerAcrossAllNamespaces

func (client *Client) SearchManagerAcrossAllNamespaces(ctx context.Context) (*appsv1.Deployment, error)

func (*Client) UpdateDeploymentByLabel

func (client *Client) UpdateDeploymentByLabel(ctx context.Context, label, newImage, tlsVerify string) error

func (*Client) UpdateOperatorDeploymentByLabel

func (client *Client) UpdateOperatorDeploymentByLabel(ctx context.Context, label string, newImage string, verbose bool, waitTimeout time.Duration) error

func (*Client) UpdateSyncDeploymentByLabel

func (client *Client) UpdateSyncDeploymentByLabel(ctx context.Context, label string, params UpdateCoreOperatorSync, verbose bool, waitTimeout time.Duration) error

func (*Client) WaitReady

func (client *Client) WaitReady(ctx context.Context, namespace, name string, verbose bool, waitTimeout time.Duration) error

type ClusterInfo

type ClusterInfo struct {
	Namespace, Platform, Version string
}

ClusterInfo information that is retrieved from the running cluster.

type ClusterRoleOpt

type ClusterRoleOpt struct {
	EnableOpenShift bool
}

type DeployCoreOperatorSync

type DeployCoreOperatorSync struct {
	CoreCloudURL        string
	FromCloudImage      string
	ToCloudImage        string
	Metrics             bool
	MetricsPort         string
	MemoryLimit         string
	Annotations         string
	Tolerations         string
	SkipServiceCreation bool
	NoTLSVerify         bool
	CloudProxy          string
	HttpProxy           string
	HttpsProxy          string
	NoProxy             string
	CoreInstance        cloud.CreatedCoreInstance
	ServiceAccount      string
}

type OperatorIncompleteError

type OperatorIncompleteError struct {
	Errors []error
}

func (*OperatorIncompleteError) Error

func (o *OperatorIncompleteError) Error() string

type ResourceRollBack

type ResourceRollBack struct {
	Name      string
	Namespace string
	GVR       schema.GroupVersionResource
}

type UpdateCoreOperatorSync

type UpdateCoreOperatorSync struct {
	Metrics             bool
	MetricsPort         string
	MemoryLimit         string
	Annotations         string
	Tolerations         string
	SkipServiceCreation bool
	NoTLSVerify         bool
	CloudProxy          string
	HttpProxy           string
	HttpsProxy          string
	NoProxy             string
	CoreInstance        cloud.CreatedCoreInstance
	ServiceAccount      string
	Image               string
}

Jump to

Keyboard shortcuts

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