kubeobjects

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPodNamespace = "POD_NAMESPACE"
	EnvPodName      = "POD_NAME"
)
View Source
const (
	AppNameLabel      = "app.kubernetes.io/name"
	AppCreatedByLabel = "app.kubernetes.io/created-by"
	AppManagedByLabel = "app.kubernetes.io/managed-by"
	AppComponentLabel = "app.kubernetes.io/component"
	AppVersionLabel   = "app.kubernetes.io/version"

	OneAgentComponentLabel    = "oneagent"
	ActiveGateComponentLabel  = "activegate"
	WebhookComponentLabel     = "webhook"
	SyntheticComponentLabel   = "synthetic"
	EdgeConnectComponentLabel = "edgeconnect"
)
View Source
const (
	ReadOnlyMountPath  = true
	ReadWriteMountPath = false
)
View Source
const AnnotationHash = dynatracev1beta1.InternalFlagPrefix + "template-hash"
View Source
const UnprivilegedGroup = int64(1000)
View Source
const UnprivilegedUser = int64(1000)

Variables

This section is empty.

Functions

func AddHashAnnotation added in v0.14.0

func AddHashAnnotation(object metav1.Object) error

func AddOrUpdate added in v0.11.0

func AddOrUpdate(envVars []corev1.EnvVar, desiredEnvVar corev1.EnvVar) []corev1.EnvVar

func AffinityNodeRequirementForSupportedArches added in v0.14.0

func AffinityNodeRequirementForSupportedArches() []corev1.NodeSelectorRequirement

func AreConfigMapsEqual added in v0.10.1

func AreConfigMapsEqual(configMap corev1.ConfigMap, other corev1.ConfigMap) bool

func AreSecretsEqual added in v0.7.0

func AreSecretsEqual(secret corev1.Secret, other corev1.Secret) bool

func CheckIfOneAgentAPMExists

func CheckIfOneAgentAPMExists(cfg *rest.Config) (bool, error)

CheckIfOneAgentAPMExists checks if a OneAgentAPM object exists

func ConfigMapDataEqual added in v0.6.0

func ConfigMapDataEqual(map1, map2 *corev1.ConfigMap) bool

func CreateConfigMap added in v0.11.0

func CreateConfigMap(scheme *runtime.Scheme, owner metav1.Object, mods ...configMapModifier) (*corev1.ConfigMap, error)

func CreateOrUpdateDaemonSet

func CreateOrUpdateDaemonSet(kubernetesClient client.Client, logger logr.Logger, desiredDaemonSet *appsv1.DaemonSet) (bool, error)

func CreateOrUpdateDeployment added in v0.14.0

func CreateOrUpdateDeployment(c client.Client, logger logr.Logger, desiredDeployment *appsv1.Deployment) (bool, error)

func CreateSecret added in v0.11.0

func CreateSecret(scheme *runtime.Scheme, owner metav1.Object, mods ...secretBuilderModifier) (*corev1.Secret, error)

func DefaultNamespace added in v0.11.0

func DefaultNamespace() string

func Delete added in v0.9.0

func Delete(ctx context.Context, client client.Client, obj client.Object) error

func EnvVarIsIn added in v0.5.0

func EnvVarIsIn(envVars []corev1.EnvVar, envVarToCheck string) bool

func ExtractField added in v0.11.0

func ExtractField(configMap *corev1.ConfigMap, key string) (string, error)

func ExtractToken

func ExtractToken(secret *corev1.Secret, key string) (string, error)

func FindContainerInPod added in v0.8.0

func FindContainerInPod(pod corev1.Pod, name string) (*corev1.Container, error)

func FindContainerInPodSpec added in v0.10.0

func FindContainerInPodSpec(podSpec *corev1.PodSpec, containerName string) *corev1.Container

func FindEnvVar added in v0.7.0

func FindEnvVar(envVars []corev1.EnvVar, name string) *corev1.EnvVar

func GenerateHash

func GenerateHash(ds any) (string, error)

func GetDataFromSecretName added in v0.7.0

func GetDataFromSecretName(apiReader client.Reader, namespacedName types.NamespacedName, dataKey string, log logr.Logger) (string, error)

func GetDeployment

func GetDeployment(c client.Client, podName, namespace string) (*appsv1.Deployment, error)

GetDeployment returns the Deployment object who is the owner of this pod.

func GetField

func GetField(values map[string]string, key string, defaultValue string) string

func GetFieldBool

func GetFieldBool(values map[string]string, key string, defaultValue bool) bool

func GetPod added in v0.9.0

func GetPod(ctx context.Context, clt client.Reader, name, namespace string) (*corev1.Pod, error)

func GetPodName added in v0.11.0

func GetPodName(pod corev1.Pod) string

GetPodName returns the name of the pod. During the webhook injection the pod.Name is not always set yet, in which case it returns the pod.GeneraName

func GetVolumeByName added in v0.6.0

func GetVolumeByName(volumes []corev1.Volume, volumeName string) (*corev1.Volume, error)

