deploy

package
v0.0.0-...-be4e7bc Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: EPL-2.0 Imports: 39 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CheServiceName = "che-host"
)
View Source
const Finalizer = "cluster-resources." + constants.FinalizerSuffix

Variables

View Source
var ClusterRoleBindingDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(rbac.ClusterRoleBinding{}, "TypeMeta", "ObjectMeta"),
}
View Source
var ClusterRoleDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(rbac.ClusterRole{}, "TypeMeta", "ObjectMeta"),
}
View Source
var ConfigMapDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(corev1.ConfigMap{}, "TypeMeta"),
	cmp.Comparer(func(x, y metav1.ObjectMeta) bool {
		return reflect.DeepEqual(x.Labels, y.Labels)
	}),
}
View Source
var DefaultDeploymentDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(appsv1.Deployment{}, "TypeMeta", "ObjectMeta", "Status"),
	cmpopts.IgnoreFields(appsv1.DeploymentSpec{}, "Replicas", "RevisionHistoryLimit", "ProgressDeadlineSeconds"),
	cmpopts.IgnoreFields(appsv1.DeploymentStrategy{}, "RollingUpdate"),
	cmpopts.IgnoreFields(corev1.Container{}, "ReadinessProbe", "LivenessProbe", "TerminationMessagePath", "TerminationMessagePolicy", "SecurityContext"),
	cmpopts.IgnoreFields(corev1.PodSpec{}, "DNSPolicy", "SchedulerName", "SecurityContext", "DeprecatedServiceAccount"),
	cmpopts.IgnoreFields(corev1.ConfigMapVolumeSource{}, "DefaultMode"),
	cmpopts.IgnoreFields(corev1.SecretVolumeSource{}, "DefaultMode"),
	cmpopts.IgnoreFields(corev1.VolumeSource{}, "EmptyDir"),
	cmp.Comparer(func(x, y resource.Quantity) bool {
		return x.Cmp(y) == 0
	}),
}
View Source
var (
	DefaultIngressAnnotations = map[string]string{
		"kubernetes.io/ingress.class":                       "nginx",
		"nginx.ingress.kubernetes.io/proxy-read-timeout":    "3600",
		"nginx.ingress.kubernetes.io/proxy-connect-timeout": "3600",
		"nginx.ingress.kubernetes.io/ssl-redirect":          "true",
	}
)
View Source
var RollBindingDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(rbac.RoleBinding{}, "TypeMeta", "ObjectMeta"),
}
View Source
var SecretDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(corev1.Secret{}, "TypeMeta", "ObjectMeta"),
}
View Source
var ServiceDefaultDiffOpts = cmp.Options{
	cmpopts.IgnoreFields(corev1.Service{}, "TypeMeta", "ObjectMeta"),
	cmp.Comparer(func(x, y corev1.ServiceSpec) bool {
		return cmp.Equal(x.Ports, y.Ports, cmpopts.IgnoreFields(corev1.ServicePort{}, "TargetPort", "NodePort")) &&
			reflect.DeepEqual(x.Selector, y.Selector)
	}),
}

Functions

func AppendFinalizer

func AppendFinalizer(deployContext *chetypes.DeployContext, finalizer string) error

func CleanUpAllFinalizers

func CleanUpAllFinalizers(ctx *chetypes.DeployContext) error

func ConfigureProxy

func ConfigureProxy(deployContext *chetypes.DeployContext, transport *http.Transport)

ConfigureProxy adds existing proxy configuration into provided transport object.

func CreateIgnoreIfExists

func CreateIgnoreIfExists(deployContext *chetypes.DeployContext, blueprint client.Object) (bool, error)

CreateIgnoreIfExists creates object. Return true if a new object is created or object already exists, otherwise returns false. Throws error if object cannot be created otherwise returns nil.

func Delete

func Delete(deployContext *chetypes.DeployContext, key client.ObjectKey, objectMeta client.Object) (bool, error)

Deletes object. Returns true if object deleted or not found otherwise returns false.

func DeleteByKeyWithClient

func DeleteByKeyWithClient(cli client.Client, key client.ObjectKey, objectMeta client.Object) (bool, error)

func DeleteClusterObject

func DeleteClusterObject(deployContext *chetypes.DeployContext, name string, objectMeta client.Object) (bool, error)

func DeleteFinalizer

func DeleteFinalizer(deployContext *chetypes.DeployContext, finalizer string) error

func DeleteIgnoreIfNotFound

func DeleteIgnoreIfNotFound(
	context context.Context,
	cli client.Client,
	key client.ObjectKey,
	blueprint client.Object,
) error

DeleteIgnoreIfNotFound deletes object. Returns nil if object deleted or not found otherwise returns error. Return error if object cannot be deleted otherwise returns nil.

