Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposes custom StatsD and EEC images in DynaKube ActiveGate spec #546

Merged
merged 5 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions config/crd/bases/dynatrace.com_dynakubes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,20 @@ spec:
tenantUUID:
type: string
type: object
eec:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
kubeSystemUUID:
description: KubeSystemUUID contains the UUID of the current Kubernetes
cluster
Expand Down Expand Up @@ -2710,6 +2724,20 @@ spec:
description: Defines the current state (Running, Updating, Error,
...)
type: string
statsd:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
tokens:
description: Credentials used to connect back to Dynatrace.
type: string
Expand Down
28 changes: 28 additions & 0 deletions config/deploy/kubernetes/kubernetes-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2653,6 +2653,20 @@ spec:
tenantUUID:
type: string
type: object
eec:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
kubeSystemUUID:
description: KubeSystemUUID contains the UUID of the current Kubernetes
cluster
Expand Down Expand Up @@ -2719,6 +2733,20 @@ spec:
description: Defines the current state (Running, Updating, Error,
...)
type: string
statsd:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
tokens:
description: Credentials used to connect back to Dynatrace.
type: string
Expand Down
28 changes: 28 additions & 0 deletions config/deploy/openshift/openshift-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2653,6 +2653,20 @@ spec:
tenantUUID:
type: string
type: object
eec:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
kubeSystemUUID:
description: KubeSystemUUID contains the UUID of the current Kubernetes
cluster
Expand Down Expand Up @@ -2719,6 +2733,20 @@ spec:
description: Defines the current state (Running, Updating, Error,
...)
type: string
statsd:
properties:
imageHash:
description: ImageHash contains the last image hash seen.
type: string
lastUpdateProbeTimestamp:
description: LastUpdateProbeTimestamp defines the last timestamp
when the querying for updates have been done
format: date-time
type: string
version:
description: Version contains the version to be deployed.
type: string
type: object
tokens:
description: Credentials used to connect back to Dynatrace.
type: string
Expand Down
2 changes: 1 addition & 1 deletion src/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 45 additions & 1 deletion src/api/v1beta1/dynakube_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ type DynaKubeStatus struct {
// Conditions includes status about the current state of the instance
Conditions []metav1.Condition `json:"conditions,omitempty"`

ActiveGate ActiveGateStatus `json:"activeGate,omitempty"`
ActiveGate ActiveGateStatus `json:"activeGate,omitempty"`
ExtensionController EecStatus `json:"eec,omitempty"`
Statsd StatsdStatus `json:"statsd,omitempty"`

OneAgent OneAgentStatus `json:"oneAgent,omitempty"`
}
Expand All @@ -68,6 +70,12 @@ type CommunicationHostStatus struct {
Port uint32 `json:"port,omitempty"`
}

// +kubebuilder:object:generate=false
type VersionStatusNamer interface {
Status() VersionStatus
Name() string
}

