Skip to content

Commit

Permalink
Merge branch 'main' into v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
khewonc committed May 17, 2022
2 parents fb19a0e + c32af59 commit 713fef0
Show file tree
Hide file tree
Showing 173 changed files with 50,090 additions and 17,084 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# and another the rest of the directory.

# All your base
* @DataDog/container-integrations
* @DataDog/container-integrations @DataDog/container-ecosystems

# Documentation
README.md @DataDog/documentation @DataDog/container-integrations
/docs/ @DataDog/documentation @DataDog/container-integrations
README.md @DataDog/documentation @DataDog/container-integrations @DataDog/container-ecosystems
/docs/ @DataDog/documentation @DataDog/container-integrations @DataDog/container-ecosystems
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: registry.ddbuild.io/images/mirror/golang:1.17
image: registry.ddbuild.io/images/mirror/golang:1.17.6-bullseye
variables:
GO111MODULE: "on"
PROJECTNAME: "datadog-operator"
Expand Down
14 changes: 13 additions & 1 deletion .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@
"wsl",
"godox",
"godot",
"nlreturn"
"nlreturn",
"varnamelen",
"tagliatelle",
"containedctx",
"contextcheck",
"nilnil",
"ireturn",
"maintidx",
"ifshort",
"gocritic",
"errchkjson",
"gofumpt",
"golint"
]

[issues]
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# Image URL to use all building/pushing image targets
IMG ?= gcr.io/datadoghq/operator:$(IMG_VERSION)

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd:preserveUnknownFields=false"
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.20

Expand Down Expand Up @@ -105,8 +104,14 @@ endef
##@ Deploy

.PHONY: manager
manager: generate lint ## Build manager binary
manager: generate lint managergobuild ## Build manager binary
go build -ldflags '${LDFLAGS}' -o bin/$(PLATFORM)/manager main.go
managergobuild: ## Builds only manager go binary
go build -ldflags '${LDFLAGS}' -o bin/$(PLATFORM)/manager main.go

##@ Deploy

manager: generate lint managergobuild ## Build manager binary

.PHONY: run
run: generate lint manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
Expand Down Expand Up @@ -134,8 +139,8 @@ manifests: generate-manifests patch-crds ## Generate manifestcd s e.g. CRD, RBAC

.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1 rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1beta1 rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases/v1beta1
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1 rbac:roleName=manager-role webhook paths="./apis/..." output:crd:artifacts:config=config/crd/bases/v1
$(CONTROLLER_GEN) $(CRD_OPTIONS),crdVersions=v1beta1 rbac:roleName=manager-role webhook paths="./apis/..." output:crd:artifacts:config=config/crd/bases/v1beta1

.PHONY: generate
generate: $(CONTROLLER_GEN) generate-openapi generate-docs ## Generate code
Expand Down Expand Up @@ -276,7 +281,7 @@ bin/$(PLATFORM)/yq: Makefile
hack/install-yq.sh 3.3.0

bin/$(PLATFORM)/golangci-lint: Makefile
hack/golangci-lint.sh -b "bin/$(PLATFORM)" v1.38.0
hack/golangci-lint.sh -b "bin/$(PLATFORM)" v1.45.2

bin/$(PLATFORM)/operator-sdk: Makefile
hack/install-operator-sdk.sh v1.13.1
Expand Down
6 changes: 5 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
domain: com
layout: go.kubebuilder.io/v3
layout:
- go.kubebuilder.io/v3
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down Expand Up @@ -39,4 +40,7 @@ resources:
kind: DatadogAgent
path: github.com/DataDog/datadog-operator/apis/datadoghq/v2alpha1
version: v2alpha1
webhooks:
conversion: true
webhookVersion: v1
version: "3"
132 changes: 132 additions & 0 deletions apis/datadoghq/common/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package common