func DeleteNamespacedObject

func DeleteNamespacedObject(deployContext *chetypes.DeployContext, name string, objectMeta client.Object) (bool, error)

func DeleteObjectWithFinalizer

func DeleteObjectWithFinalizer(deployContext *chetypes.DeployContext, key client.ObjectKey, objectMeta client.Object, finalizer string) error

func EnsurePodSecurityStandards

func EnsurePodSecurityStandards(deployment *appsv1.Deployment, userId int64, groupId int64)

EnsurePodSecurityStandards sets SecurityContext accordingly to standards https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted

func FindCheClusterCRInNamespace

func FindCheClusterCRInNamespace(cl client.Client, namespace string) (*chev2.CheCluster, error)

FindCheClusterCRInNamespace returns CheCluster custom resource from given namespace. If namespace is empty then checluster will be found in any namespace. Only one instance of CheCluster custom resource is expected.

func GenerateProxyJavaOpts

func GenerateProxyJavaOpts(proxy *chetypes.Proxy, noProxy string) (javaOpts string, err error)

GenerateProxyJavaOpts converts given proxy configuration into Java format.

func Get

func Get(deployContext *chetypes.DeployContext, key client.ObjectKey, actual client.Object) (bool, error)

Get gets object. Returns true if object exists otherwise returns false. Returns error if object cannot be retrieved otherwise returns nil.

func GetClusterObject

func GetClusterObject(deployContext *chetypes.DeployContext, name string, actual client.Object) (bool, error)

Gets cluster scope object by name Returns true if object exists otherwise returns false

func GetConfigMapSpec

func GetConfigMapSpec(
	deployContext *chetypes.DeployContext,
	name string,
	data map[string]string,
	component string) *corev1.ConfigMap

func GetForClient

func GetForClient(cli client.Client, key client.ObjectKey, actual client.Object) (bool, error)

Get gets object. Returns true if object exists otherwise returns false. Returns error if object cannot be retrieved otherwise returns nil.

func GetIngressSpec

func GetIngressSpec(
	deployContext *chetypes.DeployContext,
	name string,
	path string,
	serviceName string,
	servicePort int,
	component string) (ingressUrl string, i *networking.Ingress)

GetIngressSpec returns expected ingress config for given parameters host and path are evaluated if they are empty

func GetLabels

func GetLabels(component string) map[string]string

func GetLabelsAndSelector

func GetLabelsAndSelector(component string) (map[string]string, map[string]string)

func GetLegacyLabels

func GetLegacyLabels(component string) map[string]string

func GetManagedByLabel

func GetManagedByLabel() string

func GetNamespacedObject

func GetNamespacedObject(deployContext *chetypes.DeployContext, name string, actual client.Object) (bool, error)

Gets namespaced scope object by name Returns true if object exists otherwise returns false.

func GetObjectType

func GetObjectType(obj interface{}) string

func GetRouteSpec

func GetRouteSpec(
	deployContext *chetypes.DeployContext,
	name string,
	path string,
	serviceName string,
	servicePort int32,
	component string) (*routev1.Route, error)

GetRouteSpec returns default configuration of a route in Che namespace.

func GetSecretSpec

func GetSecretSpec(name string, namespace string, data map[string][]byte) *corev1.Secret

GetSecretSpec return default secret config for given data

func GetSecrets

func GetSecrets(deployContext *chetypes.DeployContext, labels map[string]string, annotations map[string]string) ([]corev1.Secret, error)

Get all secrets by labels and annotations

func GetServiceSpec

func GetServiceSpec(
	deployContext *chetypes.DeployContext,
	name string,
	portName []string,
	portNumber []int32,
	component string) *corev1.Service

func IsPartOfEclipseCheResourceAndManagedByOperator

func IsPartOfEclipseCheResourceAndManagedByOperator(labels map[string]string) bool

func MergeNonProxy

func MergeNonProxy(noProxy1 string, noProxy2 string) string

func MountConfigMaps

func MountConfigMaps(specDeployment *appsv1.Deployment, deployContext *chetypes.DeployContext) error

MountConfigMaps mounts configmaps into a container as a file or as environment variable. Configmaps are selected by the following labels: - app.kubernetes.io/part-of=che.eclipse.org - app.kubernetes.io/component=<DEPLOYMENT-NAME>-configmap

func MountSecrets

func MountSecrets(specDeployment *appsv1.Deployment, deployContext *chetypes.DeployContext) error

MountSecrets mounts secrets into a container as a file or as environment variable. Secrets are selected by the following labels: - app.kubernetes.io/part-of=che.eclipse.org - app.kubernetes.io/component=<DEPLOYMENT-NAME>-secret

func OverrideContainer

func OverrideContainer(
	namespace string,
	container *corev1.Container,
	overrideSettings *chev2.Container) error

