resource

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateStartupProbe

func CreateStartupProbe(dogu *core.Dogu) *corev1.Probe

CreateStartupProbe returns a container start-up probe for the given dogu if it contains a state healthcheck. Otherwise, it returns nil.

func GetAppLabel

func GetAppLabel() k8sv2.CesMatchingLabels

GetAppLabel returns an app label which all CES resource may receive for general selection.

func NewCollectApplier

func NewCollectApplier(applier Applier) *collectApplier

NewCollectApplier creates a K8s resource applier that filters and collects deployment resources for a later, customized application.

func NewDoguExposedPortHandler

func NewDoguExposedPortHandler(client client.Client) *doguExposedPortHandler

NewDoguExposedPortHandler creates a new instance of doguExposedPortHandler.

func NewResourceGenerator

func NewResourceGenerator(scheme *runtime.Scheme, requirementsGenerator requirementsGenerator, hostAliasGenerator hostAliasGenerator, additionalImages map[string]string) *resourceGenerator

NewResourceGenerator creates a new generator for k8s resources

func NewUpserter

func NewUpserter(client client.Client, generator DoguResourceGenerator) *upserter

NewUpserter creates a new upserter that generates dogu resources and applies them to the cluster.

Types

type Applier

type Applier interface {
	// ApplyWithOwner provides a testable method for applying generic, unstructured K8s resources to the API
	ApplyWithOwner(doc apply.YamlDocument, namespace string, resource metav1.Object) error
}

Applier provides ways to apply unstructured Kubernetes resources against the API.

type CollectApplier

type CollectApplier interface {
	// CollectApply applies the given resources to the K8s cluster
	CollectApply(ctx context.Context, customK8sResources map[string]string, doguResource *k8sv2.Dogu) error
}

CollectApplier provides ways to collectedly apply unstructured Kubernetes resources against the API.

type DoguResourceGenerator

type DoguResourceGenerator interface {

	// CreateDoguDeployment creates a new instance of a deployment with a given dogu.json and dogu custom resource.
	CreateDoguDeployment(doguResource *k8sv2.Dogu, dogu *cesappcore.Dogu) (*apps.Deployment, error)
	// CreateDoguService creates a new instance of a service with the given dogu custom resource and container image.
	// The container image is used to extract the exposed ports. The created service is rather meant for cluster-internal
	// apps and dogus (f. e. postgresql) which do not need external access. The given container image config provides
	// the service ports to the created service.
	CreateDoguService(doguResource *k8sv2.Dogu, imageConfig *image.ConfigFile) (*v1.Service, error)
	// CreateDoguPVC creates a persistent volume claim with a 5Gi storage for the given dogu.
	CreateDoguPVC(doguResource *k8sv2.Dogu) (*v1.PersistentVolumeClaim, error)
	// contains filtered or unexported methods
}

DoguResourceGenerator is used to generate kubernetes resources for the dogu.

type ExposePortRemover

type ExposePortRemover interface {
	// RemoveExposedPorts deletes the exposure of the exposed services from the dogu.
	RemoveExposedPorts(ctx context.Context, doguResource *k8sv2.Dogu, dogu *cesappcore.Dogu) error
}

ExposePortRemover is used to delete the exposure of the exposed services from the dogu.

type RequirementsGenerator

type RequirementsGenerator struct {
	// contains filtered or unexported fields
}

func NewRequirementsGenerator

func NewRequirementsGenerator(doguConfigGetter doguConfigGetter) *RequirementsGenerator

func (RequirementsGenerator) Generate

type RequirementsUpdater

type RequirementsUpdater struct {
	// contains filtered or unexported fields
}

RequirementsUpdater is responsible to update all resource requirements for dogu deployments when a certain trigger is called.

func NewRequirementsUpdater

func NewRequirementsUpdater(client client.Client, namespace string, doguConfigGetter doguConfigGetter, doguFetcher localDoguFetcher, globalWatcher globalConfigurationWatcher) (*RequirementsUpdater, error)

NewRequirementsUpdater creates a new runnable responsible to detect changes in the container configuration of dogus.

func (*RequirementsUpdater) Start

func (hlu *RequirementsUpdater) Start(ctx context.Context) error

Start is the entry point for the updater.

type ResourceUpserter

type ResourceUpserter interface {
	// UpsertDoguDeployment generates a deployment for a given dogu and applies it to the cluster.
	// All parameters are mandatory except deploymentPatch which may be nil.
	// The deploymentPatch can be used to arbitrarily alter the deployment after resource generation.
	UpsertDoguDeployment(ctx context.Context, doguResource *k8sv2.Dogu, dogu *cesappcore.Dogu, deploymentPatch func(*apps.Deployment)) (*apps.Deployment, error)
	// UpsertDoguService generates a service for a given dogu and applies it to the cluster.
	UpsertDoguService(ctx context.Context, doguResource *k8sv2.Dogu, image *image.ConfigFile) (*v1.Service, error)
	// UpsertDoguPVCs generates a persistent volume claim for a given dogu and applies it to the cluster.
	UpsertDoguPVCs(ctx context.Context, doguResource *k8sv2.Dogu, dogu *cesappcore.Dogu) (*v1.PersistentVolumeClaim, error)
	// UpsertDoguExposedService creates oder updates the exposed service with the given dogu.
	UpsertDoguExposedService(ctx context.Context, doguResource *k8sv2.Dogu, dogu *cesappcore.Dogu) (*v1.Service, error)
}

ResourceUpserter includes functionality to generate and create all the necessary K8s resources for a given dogu.

Jump to

Keyboard shortcuts

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