// Datadog const value
const (
// AgentDeploymentNameLabelKey label key use to link a Resource to a DatadogAgent
AgentDeploymentNameLabelKey = "agent.datadoghq.com/name"
// AgentDeploymentComponentLabelKey label key use to know with component is it
AgentDeploymentComponentLabelKey = "agent.datadoghq.com/component"
// MD5AgentDeploymentAnnotationKey annotation key used on a Resource in order to identify which AgentDeployment have been used to generate it.
MD5AgentDeploymentAnnotationKey = "agent.datadoghq.com/agentspechash"

// DefaultAgentResourceSuffix use as suffix for agent resource naming
DefaultAgentResourceSuffix = "agent"
// DefaultClusterAgentResourceSuffix use as suffix for cluster-agent resource naming
DefaultClusterAgentResourceSuffix = "cluster-agent"
// DefaultClusterChecksRunnerResourceSuffix use as suffix for cluster-checks-runner resource naming
DefaultClusterChecksRunnerResourceSuffix = "cluster-checks-runner"
// DefaultMetricsServerResourceSuffix use as suffix for cluster-agent metrics-server resource naming
DefaultMetricsServerResourceSuffix = "cluster-agent-metrics-server"
// DefaultAPPKeyKey default app-key key (use in secret for instance).
DefaultAPPKeyKey = "app_key"
// DefaultAPIKeyKey default api-key key (use in secret for instance).
DefaultAPIKeyKey = "api_key"
// DefaultTokenKey default token key (use in secret for instance).
DefaultTokenKey = "token"
// DefaultClusterAgentServicePort default cluster-agent service port
DefaultClusterAgentServicePort = 5005
// DefaultMetricsServerServicePort default metrics-server port
DefaultMetricsServerServicePort = 443
// DefaultMetricsServerTargetPort default metrics-server pod port
DefaultMetricsServerTargetPort = int(DefaultMetricsProviderPort)
// DefaultAdmissionControllerServicePort default admission controller service port
DefaultAdmissionControllerServicePort = 443
// DefaultAdmissionControllerTargetPort default admission controller pod port
DefaultAdmissionControllerTargetPort = 8000
// DefaultDogstatsdPort default dogstatsd port
DefaultDogstatsdPort = 8125
// DefaultDogstatsdPortName default dogstatsd port name
DefaultDogstatsdPortName = "dogstatsd"
// DefaultApmPortName default apm port name
DefaultApmPortName = "apm"
// DefaultMetricsProviderPort default metrics provider port
DefaultMetricsProviderPort int32 = 8443
// DefaultKubeStateMetricsCoreConf default ksm core ConfigMap name
DefaultKubeStateMetricsCoreConf string = "kube-state-metrics-core-config"
// DefaultSystemProbeSocketPath default System Probe socket path
DefaultSystemProbeSocketPath string = "/var/run/sysprobe/sysprobe.sock"

// Liveness probe default config
DefaultLivenessProbeInitialDelaySeconds int32 = 15
DefaultLivenessProbePeriodSeconds int32 = 15
DefaultLivenessProbeTimeoutSeconds int32 = 5
DefaultLivenessProbeSuccessThreshold int32 = 1
DefaultLivenessProbeFailureThreshold int32 = 6
DefaultAgentHealthPort int32 = 5555
DefaultLivenessProbeHTTPPath = "/live"

// Readiness probe default config
DefaultReadinessProbeInitialDelaySeconds int32 = 15
DefaultReadinessProbePeriodSeconds int32 = 15
DefaultReadinessProbeTimeoutSeconds int32 = 5
DefaultReadinessProbeSuccessThreshold int32 = 1
DefaultReadinessProbeFailureThreshold int32 = 6
DefaultReadinessProbeHTTPPath = "/ready"
)

// Annotations
const (
SystemProbeAppArmorAnnotationKey = "container.apparmor.security.beta.kubernetes.io/system-probe"
SystemProbeAppArmorAnnotationValue = "unconfined"
)

// Datadog volume names and mount paths
const (
ConfdVolumeName = "confd"
ConfdVolumePath = "/conf.d"
ConfigVolumeName = "config"
ConfigVolumePath = "/etc/datadog-agent"
KubeStateMetricCoreVolumeName = "ksm-core-config"

HostRootVolumeName = "hostroot"
HostRootHostPath = "/"
HostRootMountPath = "/host/root"

ProcdirVolumeName = "procdir"
ProcdirHostPath = "/proc"
ProcdirMountPath = "/host/proc"

CgroupsVolumeName = "cgroups"
CgroupsHostPath = "/sys/fs/cgroup"
CgroupsMountPath = "/host/sys/fs/cgroup"

SystemProbeSocketVolumeName = "sysprobe-socket-dir"
SystemProbeSocketVolumePath = "/var/run/sysprobe"

DebugfsVolumeName = "debugfs"
// same path on host and container
DebugfsPath = "/sys/kernel/debug"

ModulesVolumeName = "modules"
// same path on host and container
ModulesVolumePath = "/lib/modules"
SrcVolumeName = "src"
// same path on host and container
SrcVolumePath = "/usr/src"
LogDatadogVolumeName = "logdatadog"
LogDatadogVolumePath = "/var/log/datadog"
TmpVolumeName = "tmp"
TmpVolumePath = "/tmp"
CertificatesVolumeName = "certificates"
CertificatesVolumePath = "/etc/datadog-agent/certificates"
AuthVolumeName = "datadog-agent-auth"
AuthVolumePath = "/etc/datadog-agent/auth"
InstallInfoVolumeName = "installinfo"
InstallInfoVolumeSubPath = "install_info"
InstallInfoVolumePath = "/etc/datadog-agent/install_info"
InstallInfoVolumeReadOnly = true
PointerVolumeName = "pointerdir"
PointerVolumePath = "/opt/datadog-agent/run"
LogTempStoragePath = "/var/lib/datadog-agent/logs"
PodLogVolumeName = "logpodpath"
PodLogVolumePath = "/var/log/pods"
ContainerLogVolumeName = "logcontainerpath"
ContainerLogVolumePath = "/var/lib/docker/containers"
SymlinkContainerVolumeName = "symlinkcontainerpath"
SymlinkContainerVolumePath = "/var/log/containers"
)
29 changes: 29 additions & 0 deletions apis/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package common