func OverrideDeployment

func OverrideDeployment(
	ctx *chetypes.DeployContext,
	deployment *appsv1.Deployment,
	overrideDeploymentSettings *chev2.Deployment) error

OverrideDeployment with custom settings

func ReadCheClusterProxyConfiguration

func ReadCheClusterProxyConfiguration(ctx *chetypes.DeployContext) (*chetypes.Proxy, error)

func ReadClusterWideProxyConfiguration

func ReadClusterWideProxyConfiguration(clusterProxy *configv1.Proxy) (*chetypes.Proxy, error)

func ReloadCheClusterCR

func ReloadCheClusterCR(deployContext *chetypes.DeployContext) error

func SetStatusDetails

func SetStatusDetails(deployContext *chetypes.DeployContext, reason string, message string) (err error)

func Sync

func Sync(deployContext *chetypes.DeployContext, blueprint client.Object, diffOpts ...cmp.Option) (bool, error)

Sync syncs the blueprint to the cluster in a generic (as much as Go allows) manner. Returns true if object is up-to-date otherwise returns false

func SyncClusterRoleBindingToCluster

func SyncClusterRoleBindingToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	serviceAccountName string,
	clusterRoleName string) (bool, error)

func SyncClusterRoleToCluster

func SyncClusterRoleToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	policyRule []rbac.PolicyRule) (bool, error)

func SyncConfigMapDataToCluster

func SyncConfigMapDataToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	data map[string]string,
	component string) (bool, error)

func SyncConfigMapSpecToCluster

func SyncConfigMapSpecToCluster(
	deployContext *chetypes.DeployContext,
	configMapSpec *corev1.ConfigMap) (bool, error)

func SyncDeploymentSpecToCluster

func SyncDeploymentSpecToCluster(
	deployContext *chetypes.DeployContext,
	deploymentSpec *appsv1.Deployment,
	deploymentDiffOpts cmp.Options) (bool, error)

func SyncForClient

func SyncForClient(cli client.Client, deployContext *chetypes.DeployContext, blueprint client.Object, diffOpts ...cmp.Option) (bool, error)

func SyncIngressToCluster

func SyncIngressToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	path string,
	serviceName string,
	servicePort int,
	component string) (endpointUrl string, done bool, err error)

SyncIngressToCluster creates ingress to expose service with the set settings host and path are evaluated if they are empty

func SyncJobToCluster

func SyncJobToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	component string,
	image string,
	serviceAccountName string,
	env map[string]string) (bool, error)

func SyncRoleBindingToCluster

func SyncRoleBindingToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	serviceAccountName string,
	roleName string,
	roleKind string) (bool, error)

func SyncRoleToCluster

func SyncRoleToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	policyRule []rbac.PolicyRule) (bool, error)

func SyncRouteToCluster

func SyncRouteToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	path string,
	serviceName string,
	servicePort int32,
	component string) (bool, error)

func SyncSecretToCluster

func SyncSecretToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	namespace string,
	data map[string][]byte) (bool, error)

SyncSecret applies secret into cluster or external namespace

func SyncServiceAccountToCluster

func SyncServiceAccountToCluster(deployContext *chetypes.DeployContext, name string) (bool, error)

func SyncServiceSpecToCluster

func SyncServiceSpecToCluster(deployContext *chetypes.DeployContext, serviceSpec *corev1.Service) (bool, error)

func SyncServiceToCluster

func SyncServiceToCluster(
	deployContext *chetypes.DeployContext,
	name string,
	portName []string,
	portNumber []int32,
	component string) (bool, error)

func UpdateCheCRStatus

func UpdateCheCRStatus(deployContext *chetypes.DeployContext, field string, value string) (err error)

Types

type Reconcilable

type Reconcilable interface {
	// Reconcile object.
	Reconcile(ctx *chetypes.DeployContext) (result reconcile.Result, done bool, err error)
	// Does finalization (removes cluster scope objects, etc)
	Finalize(ctx *chetypes.DeployContext) (done bool)
}

type ReconcileManager

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

func NewReconcileManager

func NewReconcileManager() *ReconcileManager

func (*ReconcileManager) FinalizeAll

func (manager *ReconcileManager) FinalizeAll(ctx *chetypes.DeployContext) (done bool)

func (*ReconcileManager) ReconcileAll

func (manager *ReconcileManager) ReconcileAll(ctx *chetypes.DeployContext) (reconcile.Result, bool, error)

ReconcileAll reconciles all objects in an order they have been added. If reconciliation failed then CheCluster status will be updated accordingly.

func (*ReconcileManager) RegisterReconciler

func (manager *ReconcileManager) RegisterReconciler(reconciler Reconcilable)

Jump to

Keyboard shortcuts

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