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

Add flavor pod annotation #516

Merged
merged 1 commit into from
Jan 31, 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
4 changes: 4 additions & 0 deletions src/webhook/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const (
DataIngestPrefix = "data-ingest"
AnnotationDataIngestInject = DataIngestPrefix + ".dynatrace.com/inject"

// AnnotationFlavor can be set on a Pod to configure which code modules flavor to download. It's set to "default"
// if not set.
AnnotationFlavor = "oneagent.dynatrace.com/flavor"

// AnnotationTechnologies can be set on a Pod to configure which code module technologies to download. It's set to
// "all" if not set.
AnnotationTechnologies = "oneagent.dynatrace.com/technologies"
Expand Down
10 changes: 6 additions & 4 deletions src/webhook/mutation/pod_mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (m *podMutator) Handle(ctx context.Context, req admission.Request) admissio
return *workloadResponse
}

technologies, installPath, installerURL, failurePolicy, image := m.getBasicData(pod)
flavor, technologies, installPath, installerURL, failurePolicy, image := m.getBasicData(pod)

dkVol, mode := ensureDynakubeVolume(dk)

Expand All @@ -256,7 +256,7 @@ func (m *podMutator) Handle(ctx context.Context, req admission.Request) admissio

installContainer := createInstallInitContainerBase(image, pod, failurePolicy, basePodName, sc, dk)

decorateInstallContainerWithOneAgent(&installContainer, injectionInfo, technologies, installPath, installerURL, mode)
decorateInstallContainerWithOneAgent(&installContainer, injectionInfo, flavor, technologies, installPath, installerURL, mode)
decorateInstallContainerWithDataIngest(&installContainer, injectionInfo, workloadKind, workloadName)

updateContainers(pod, injectionInfo, &installContainer, dk, deploymentMetadata, dataIngestFields)
Expand Down Expand Up @@ -320,10 +320,10 @@ func decorateInstallContainerWithDataIngest(ic *corev1.Container, injectionInfo
}
}

func decorateInstallContainerWithOneAgent(ic *corev1.Container, injectionInfo *InjectionInfo, technologies string, installPath string, installerURL string, mode string) {
func decorateInstallContainerWithOneAgent(ic *corev1.Container, injectionInfo *InjectionInfo, flavor string, technologies string, installPath string, installerURL string, mode string) {
if injectionInfo.enabled(OneAgent) {
ic.Env = append(ic.Env,
corev1.EnvVar{Name: "FLAVOR", Value: dtclient.FlavorMultidistro},
corev1.EnvVar{Name: "FLAVOR", Value: flavor},
corev1.EnvVar{Name: "TECHNOLOGIES", Value: technologies},
corev1.EnvVar{Name: "INSTALLPATH", Value: installPath},
corev1.EnvVar{Name: "INSTALLER_URL", Value: installerURL},
Expand Down Expand Up @@ -451,12 +451,14 @@ func setupInjectionConfigVolume(pod *corev1.Pod) {
}

func (m *podMutator) getBasicData(pod *corev1.Pod) (
flavor string,
technologies string,
installPath string,
installerURL string,
failurePolicy string,
image string,
) {
flavor = kubeobjects.GetField(pod.Annotations, dtwebhook.AnnotationFlavor, dtclient.FlavorMultidistro)
technologies = url.QueryEscape(kubeobjects.GetField(pod.Annotations, dtwebhook.AnnotationTechnologies, "all"))
installPath = kubeobjects.GetField(pod.Annotations, dtwebhook.AnnotationInstallPath, dtwebhook.DefaultInstallPath)
installerURL = kubeobjects.GetField(pod.Annotations, dtwebhook.AnnotationInstallerUrl, "")
Expand Down