// Datadog env var names
const (
DDIgnoreAutoConf = "DD_IGNORE_AUTOCONF"
DDKubeStateMetricsCoreEnabled = "DD_KUBE_STATE_METRICS_CORE_ENABLED"
DDKubeStateMetricsCoreConfigMap = "DD_KUBE_STATE_METRICS_CORE_CONFIGMAP_NAME"
DDHostRootEnvVar = "HOST_ROOT"
DDSystemProbeNPMEnabledEnvVar = "DD_SYSTEM_PROBE_NETWORK_ENABLED"
DDSystemProbeEnabledEnvVar = "DD_SYSTEM_PROBE_ENABLED"
DDProcessAgentEnabledEnvVar = "DD_PROCESS_AGENT_ENABLED"
DDSystemProbeExternal = "DD_SYSTEM_PROBE_EXTERNAL"
DDSystemProbeServiceMonitoringEnabled = "DD_SYSTEM_PROBE_SERVICE_MONITORING_ENABLED"
DDSystemProbeSocket = "DD_SYSPROBE_SOCKET"
DDEnableOOMKillEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_OOM_KILL"
DDEnableTCPQueueLengthEnvVar = "DD_SYSTEM_PROBE_CONFIG_ENABLE_TCP_QUEUE_LENGTH"
DDLeaderElection = "DD_LEADER_ELECTION"
DDClusterAgentKubeServiceName = "DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME"
DDHealthPort = "DD_HEALTH_PORT"
DDLogsEnabled = "DD_LOGS_ENABLED"
DDLogsConfigContainerCollectAll = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL"
DDLogsContainerCollectUsingFiles = "DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE"
DDLogsConfigOpenFilesLimit = "DD_LOGS_CONFIG_OPEN_FILES_LIMIT"
)
38 changes: 38 additions & 0 deletions apis/datadoghq/common/v1/agent_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package common

import corev1 "k8s.io/api/core/v1"

// AgentImageConfig defines the agent container image config.
// +kubebuilder:object:generate=true
type AgentImageConfig struct {
// Define the image to use:
// Use "gcr.io/datadoghq/agent:latest" for Datadog Agent 7.
// Use "datadog/dogstatsd:latest" for standalone Datadog Agent DogStatsD 7.
// Use "gcr.io/datadoghq/cluster-agent:latest" for Datadog Cluster Agent.
// Use "agent" with the registry and tag configurations for <registry>/agent:<tag>.
// Use "cluster-agent" with the registry and tag configurations for <registry>/cluster-agent:<tag>.
Name string `json:"name,omitempty"`

// Define the image tag to use.
// To be used if the Name field does not correspond to a full image string.
// +optional
Tag string `json:"tag,omitempty"`

// Define whether the Agent image should support JMX.
// +optional
JMXEnabled bool `json:"jmxEnabled,omitempty"`

// The Kubernetes pull policy:
// Use Always, Never or IfNotPresent.
PullPolicy *corev1.PullPolicy `json:"pullPolicy,omitempty"`

// It is possible to specify Docker registry credentials.
// See https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
// +optional
PullSecrets *[]corev1.LocalObjectReference `json:"pullSecrets,omitempty"`
}
22 changes: 22 additions & 0 deletions apis/datadoghq/common/v1/customConfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package common

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// GetConfName get the name of the Configmap for a CustomConfigSpec
func GetConfName(owner metav1.Object, conf *CustomConfig, defaultName string) string {
// `configData` and `configMap` can't be set together.
// Return the default if the conf is not overridden or if it is just overridden with the ConfigData.
if conf != nil && conf.ConfigMap != nil {
return conf.ConfigMap.Name
}
return fmt.Sprintf("%s-%s", owner.GetName(), defaultName)
}
Loading

0 comments on commit 713fef0

Please sign in to comment.