func GetVolumeMountByName added in v0.12.0

func GetVolumeMountByName(mounts []corev1.VolumeMount, volumeName string) (*corev1.VolumeMount, error)

func IsDifferent added in v0.10.0

func IsDifferent(a, b any) (bool, error)

func IsHashAnnotationDifferent added in v0.10.0

func IsHashAnnotationDifferent(a, b metav1.Object) bool

func IsVolumeMountPresent added in v0.10.0

func IsVolumeMountPresent(volumeMounts []corev1.VolumeMount, neededMount corev1.VolumeMount) bool

func Key added in v0.6.0

func Key(object client.Object) client.ObjectKey

func LabelsNotEqual added in v0.6.0

func LabelsNotEqual(currentLabels, desiredLabels map[string]string) bool

func MergeMap added in v0.9.0

func MergeMap(maps ...map[string]string) map[string]string

func MountPathIsIn added in v0.5.0

func MountPathIsIn(volumeMounts []corev1.VolumeMount, mountPathToCheck string) bool

func MountPathIsReadOnlyOrReadWrite added in v0.6.0

func MountPathIsReadOnlyOrReadWrite(volumeMounts []corev1.VolumeMount, mountPathToCheck string, mode bool) bool

func NewEnvVarSourceForField added in v0.8.0

func NewEnvVarSourceForField(fieldPath string) *corev1.EnvVarSource

func NewQuantity added in v0.11.0

func NewQuantity(serialized string) *resource.Quantity

func NewResources added in v0.11.0

func NewResources(cpu, memory string) corev1.ResourceList

func PortIsIn added in v0.5.0

func PortIsIn(ports []corev1.ContainerPort, portToCheck int32) bool

func SwitchCapability added in v0.9.0

func SwitchCapability(instance *dynatracev1beta1.DynaKube, capability dynatracev1beta1.ActiveGateCapability, wantEnabled bool)

func ValidateCertificateExpiration added in v0.5.0

func ValidateCertificateExpiration(certData []byte, renewalThreshold time.Duration, now time.Time, log logr.Logger) (bool, error)

func VolumeClaimIsDefined added in v0.11.0

func VolumeClaimIsDefined(claims []corev1.PersistentVolumeClaim, claimNameToCheck string) bool

func VolumeIsDefined added in v0.5.0

func VolumeIsDefined(volumes []corev1.Volume, volumeNameToCheck string) bool

Types

type AppLabels added in v0.6.0

type AppLabels struct {
	Component string
	Version   string
	// contains filtered or unexported fields
}

func NewAnnotations added in v0.14.0

func NewAnnotations(appName, name, component, ver string) *AppLabels

func NewAppLabels added in v0.6.0

func NewAppLabels(appName, name, component, ver string) *AppLabels

NewAppLabels abstracts labels that are specific to an application managed by the operator which have their own version separate from the operator version. Follows the recommended label pattern: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels

func (*AppLabels) BuildLabels added in v0.6.0

func (labels *AppLabels) BuildLabels() map[string]string

BuildLabels creates labels that include oneagent or activegate mode and version

func (*AppLabels) BuildMatchLabels added in v0.6.0

func (labels *AppLabels) BuildMatchLabels() map[string]string

BuildMatchLabels creates labels that don't change when switching oneagent or activegate mode

type ConfigMapDataModifier added in v0.11.0

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

func NewConfigMapDataModifier added in v0.11.0

func NewConfigMapDataModifier(data map[string]string) ConfigMapDataModifier

func (ConfigMapDataModifier) Enabled added in v0.11.0

func (mod ConfigMapDataModifier) Enabled() bool

func (ConfigMapDataModifier) Modify added in v0.11.0

func (mod ConfigMapDataModifier) Modify(configMap *corev1.ConfigMap) error

type ConfigMapNameModifier added in v0.11.0

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

func NewConfigMapNameModifier added in v0.11.0

func NewConfigMapNameModifier(name string) ConfigMapNameModifier

func (ConfigMapNameModifier) Enabled added in v0.11.0

func (mod ConfigMapNameModifier) Enabled() bool

func (ConfigMapNameModifier) Modify added in v0.11.0

func (mod ConfigMapNameModifier) Modify(configMap *corev1.ConfigMap) error

type ConfigMapNamespaceModifier added in v0.11.0

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

func NewConfigMapNamespaceModifier added in v0.11.0

func NewConfigMapNamespaceModifier(namespaceName string) ConfigMapNamespaceModifier

func (ConfigMapNamespaceModifier) Enabled added in v0.11.0

func (mod ConfigMapNamespaceModifier) Enabled() bool

func (ConfigMapNamespaceModifier) Modify added in v0.11.0

func (mod ConfigMapNamespaceModifier) Modify(configMap *corev1.ConfigMap) error

type ConfigMapQuery added in v0.10.1

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

func NewConfigMapQuery added in v0.10.1

func NewConfigMapQuery(ctx context.Context, kubeClient client.Client, kubeReader client.Reader, log logr.Logger) ConfigMapQuery

