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

update metrics forwarder to support v2 #601

Merged
merged 9 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
67 changes: 66 additions & 1 deletion apis/datadoghq/common/v1/agent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

package common

import corev1 "k8s.io/api/core/v1"
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AgentImageConfig defines the agent container image config.
// +kubebuilder:object:generate=true
Expand Down Expand Up @@ -36,3 +39,65 @@ type AgentImageConfig struct {
// +optional
PullSecrets *[]corev1.LocalObjectReference `json:"pullSecrets,omitempty"`
}

// DaemonSetStatus defines the observed state of Agent running as DaemonSet.
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type DaemonSetStatus struct {
Desired int32 `json:"desired"`
Current int32 `json:"current"`
Ready int32 `json:"ready"`
Available int32 `json:"available"`
UpToDate int32 `json:"upToDate"`

Status string `json:"status,omitempty"`
State string `json:"state,omitempty"`
LastUpdate *metav1.Time `json:"lastUpdate,omitempty"`
CurrentHash string `json:"currentHash,omitempty"`

// DaemonsetName corresponds to the name of the created DaemonSet.
DaemonsetName string `json:"daemonsetName,omitempty"`
}

// DeploymentStatus type representing a Deployment status.
// +k8s:openapi-gen=true
// +kubebuilder:object:generate=true
type DeploymentStatus struct {
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
// +optional
Replicas int32 `json:"replicas,omitempty"`

// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
// +optional
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`

// Total number of ready pods targeted by this deployment.
// +optional
ReadyReplicas int32 `json:"readyReplicas,omitempty"`

// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty"`

// Total number of unavailable pods targeted by this deployment. This is the total number of
// pods that are still required for the deployment to have 100% available capacity. They may
// either be pods that are running but not yet available or pods that still have not been created.
// +optional
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`

LastUpdate *metav1.Time `json:"lastUpdate,omitempty"`
CurrentHash string `json:"currentHash,omitempty"`

// GeneratedToken corresponds to the generated token if any token was provided in the Credential configuration when ClusterAgent is
// enabled.
// +optional
GeneratedToken string `json:"generatedToken,omitempty"`

// Status corresponds to the ClusterAgent deployment computed status.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeploymentStatus can be use also for the clustercheckrunner so it can be good to remove the notion of ClusterAgent in the description

Status string `json:"status,omitempty"`
// State corresponds to the ClusterAgent deployment state.
State string `json:"state,omitempty"`

// DeploymentName corresponds to the name of the Cluster Agent Deployment.
DeploymentName string `json:"deploymentName,omitempty"`
}
38 changes: 38 additions & 0 deletions apis/datadoghq/common/v1/zz_generated.deepcopy.go

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

66 changes: 3 additions & 63 deletions apis/datadoghq/v1alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,82 +1292,22 @@ type DatadogAgentStatus struct {

// The actual state of the Agent as an extended daemonset.
// +optional
Agent *DaemonSetStatus `json:"agent,omitempty"`
Agent *commonv1.DaemonSetStatus `json:"agent,omitempty"`

// The actual state of the Cluster Agent as a deployment.
// +optional
ClusterAgent *DeploymentStatus `json:"clusterAgent,omitempty"`
ClusterAgent *commonv1.DeploymentStatus `json:"clusterAgent,omitempty"`

// The actual state of the Cluster Checks Runner as a deployment.
// +optional
ClusterChecksRunner *DeploymentStatus `json:"clusterChecksRunner,omitempty"`
ClusterChecksRunner *commonv1.DeploymentStatus `json:"clusterChecksRunner,omitempty"`

// Conditions Represents the latest available observations of a DatadogAgent's current state.
// +listType=map
// +listMapKey=type
Conditions []DatadogAgentCondition `json:"conditions,omitempty"`
}

// DaemonSetStatus defines the observed state of Agent running as DaemonSet.
// +k8s:openapi-gen=true
type DaemonSetStatus struct {
Desired int32 `json:"desired"`
Current int32 `json:"current"`
Ready int32 `json:"ready"`
Available int32 `json:"available"`
UpToDate int32 `json:"upToDate"`

Status string `json:"status,omitempty"`
State string `json:"state,omitempty"`
LastUpdate *metav1.Time `json:"lastUpdate,omitempty"`
CurrentHash string `json:"currentHash,omitempty"`

// DaemonsetName corresponds to the name of the created DaemonSet.
DaemonsetName string `json:"daemonsetName,omitempty"`
}

// DeploymentStatus type representing the Cluster Agent Deployment status.
// +k8s:openapi-gen=true
type DeploymentStatus struct {
// Total number of non-terminated pods targeted by this deployment (their labels match the selector).
// +optional
Replicas int32 `json:"replicas,omitempty"`

// Total number of non-terminated pods targeted by this deployment that have the desired template spec.
// +optional
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`

// Total number of ready pods targeted by this deployment.
// +optional
ReadyReplicas int32 `json:"readyReplicas,omitempty"`

// Total number of available pods (ready for at least minReadySeconds) targeted by this deployment.
// +optional
AvailableReplicas int32 `json:"availableReplicas,omitempty"`

// Total number of unavailable pods targeted by this deployment. This is the total number of
// pods that are still required for the deployment to have 100% available capacity. They may
// either be pods that are running but not yet available or pods that still have not been created.
// +optional
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`

LastUpdate *metav1.Time `json:"lastUpdate,omitempty"`
CurrentHash string `json:"currentHash,omitempty"`

// GeneratedToken corresponds to the generated token if any token was provided in the Credential configuration when ClusterAgent is
// enabled.
// +optional
GeneratedToken string `json:"generatedToken,omitempty"`

// Status corresponds to the ClusterAgent deployment computed status.
Status string `json:"status,omitempty"`
// State corresponds to the ClusterAgent deployment state.
State string `json:"state,omitempty"`

// DeploymentName corresponds to the name of the Cluster Agent Deployment.
DeploymentName string `json:"deploymentName,omitempty"`
}

// DatadogAgentCondition describes the state of a DatadogAgent at a certain point.
// +k8s:openapi-gen=true
type DatadogAgentCondition struct {
Expand Down
56 changes: 30 additions & 26 deletions apis/datadoghq/v1alpha1/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,51 @@ func GetDefaultCredentialsSecretName(dda *DatadogAgent) string {
}

// GetAPIKeySecret returns the API key secret name and the key inside the secret
// returns <is_set>, secretName, secretKey
// returns <isSet>, secretName, secretKey
// Note that the default name can differ depending on where this is called
func GetAPIKeySecret(credentials *DatadogCredentials, defaultName string) (bool, string, string) {
isSet := false
secretName := defaultName
secretKey := apicommon.DefaultAPIKeyKey

if credentials.APISecret != nil {
isSet = true
secretName = credentials.APISecret.SecretName
if credentials.APISecret.KeyName != "" {
return true, credentials.APISecret.SecretName, credentials.APISecret.KeyName
secretKey = credentials.APISecret.KeyName
}

return true, credentials.APISecret.SecretName, apicommon.DefaultAPIKeyKey
}

if credentials.APIKeyExistingSecret != "" {
return true, credentials.APIKeyExistingSecret, apicommon.DefaultAPIKeyKey
}

if credentials.APIKey != "" {
return true, defaultName, apicommon.DefaultAPIKeyKey
} else if credentials.APIKeyExistingSecret != "" {
isSet = true
secretName = credentials.APIKeyExistingSecret
} else if credentials.APIKey != "" {
isSet = true
}

return false, defaultName, apicommon.DefaultAPIKeyKey
return isSet, secretName, secretKey
}

// GetAppKeySecret returns the APP key secret name and the key inside the secret
// returns <is_set>, secretName, secretKey
// returns <isSet>, secretName, secretKey
// Note that the default name can differ depending on where this is called
func GetAppKeySecret(credentials *DatadogCredentials, defaultName string) (bool, string, string) {
isSet := false
secretName := defaultName
secretKey := apicommon.DefaultAPPKeyKey

if credentials.APPSecret != nil {
isSet = true
secretName = credentials.APPSecret.SecretName
if credentials.APPSecret.KeyName != "" {
return true, credentials.APPSecret.SecretName, credentials.APPSecret.KeyName
secretKey = credentials.APPSecret.KeyName
}

return true, credentials.APPSecret.SecretName, apicommon.DefaultAPPKeyKey
}

if credentials.AppKeyExistingSecret != "" {
return true, credentials.AppKeyExistingSecret, apicommon.DefaultAPPKeyKey
}

if credentials.AppKey != "" {
return true, defaultName, apicommon.DefaultAPPKeyKey
} else if credentials.AppKeyExistingSecret != "" {
isSet = true
secretName = credentials.AppKeyExistingSecret
} else if credentials.AppKey != "" {
isSet = true
}

return false, defaultName, apicommon.DefaultAPPKeyKey
return isSet, secretName, secretKey
}

// GetKeysFromCredentials returns any key data that need to be stored in a new secret
Expand Down
44 changes: 3 additions & 41 deletions apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

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

Loading