type VersionStatus struct {
// ImageHash contains the last image hash seen.
ImageHash string `json:"imageHash,omitempty"`
Expand All @@ -79,10 +87,42 @@ type VersionStatus struct {
LastUpdateProbeTimestamp *metav1.Time `json:"lastUpdateProbeTimestamp,omitempty"`
}

func (verStatus *VersionStatus) Status() VersionStatus {
return *verStatus.DeepCopy()
}

var _ VersionStatusNamer = (*ActiveGateStatus)(nil)

type ActiveGateStatus struct {
VersionStatus `json:",inline"`
}

func (agStatus *ActiveGateStatus) Name() string {
return "ActiveGate"
}

var _ VersionStatusNamer = (*EecStatus)(nil)

type EecStatus struct {
VersionStatus `json:",inline"`
}

func (eecStatus *EecStatus) Name() string {
return "Extension Controller"
}

var _ VersionStatusNamer = (*StatsdStatus)(nil)

type StatsdStatus struct {
VersionStatus `json:",inline"`
}

func (statsdStatus *StatsdStatus) Name() string {
return "StatsD data source"
}

var _ VersionStatusNamer = (*OneAgentStatus)(nil)

type OneAgentStatus struct {
VersionStatus `json:",inline"`

Expand All @@ -92,6 +132,10 @@ type OneAgentStatus struct {
LastHostsRequestTimestamp *metav1.Time `json:"lastHostsRequestTimestamp,omitempty"`
}

func (oneAgentStatus *OneAgentStatus) Name() string {
return "OneAgent"
}

type OneAgentInstance struct {
PodName string `json:"podName,omitempty"`
IPAddress string `json:"ipAddress,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions src/api/v1beta1/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
annotationFeatureAutomaticKubernetesApiMonitoring = annotationFeaturePrefix + "automatic-kubernetes-api-monitoring"
annotationFeatureDisableMetadataEnrichment = annotationFeaturePrefix + "disable-metadata-enrichment"
annotationFeatureUseActiveGateImageForStatsd = annotationFeaturePrefix + "use-activegate-image-for-statsd"
annotationFeatureCustomEecImage = annotationFeaturePrefix + "custom-eec-image"
annotationFeatureCustomStatsdImage = annotationFeaturePrefix + "custom-statsd-image"
AnnotationFeatureReadOnlyOneAgent = annotationFeaturePrefix + "oneagent-readonly-host-fs"
)

Expand Down Expand Up @@ -126,6 +128,16 @@ func (dk *DynaKube) FeatureUseActiveGateImageForStatsd() bool {
return dk.Annotations[annotationFeatureUseActiveGateImageForStatsd] == "true"
}

// FeatureCustomEecImage is a feature flag to specify custom Extension Controller Docker image path
func (dk *DynaKube) FeatureCustomEecImage() string {
return dk.Annotations[annotationFeatureCustomEecImage]
}

// FeatureCustomStatsdImage is a feature flag to specify custom StatsD Docker image path
func (dk *DynaKube) FeatureCustomStatsdImage() string {
return dk.Annotations[annotationFeatureCustomStatsdImage]
}

// FeatureReadOnlyOneAgent is a feature flag that makes the operator deploy the oneagents in a readonly mode, where the csi-driver provides the volume for logs and such,
func (dk *DynaKube) FeatureReadOnlyOneAgent() bool {
return dk.Annotations[AnnotationFeatureReadOnlyOneAgent] == "true"
Expand Down
128 changes: 128 additions & 0 deletions src/api/v1beta1/image_paths.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package v1beta1

import (
"fmt"
"strings"
)

type imagePathResolver interface {
CustomImagePath() string
DefaultImagePath() string

apiUrl() string
}

type genericImagePath struct {
dynaKube *DynaKube
}

func newGenericImagePath(dynaKube *DynaKube) *genericImagePath {
return &genericImagePath{
dynaKube: dynaKube,
}
}

func (imagePath *genericImagePath) apiUrl() string {
return imagePath.dynaKube.Spec.APIURL
}

var _ imagePathResolver = (*activeGateImagePath)(nil)

type activeGateImagePath genericImagePath

func newActiveGateImagePath(dynaKube *DynaKube) *activeGateImagePath {
return (*activeGateImagePath)(newGenericImagePath(dynaKube))
}

func (imagePath *activeGateImagePath) apiUrl() string {
return (*genericImagePath)(imagePath).apiUrl()
}

func (imagePath *activeGateImagePath) CustomImagePath() string {
dk := imagePath.dynaKube
if dk.DeprecatedActiveGateMode() {
if dk.Spec.KubernetesMonitoring.Image != "" {
return dk.Spec.KubernetesMonitoring.Image
} else if dk.Spec.Routing.Image != "" {
return dk.Spec.Routing.Image
}
} else if dk.ActiveGateMode() {
if dk.Spec.ActiveGate.Image != "" {
return dk.Spec.ActiveGate.Image
}
}

return ""
}

func (imagePath *activeGateImagePath) DefaultImagePath() string {
return "linux/activegate:latest"
}

var _ imagePathResolver = (*statsdImagePath)(nil)

type statsdImagePath genericImagePath

func newStatsdImagePath(dynaKube *DynaKube) *statsdImagePath {
return (*statsdImagePath)(newGenericImagePath(dynaKube))
}

func (imagePath *statsdImagePath) apiUrl() string {
return (*genericImagePath)(imagePath).apiUrl()
}

func (imagePath *statsdImagePath) CustomImagePath() string {
if imagePath.dynaKube.NeedsStatsd() {
return imagePath.dynaKube.FeatureCustomStatsdImage()
}
return ""
}

func (imagePath *statsdImagePath) DefaultImagePath() string {
return "linux/dynatrace-datasource-statsd:latest"
}

var _ imagePathResolver = (*eecImagePath)(nil)

type eecImagePath genericImagePath

func newEecImagePath(dynaKube *DynaKube) *eecImagePath {
return (*eecImagePath)(newGenericImagePath(dynaKube))
}

func (imagePath *eecImagePath) apiUrl() string {
return (*genericImagePath)(imagePath).apiUrl()
}

func (imagePath *eecImagePath) CustomImagePath() string {
if imagePath.dynaKube.NeedsStatsd() {
return imagePath.dynaKube.FeatureCustomEecImage()
}
return ""
}

func (imagePath *eecImagePath) DefaultImagePath() string {
return "linux/dynatrace-eec:latest"
}

func resolveImagePath(resolver imagePathResolver) string {
customImage := resolver.CustomImagePath()
if len(customImage) > 0 {
return customImage
}

apiUrl := resolver.apiUrl()
if apiUrl == "" {
return ""
}

registry := buildImageRegistry(apiUrl)
return fmt.Sprintf("%s/%s", registry, resolver.DefaultImagePath())
}

func buildImageRegistry(apiURL string) string {
registry := strings.TrimPrefix(apiURL, "https://")
registry = strings.TrimPrefix(registry, "http://")
registry = strings.TrimSuffix(registry, "/api")
return registry
}
Loading