func (ConfigMapQuery) Create added in v0.10.1

func (query ConfigMapQuery) Create(configMap corev1.ConfigMap) error

func (ConfigMapQuery) CreateOrUpdate added in v0.10.1

func (query ConfigMapQuery) CreateOrUpdate(configMap corev1.ConfigMap) error

func (ConfigMapQuery) Delete added in v0.11.0

func (query ConfigMapQuery) Delete(configMap corev1.ConfigMap) error

func (ConfigMapQuery) Get added in v0.10.1

func (query ConfigMapQuery) Get(objectKey client.ObjectKey) (corev1.ConfigMap, error)

func (ConfigMapQuery) Update added in v0.10.1

func (query ConfigMapQuery) Update(configMap corev1.ConfigMap) error

type CoreLabels added in v0.6.0

type CoreLabels struct {
	Version string
	// contains filtered or unexported fields
}

func NewCoreLabels added in v0.6.0

func NewCoreLabels(dynakubeName, component string) *CoreLabels

NewCoreLabels abstracts labels that are used for statefulsetreconciler functionality in the operator which are not specific to an application's version Follows the recommended label pattern: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels

func (*CoreLabels) BuildLabels added in v0.6.0

func (labels *CoreLabels) BuildLabels() map[string]string

BuildLabels creates labels that include operator version

func (*CoreLabels) BuildMatchLabels added in v0.6.0

func (labels *CoreLabels) BuildMatchLabels() map[string]string

BuildMatchLabels creates labels that don't change when switching operator versions

type SecretDataModifier added in v0.11.0

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

func NewSecretDataModifier added in v0.11.0

func NewSecretDataModifier(data map[string][]byte) SecretDataModifier

func (SecretDataModifier) Enabled added in v0.11.0

func (mod SecretDataModifier) Enabled() bool

func (SecretDataModifier) Modify added in v0.11.0

func (mod SecretDataModifier) Modify(secret *corev1.Secret) error

type SecretLabelsModifier added in v0.11.0

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

func NewSecretLabelsModifier added in v0.11.0

func NewSecretLabelsModifier(labels map[string]string) SecretLabelsModifier

func (SecretLabelsModifier) Enabled added in v0.11.0

func (mod SecretLabelsModifier) Enabled() bool

func (SecretLabelsModifier) Modify added in v0.11.0

func (mod SecretLabelsModifier) Modify(secret *corev1.Secret) error

type SecretNameModifier added in v0.11.0

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

func NewSecretNameModifier added in v0.11.0

func NewSecretNameModifier(name string) SecretNameModifier

func (SecretNameModifier) Enabled added in v0.11.0

func (mod SecretNameModifier) Enabled() bool

func (SecretNameModifier) Modify added in v0.11.0

func (mod SecretNameModifier) Modify(secret *corev1.Secret) error

type SecretNamespaceModifier added in v0.11.0

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

func NewSecretNamespaceModifier added in v0.11.0

func NewSecretNamespaceModifier(namespaceName string) SecretNamespaceModifier

func (SecretNamespaceModifier) Enabled added in v0.11.0

func (mod SecretNamespaceModifier) Enabled() bool

func (SecretNamespaceModifier) Modify added in v0.11.0

func (mod SecretNamespaceModifier) Modify(secret *corev1.Secret) error

type SecretQuery added in v0.7.0

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

func NewSecretQuery added in v0.7.0

func NewSecretQuery(ctx context.Context, kubeClient client.Client, kubeReader client.Reader, log logr.Logger) SecretQuery

func (SecretQuery) Create added in v0.7.0

func (query SecretQuery) Create(secret corev1.Secret) error

func (SecretQuery) CreateOrUpdate added in v0.7.0

func (query SecretQuery) CreateOrUpdate(secret corev1.Secret) error

func (SecretQuery) CreateOrUpdateForNamespacesList added in v0.11.0

func (query SecretQuery) CreateOrUpdateForNamespacesList(newSecret corev1.Secret, namespaces []corev1.Namespace) error

func (SecretQuery) Get added in v0.7.0

func (query SecretQuery) Get(objectKey client.ObjectKey) (corev1.Secret, error)

func (SecretQuery) GetAllFromNamespaces added in v0.11.0

func (query SecretQuery) GetAllFromNamespaces(secretName string) ([]corev1.Secret, error)

func (SecretQuery) Update added in v0.7.0

func (query SecretQuery) Update(secret corev1.Secret) error

type SecretTypeModifier added in v0.11.0

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

func NewSecretTypeModifier added in v0.11.0

func NewSecretTypeModifier(secretType corev1.SecretType) SecretTypeModifier

func (SecretTypeModifier) Enabled added in v0.11.0

func (mod SecretTypeModifier) Enabled() bool

func (SecretTypeModifier) Modify added in v0.11.0

func (mod SecretTypeModifier) Modify(secret *corev1.Secret) error

type Tokens

type Tokens struct {
	ApiToken  string
	PaasToken string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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