From 08257fadd1442df228dee3e5298cc675f99ec33f Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 10:53:19 +0200 Subject: [PATCH 1/7] api: add markers for metrics to api types --- api/v1beta1/cluster_types.go | 13 ++++++++++- api/v1beta1/clusterclass_types.go | 12 +++++++++- api/v1beta1/machine_types.go | 17 +++++++++++++- api/v1beta1/machinedeployment_types.go | 23 ++++++++++++++++++- api/v1beta1/machinehealthcheck_types.go | 16 ++++++++++++- api/v1beta1/machineset_types.go | 18 ++++++++++++++- .../api/v1beta1/kubeadmconfig_types.go | 13 ++++++++++- .../v1beta1/kubeadm_control_plane_types.go | 19 ++++++++++++++- exp/api/v1beta1/machinepool_types.go | 19 ++++++++++++++- 9 files changed, 141 insertions(+), 9 deletions(-) diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index ccefcd69468b..dd030a303a59 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -46,6 +46,7 @@ const ( type ClusterSpec struct { // Paused can be used to prevent controllers from processing the Cluster and all its associated objects. // +optional + // +Metrics:gauge:name="spec_paused",help="Whether the cluster is paused and any of its resources will not be processed by the controllers.",nilIsZero=true Paused bool `json:"paused,omitempty"` // Cluster network configuration. @@ -430,6 +431,7 @@ type ClusterStatus struct { // Phase represents the current phase of cluster actuation. // E.g. Pending, Running, Terminating, Failed etc. // +optional + // +Metrics:stateset:name="status_phase",help="The clusters current phase.",labelName="phase",list={"Pending","Provisioning","Provisioned","Deleting","Failed","Unknown"} Phase string `json:"phase,omitempty"` // InfrastructureReady is the state of the infrastructure provider. @@ -446,6 +448,8 @@ type ClusterStatus struct { // Conditions defines current service state of the cluster. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a cluster.",labelName="status",JSONPath=.status,list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a cluster.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` // ObservedGeneration is the latest generation observed by the controller. @@ -514,8 +518,15 @@ func (v APIEndpoint) String() string { // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.topology.version",description="Kubernetes version associated with this Cluster" // Cluster is the Schema for the clusters API. +// +Metrics:gvk:namePrefix="capi_cluster" +// +Metrics:labelFromPath:name="name",JSONPath=.metadata.name +// +Metrics:labelFromPath:name="namespace",JSONPath=.metadata.namespace +// +Metrics:labelFromPath:name="uid",JSONPath=.metadata.uid +// +Metrics:info:name="info",help="Information about a cluster.",labelsFromPath={topology_version:".spec.topology.version",topology_class:".spec.topology.class",control_plane_endpoint_host:".spec.controlPlaneEndpoint.host",control_plane_endpoint_port:".spec.controlPlaneEndpoint.port",control_plane_reference_kind:".spec.controlPlaneRef.kind",control_plane_reference_name:".spec.controlPlaneRef.name",infrastructure_reference_kind:".spec.infrastructureRef.kind",infrastructure_reference_name:".spec.infrastructureRef.name"} type Cluster struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the cluster is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} metav1.ObjectMeta `json:"metadata,omitempty"` Spec ClusterSpec `json:"spec,omitempty"` diff --git a/api/v1beta1/clusterclass_types.go b/api/v1beta1/clusterclass_types.go index 38c2530cbdd6..f7ad086103e6 100644 --- a/api/v1beta1/clusterclass_types.go +++ b/api/v1beta1/clusterclass_types.go @@ -35,8 +35,16 @@ const ClusterClassKind = "ClusterClass" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterClass" // ClusterClass is a template which can be used to create managed topologies. +// +Metrics:gvk:namePrefix="capi_clusterclass" +// +Metrics:labelFromPath:name="name",JSONPath=.metadata.name +// +Metrics:labelFromPath:name="namespace",JSONPath=.metadata.namespace +// +Metrics:labelFromPath:name="uid",JSONPath=.metadata.uid +// +Metrics:info:name="info",help="Information about a clusterclass.",labelsFromPath={name:.metadata.name} type ClusterClass struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the clusterclass is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec ClusterClassSpec `json:"spec,omitempty"` @@ -890,6 +898,8 @@ type ClusterClassStatus struct { // Conditions defines current observed state of the ClusterClass. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a clusterclass.",labelName="status",JSONPath=.status,list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a clusterclass.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` // ObservedGeneration is the latest generation observed by the controller. diff --git a/api/v1beta1/machine_types.go b/api/v1beta1/machine_types.go index e6e0fa8fe0cf..2f196926ced0 100644 --- a/api/v1beta1/machine_types.go +++ b/api/v1beta1/machine_types.go @@ -142,6 +142,7 @@ type MachineSpec struct { type MachineStatus struct { // NodeRef will point to the corresponding Node if it exists. // +optional + // +Metrics:info:name="status_noderef",help="Information about the node reference of a machine.",labelsFromPath={node_name:".name",node_uid:".uid"} NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"` // NodeInfo is a set of ids/uuids to uniquely identify the node. @@ -194,16 +195,19 @@ type MachineStatus struct { // Addresses is a list of addresses assigned to the machine. // This field is copied from the infrastructure provider reference. // +optional + // +Metrics:info:name="addresses",help="Address information about a machine.",labelsFromPath={address:".address",type:".type"} Addresses MachineAddresses `json:"addresses,omitempty"` // Phase represents the current phase of machine actuation. // E.g. Pending, Running, Terminating, Failed etc. // +optional + // +Metrics:stateset:name="status_phase",help="The machines current phase.",labelName="phase",list={"Pending","Provisioning","Provisioned","Running","Deleting","Deleted","Failed","Unknown"} Phase string `json:"phase,omitempty"` // CertificatesExpiryDate is the expiry date of the machine certificates. // This value is only set for control plane machines. // +optional + // +Metrics:gauge:name="status_certificatesexpirydate",help="Information about certificate expiration date of a control plane node.",nilIsZero=true CertificatesExpiryDate *metav1.Time `json:"certificatesExpiryDate,omitempty"` // BootstrapReady is the state of the bootstrap provider. @@ -220,6 +224,8 @@ type MachineStatus struct { // Conditions defines current service state of the Machine. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a machine.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a machine.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` } @@ -279,8 +285,17 @@ type Bootstrap struct { // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version",description="Kubernetes version associated with this Machine" // Machine is the Schema for the machines API. +// +Metrics:gvk:namePrefix="capi_machine" +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=".spec.clusterName" +// +Metrics:info:name="info",help="Information about a machine.",labelsFromPath={bootstrap_reference_kind:.spec.bootstrap.configRef.kind,bootstrap_reference_name:.spec.bootstrap.configRef.name,container_runtime_version:.status.nodeInfo.containerRuntimeVersion,control_plane_name:.metadata.labels.cluster\.x-k8s\.io/control-plane-name,failure_domain:.spec.failureDomain,infrastructure_reference_kind:.spec.infrastructureRef.kind,infrastructure_reference_name:.spec.infrastructureRef.name,kernel_version:.status.nodeInfo.kernelVersion,kube_proxy_version:.status.nodeInfo.kubeProxyVersion,kubelet_version:.status.nodeInfo.kubeletVersion,os_image:.status.nodeInfo.osImage,provider_id:.spec.providerID,version:.spec.version} type Machine struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the machine is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec MachineSpec `json:"spec,omitempty"` diff --git a/api/v1beta1/machinedeployment_types.go b/api/v1beta1/machinedeployment_types.go index 1e4b1c6b0ded..a1e0326fdc21 100644 --- a/api/v1beta1/machinedeployment_types.go +++ b/api/v1beta1/machinedeployment_types.go @@ -99,6 +99,7 @@ type MachineDeploymentSpec struct { // * An existing MachineDeployment which initially wasn't controlled by the autoscaler // should be later controlled by the autoscaler // +optional + // +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a machinedeployment." Replicas *int32 `json:"replicas,omitempty"` // RolloutAfter is a field to indicate a rollout should be performed @@ -139,6 +140,7 @@ type MachineDeploymentSpec struct { // Indicates that the deployment is paused. // +optional + // +Metrics:gauge:name="spec_paused",help="Whether the machinedeployment is paused and any of its resources will not be processed by the controllers.",nilIsZero=true Paused bool `json:"paused,omitempty"` // The maximum time in seconds for a deployment to make progress before it @@ -193,6 +195,7 @@ type MachineRollingUpdateDeployment struct { // that the total number of machines available at all times // during the update is at least 70% of desired machines. // +optional + // +Metrics:gauge:name="spec_strategy_rollingupdate_max_unavailable",help="Maximum number of unavailable replicas during a rolling update of a machinedeployment." MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"` // The maximum number of machines that can be scheduled above the @@ -209,6 +212,7 @@ type MachineRollingUpdateDeployment struct { // be scaled up further, ensuring that total number of machines running // at any time during the update is at most 130% of desired machines. // +optional + // +Metrics:gauge:name="spec_strategy_rollingupdate_max_surge",help="Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a machinedeployment." MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"` // DeletePolicy defines the policy used by the MachineDeployment to identify nodes to delete when downscaling. @@ -263,20 +267,24 @@ type MachineDeploymentStatus struct { // Total number of non-terminated machines targeted by this deployment // (their labels match the selector). // +optional + // +Metrics:gauge:name="status_replicas",help="The number of replicas per machinedeployment.",nilIsZero=true Replicas int32 `json:"replicas"` // Total number of non-terminated machines targeted by this deployment // that have the desired template spec. // +optional + // +Metrics:gauge:name="status_replicas_updated",help="The number of updated replicas per machinedeployment.",nilIsZero=true UpdatedReplicas int32 `json:"updatedReplicas"` // Total number of ready machines targeted by this deployment. // +optional + // +Metrics:gauge:name="status_replicas_ready",help="The number of ready replicas per machinedeployment.",nilIsZero=true ReadyReplicas int32 `json:"readyReplicas"` // Total number of available machines (ready for at least minReadySeconds) // targeted by this deployment. // +optional + // +Metrics:gauge:name="status_replicas_available",help="The number of available replicas per machinedeployment.",nilIsZero=true AvailableReplicas int32 `json:"availableReplicas"` // Total number of unavailable machines targeted by this deployment. @@ -285,14 +293,18 @@ type MachineDeploymentStatus struct { // be machines that are running but not yet available or machines // that still have not been created. // +optional + // +Metrics:gauge:name="status_replicas_unavailable",help="The number of unavailable replicas per machinedeployment.",nilIsZero=true UnavailableReplicas int32 `json:"unavailableReplicas"` // Phase represents the current phase of a MachineDeployment (ScalingUp, ScalingDown, Running, Failed, or Unknown). // +optional + // +Metrics:stateset:name="status_phase",help="The machinedeployments current phase.",labelName="phase",list={"ScalingUp","ScalingDown","Running","Failed","Unknown"} Phase string `json:"phase,omitempty"` // Conditions defines current service state of the MachineDeployment. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a machinedeployment.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a machinedeployment.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` } @@ -354,8 +366,17 @@ func (md *MachineDeploymentStatus) GetTypedPhase() MachineDeploymentPhase { // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineDeployment" // MachineDeployment is the Schema for the machinedeployments API. +// +Metrics:gvk:namePrefix="capi_machinedeployment" +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=".spec.clusterName" +// +Metrics:info:name="info",help="Information about a machinedeployment.",labelsFromPath={bootstrap_reference_kind:.spec.template.spec.bootstrap.configRef.kind,bootstrap_reference_name:.spec.template.spec.bootstrap.configRef.name,infrastructure_reference_kind:.spec.template.spec.infrastructureRef.kind,infrastructure_reference_name:.spec.template.spec.infrastructureRef.name,version:.spec.template.spec.version} type MachineDeployment struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the machinedeployment is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec MachineDeploymentSpec `json:"spec,omitempty"` diff --git a/api/v1beta1/machinehealthcheck_types.go b/api/v1beta1/machinehealthcheck_types.go index 578a955238dd..20af07bcc601 100644 --- a/api/v1beta1/machinehealthcheck_types.go +++ b/api/v1beta1/machinehealthcheck_types.go @@ -123,17 +123,20 @@ type MachineHealthCheckStatus struct { // total number of machines counted by this machine health check // +kubebuilder:validation:Minimum=0 // +optional + // +Metrics:gauge:name="status_expected_machines",help="Total number of machines counted by this machinehealthcheck.",nilIsZero=true ExpectedMachines int32 `json:"expectedMachines"` // total number of healthy machines counted by this machine health check // +kubebuilder:validation:Minimum=0 // +optional + // +Metrics:gauge:name="status_current_healthy",help="Current number of healthy machines.",nilIsZero=true CurrentHealthy int32 `json:"currentHealthy"` // RemediationsAllowed is the number of further remediations allowed by this machine health check before // maxUnhealthy short circuiting will be applied // +kubebuilder:validation:Minimum=0 // +optional + // +Metrics:gauge:name="status_remediations_allowed",help="Number of machine remediations that are currently allowed.",nilIsZero=true RemediationsAllowed int32 `json:"remediationsAllowed"` // ObservedGeneration is the latest generation observed by the controller. @@ -146,6 +149,8 @@ type MachineHealthCheckStatus struct { // Conditions defines current service state of the MachineHealthCheck. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a machinehealthcheck.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a machinehealthcheck.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` } @@ -162,8 +167,17 @@ type MachineHealthCheckStatus struct { // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of MachineHealthCheck" // MachineHealthCheck is the Schema for the machinehealthchecks API. +// +Metrics:gvk:namePrefix="capi_machinehealthcheck" +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=".spec.clusterName" +// +Metrics:info:name="info",help="Information about a machinehealthcheck.",labelsFromPath={maxUnhealthy:.spec.maxUnhealthy} type MachineHealthCheck struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the machinehealthcheck is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` // Specification of machine health check policy diff --git a/api/v1beta1/machineset_types.go b/api/v1beta1/machineset_types.go index f10e44f4f28d..d2a6570ffb5b 100644 --- a/api/v1beta1/machineset_types.go +++ b/api/v1beta1/machineset_types.go @@ -57,6 +57,7 @@ type MachineSetSpec struct { // * An existing MachineSet which initially wasn't controlled by the autoscaler // should be later controlled by the autoscaler // +optional + // +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a machineset.",nilIsZero=true Replicas *int32 `json:"replicas,omitempty"` // MinReadySeconds is the minimum number of seconds for which a Node for a newly created machine should be ready before considering the replica available. @@ -141,18 +142,22 @@ type MachineSetStatus struct { // Replicas is the most recently observed number of replicas. // +optional + // +Metrics:gauge:name="status_replicas",help="The number of replicas per machineset.",nilIsZero=true Replicas int32 `json:"replicas"` // The number of replicas that have labels matching the labels of the machine template of the MachineSet. // +optional + // +Metrics:gauge:name="status_replicas_fully_labeled",help="The number of fully labeled replicas per machineset.",nilIsZero=true FullyLabeledReplicas int32 `json:"fullyLabeledReplicas"` // The number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready". // +optional + // +Metrics:gauge:name="status_replicas_ready",help="The number of ready replicas per machineset.",nilIsZero=true ReadyReplicas int32 `json:"readyReplicas"` // The number of available replicas (ready for at least minReadySeconds) for this MachineSet. // +optional + // +Metrics:gauge:name="status_replicas_available",help="The number of available replicas per machineset.",nilIsZero=true AvailableReplicas int32 `json:"availableReplicas"` // ObservedGeneration reflects the generation of the most recently observed MachineSet. @@ -183,6 +188,8 @@ type MachineSetStatus struct { FailureMessage *string `json:"failureMessage,omitempty"` // Conditions defines current service state of the MachineSet. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a machineset.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a machineset.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions Conditions `json:"conditions,omitempty"` } @@ -225,8 +232,17 @@ func (m *MachineSet) Validate() field.ErrorList { // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineSet" // MachineSet is the Schema for the machinesets API. +// +Metrics:gvk:namePrefix="capi_machineset" +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=".spec.clusterName" +// +Metrics:info:name="info",help="Information about a machineset.",labelsFromPath={bootstrap_reference_kind:.spec.template.spec.bootstrap.configRef.kind,bootstrap_reference_name:.spec.template.spec.bootstrap.configRef.name,infrastructure_reference_kind:.spec.template.spec.infrastructureRef.kind,infrastructure_reference_name:.spec.template.spec.infrastructureRef.name,version:.spec.template.spec.version} type MachineSet struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the machineset is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec MachineSetSpec `json:"spec,omitempty"` diff --git a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go index 90689364dae0..bf829d920f90 100644 --- a/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go +++ b/bootstrap/kubeadm/api/v1beta1/kubeadmconfig_types.go @@ -440,6 +440,8 @@ type KubeadmConfigStatus struct { // Conditions defines current service state of the KubeadmConfig. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a kubeadmconfig.",labelName="status",JSONPath=.status,list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a kubeadmconfig.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions clusterv1.Conditions `json:"conditions,omitempty"` } @@ -451,8 +453,17 @@ type KubeadmConfigStatus struct { // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KubeadmConfig" // KubeadmConfig is the Schema for the kubeadmconfigs API. +// +Metrics:gvk:namePrefix="capi_kubeadmconfig" +// +Metrics:labelFromPath:name="name",JSONPath=.metadata.name +// +Metrics:labelFromPath:name="namespace",JSONPath=.metadata.namespace +// +Metrics:labelFromPath:name="uid",JSONPath=.metadata.uid +// +Metrics:labelFromPath:name="cluster_name",JSONPath=.metadata.labels.cluster\.x-k8s\.io/cluster-name +// +Metrics:info:name="info",help="Information about a kubeadmconfig.",labelsFromPath={name:.metadata.name} type KubeadmConfig struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the kubeadmconfig is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec KubeadmConfigSpec `json:"spec,omitempty"` diff --git a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go index 1a9ccf073831..5266bc01bb2d 100644 --- a/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go +++ b/controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go @@ -76,6 +76,7 @@ type KubeadmControlPlaneSpec struct { // odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members). // This is a pointer to distinguish between explicit zero and not specified. // +optional + // +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a kubeadmcontrolplane." Replicas *int32 `json:"replicas,omitempty"` // Version defines the desired Kubernetes version. @@ -181,6 +182,7 @@ type RollingUpdate struct { // Example: when this is set to 1, the control plane can be scaled // up immediately when the rolling update starts. // +optional + // +Metrics:gauge:name="spec_strategy_rollingupdate_max_surge",help="Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a kubeadmcontrolplane." MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"` } @@ -241,6 +243,7 @@ type KubeadmControlPlaneStatus struct { // Total number of non-terminated machines targeted by this control plane // (their labels match the selector). // +optional + // +Metrics:gauge:name="status_replicas",help="The number of replicas per kubeadmcontrolplane.",nilIsZero=true Replicas int32 `json:"replicas"` // Version represents the minimum Kubernetes version for the control plane machines @@ -251,10 +254,12 @@ type KubeadmControlPlaneStatus struct { // Total number of non-terminated machines targeted by this control plane // that have the desired template spec. // +optional + // +Metrics:gauge:name="status_replicas_updated",help="The number of updated replicas per kubeadmcontrolplane.",nilIsZero=true UpdatedReplicas int32 `json:"updatedReplicas"` // Total number of fully running and ready control plane machines. // +optional + // +Metrics:gauge:name="status_replicas_ready",help="The number of ready replicas per kubeadmcontrolplane.",nilIsZero=true ReadyReplicas int32 `json:"readyReplicas"` // Total number of unavailable machines targeted by this control plane. @@ -263,6 +268,7 @@ type KubeadmControlPlaneStatus struct { // be machines that are running but not yet ready or machines // that still have not been created. // +optional + // +Metrics:gauge:name="status_replicas_unavailable",help="The number of unavailable replicas per kubeadmcontrolplane.",nilIsZero=true UnavailableReplicas int32 `json:"unavailableReplicas"` // Initialized denotes whether or not the control plane has the @@ -295,6 +301,8 @@ type KubeadmControlPlaneStatus struct { // Conditions defines current service state of the KubeadmControlPlane. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a kubeadmcontrolplane.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a kubeadmcontrolplane.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions clusterv1.Conditions `json:"conditions,omitempty"` // LastRemediation stores info about last remediation performed. @@ -334,8 +342,17 @@ type LastRemediationStatus struct { // +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="Kubernetes version associated with this control plane" // KubeadmControlPlane is the Schema for the KubeadmControlPlane API. +// +Metrics:gvk:namePrefix="capi_kubeadmcontrolplane" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=.metadata.ownerReferences.\[kind=Cluster\].name +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:info:name="info",help="Information about a kubeadmcontrolplane.",labelsFromPath={version:".spec.version"} type KubeadmControlPlane struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the kubeadmcontrolplane is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec KubeadmControlPlaneSpec `json:"spec,omitempty"` diff --git a/exp/api/v1beta1/machinepool_types.go b/exp/api/v1beta1/machinepool_types.go index 0c7839998afa..8fccdbe3450f 100644 --- a/exp/api/v1beta1/machinepool_types.go +++ b/exp/api/v1beta1/machinepool_types.go @@ -40,6 +40,7 @@ type MachinePoolSpec struct { // Number of desired machines. Defaults to 1. // This is a pointer to distinguish between explicit zero and not specified. // +optional + // +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a machinepool." Replicas *int32 `json:"replicas,omitempty"` // Template describes the machines that will be created. @@ -74,14 +75,17 @@ type MachinePoolStatus struct { // Replicas is the most recently observed number of replicas. // +optional + // +Metrics:gauge:name="status_replicas",help="The number of replicas per machinepool.",nilIsZero=true Replicas int32 `json:"replicas"` // The number of ready replicas for this MachinePool. A machine is considered ready when the node has been created and is "Ready". // +optional + // +Metrics:gauge:name="status_replicas_ready",help="The number of ready replicas per machinepool.",nilIsZero=true ReadyReplicas int32 `json:"readyReplicas,omitempty"` // The number of available replicas (ready for at least minReadySeconds) for this MachinePool. // +optional + // +Metrics:gauge:name="status_replicas_available",help="The number of available replicas per machinepool.",nilIsZero=true AvailableReplicas int32 `json:"availableReplicas,omitempty"` // Total number of unavailable machine instances targeted by this machine pool. @@ -90,6 +94,7 @@ type MachinePoolStatus struct { // be machine instances that are running but not yet available or machine instances // that still have not been created. // +optional + // +Metrics:gauge:name="status_replicas_unavailable",help="The number of unavailable replicas per machinepool.",nilIsZero=true UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"` // FailureReason indicates that there is a problem reconciling the state, and @@ -105,6 +110,7 @@ type MachinePoolStatus struct { // Phase represents the current phase of cluster actuation. // E.g. Pending, Running, Terminating, Failed etc. // +optional + // +Metrics:stateset:name="status_phase",help="The machinepools current phase.",labelName="phase",list={"ScalingUp","ScalingDown","Running","Failed","Unknown"} Phase string `json:"phase,omitempty"` // BootstrapReady is the state of the bootstrap provider. @@ -121,6 +127,8 @@ type MachinePoolStatus struct { // Conditions define the current service state of the MachinePool. // +optional + // +Metrics:stateset:name="status_condition",help="The condition of a machinepool.",labelName="status",JSONPath=".status",list={"True","False","Unknown"},labelsFromPath={"type":".type"} + // +Metrics:gauge:name="status_condition_last_transition_time",help="The condition last transition time of a machinepool.",valueFrom=.lastTransitionTime,labelsFromPath={"type":".type","status":".status"} Conditions clusterv1.Conditions `json:"conditions,omitempty"` } @@ -220,8 +228,17 @@ func (m *MachinePoolStatus) GetTypedPhase() MachinePoolPhase { // +k8s:conversion-gen=false // MachinePool is the Schema for the machinepools API. +// +Metrics:gvk:namePrefix="capi_machinepool" +// +Metrics:labelFromPath:name="name",JSONPath=".metadata.name" +// +Metrics:labelFromPath:name="namespace",JSONPath=".metadata.namespace" +// +Metrics:labelFromPath:name="uid",JSONPath=".metadata.uid" +// +Metrics:labelFromPath:name="cluster_name",JSONPath=".spec.clusterName" +// +Metrics:info:name="info",help="Information about a machinepool.",labelsFromPath={bootstrap_configuration_reference_kind:.spec.template.spec.bootstrap.configRef.kind,bootstrap_configuration_reference_name:.spec.template.spec.bootstrap.configRef.name,failure_domain:.spec.template.spec.failureDomain,infrastructure_reference_kind:.spec.template.spec.infrastructureRef.kind,infrastructure_reference_name:.spec.template.spec.infrastructureRef.name,version:.spec.template.spec.version} type MachinePool struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + // +Metrics:gauge:name="created",JSONPath=".creationTimestamp",help="Unix creation timestamp." + // +Metrics:info:name="annotation_paused",JSONPath=.annotations['cluster\.x-k8s\.io/paused'],help="Whether the machinepool is paused and any of its resources will not be processed by the controllers.",labelsFromPath={paused_value:"."} + // +Metrics:info:name="owner",JSONPath=".ownerReferences",help="Owner references.",labelsFromPath={owner_is_controller:".controller",owner_kind:".kind",owner_name:".name",owner_uid:".uid"} metav1.ObjectMeta `json:"metadata,omitempty"` Spec MachinePoolSpec `json:"spec,omitempty"` From fb8f4aa78a67543e087ba90cb7a3b52783a5c04f Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 10:56:20 +0200 Subject: [PATCH 2/7] metrics: drop templates for metrics generation and rename yaml files --- config/metrics/kustomization.yaml | 7 +- .../{crd-metrics-config.yaml => metrics.yaml} | 0 .../{crd-clusterrole.yaml => rbac.yaml} | 0 config/metrics/templates/README.md | 7 - config/metrics/templates/cluster.yaml | 79 --------- config/metrics/templates/clusterclass.yaml | 26 --- config/metrics/templates/common_metrics.yaml | 52 ------ config/metrics/templates/header.yaml | 3 - config/metrics/templates/kubeadmconfig.yaml | 30 ---- .../templates/kubeadmcontrolplane.yaml | 84 ---------- config/metrics/templates/machine.yaml | 130 --------------- .../metrics/templates/machinedeployment.yaml | 153 ------------------ .../metrics/templates/machinehealthcheck.yaml | 53 ------ config/metrics/templates/machinepool.yaml | 119 -------------- config/metrics/templates/machineset.yaml | 100 ------------ config/metrics/templates/owner_metric.yaml | 17 -- 16 files changed, 4 insertions(+), 856 deletions(-) rename config/metrics/{crd-metrics-config.yaml => metrics.yaml} (100%) rename config/metrics/{crd-clusterrole.yaml => rbac.yaml} (100%) delete mode 100644 config/metrics/templates/README.md delete mode 100644 config/metrics/templates/cluster.yaml delete mode 100644 config/metrics/templates/clusterclass.yaml delete mode 100644 config/metrics/templates/common_metrics.yaml delete mode 100644 config/metrics/templates/header.yaml delete mode 100644 config/metrics/templates/kubeadmconfig.yaml delete mode 100644 config/metrics/templates/kubeadmcontrolplane.yaml delete mode 100644 config/metrics/templates/machine.yaml delete mode 100644 config/metrics/templates/machinedeployment.yaml delete mode 100644 config/metrics/templates/machinehealthcheck.yaml delete mode 100644 config/metrics/templates/machinepool.yaml delete mode 100644 config/metrics/templates/machineset.yaml delete mode 100644 config/metrics/templates/owner_metric.yaml diff --git a/config/metrics/kustomization.yaml b/config/metrics/kustomization.yaml index 3955c8d0d945..efdaabd4ea99 100644 --- a/config/metrics/kustomization.yaml +++ b/config/metrics/kustomization.yaml @@ -1,12 +1,13 @@ resources: - - ./crd-clusterrole.yaml + - ./rbac.yaml namespace: observability +namePrefix: capi- configMapGenerator: -- name: kube-state-metrics-crd-config-capi +- name: kube-state-metrics-crd-config files: - - capi.yaml=crd-metrics-config.yaml + - capi.yaml=metrics.yaml options: disableNameSuffixHash: true labels: diff --git a/config/metrics/crd-metrics-config.yaml b/config/metrics/metrics.yaml similarity index 100% rename from config/metrics/crd-metrics-config.yaml rename to config/metrics/metrics.yaml diff --git a/config/metrics/crd-clusterrole.yaml b/config/metrics/rbac.yaml similarity index 100% rename from config/metrics/crd-clusterrole.yaml rename to config/metrics/rbac.yaml diff --git a/config/metrics/templates/README.md b/config/metrics/templates/README.md deleted file mode 100644 index c52a76817f1f..000000000000 --- a/config/metrics/templates/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Metrics - -**Disclamer**: This is a temporary workaround. The long-term goal is to generate metric configuration from API type markers. - -The make target `generate-metrics-config` is used to generate a single file which contains the Cluster API specific custom resource configuration for kube-state-metrics. - -To regenerate the file `../crd-metrics-config.yaml`, execute the `make generate-metrics-config` command. diff --git a/config/metrics/templates/cluster.yaml b/config/metrics/templates/cluster.yaml deleted file mode 100644 index f1e91daa6b57..000000000000 --- a/config/metrics/templates/cluster.yaml +++ /dev/null @@ -1,79 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: Cluster - version: v1beta1 - labelsFromPath: - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_cluster - metrics: - - name: info - help: Information about a cluster. - each: - info: - labelsFromPath: - topology_version: - - spec - - topology - - version - topology_class: - - spec - - topology - - class - control_plane_endpoint_host: - - spec - - controlPlaneEndpoint - - host - control_plane_endpoint_port: - - spec - - controlPlaneEndpoint - - port - control_plane_reference_kind: - - spec - - controlPlaneRef - - kind - control_plane_reference_name: - - spec - - controlPlaneRef - - name - infrastructure_reference_kind: - - spec - - infrastructureRef - - kind - infrastructure_reference_name: - - spec - - infrastructureRef - - name - type: Info - - name: spec_paused - help: Whether the cluster is paused and any of its resources will not be processed by the controllers. - each: - gauge: - nilIsZero: true - path: - - spec - - paused - type: Gauge - - name: status_phase - help: The clusters current phase. - each: - stateSet: - labelName: phase - list: - - Pending - - Provisioning - - Provisioned - - Deleting - - Failed - - Unknown - path: - - status - - phase - type: StateSet diff --git a/config/metrics/templates/clusterclass.yaml b/config/metrics/templates/clusterclass.yaml deleted file mode 100644 index 21b464d45e06..000000000000 --- a/config/metrics/templates/clusterclass.yaml +++ /dev/null @@ -1,26 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: ClusterClass - version: v1beta1 - labelsFromPath: - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_clusterclass - metrics: - - name: info - help: Information about a clusterclass. - each: - info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. - labelsFromPath: - name: - - metadata - - name - type: Info diff --git a/config/metrics/templates/common_metrics.yaml b/config/metrics/templates/common_metrics.yaml deleted file mode 100644 index 073631b9c88b..000000000000 --- a/config/metrics/templates/common_metrics.yaml +++ /dev/null @@ -1,52 +0,0 @@ - - name: created - help: Unix creation timestamp. - each: - gauge: - path: - - metadata - - creationTimestamp - type: Gauge - - name: annotation_paused - help: Whether the ${RESOURCE} is paused and any of its resources will not be processed by the controllers. - each: - info: - path: - - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] - type: Info - - name: status_condition - help: The condition of a ${RESOURCE}. - each: - stateSet: - labelName: status - labelsFromPath: - type: - - type - list: - - 'True' - - 'False' - - Unknown - path: - - status - - conditions - valueFrom: - - status - type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a ${RESOURCE}. - each: - gauge: - labelsFromPath: - type: - - type - status: - - status - path: - - status - - conditions - valueFrom: - - lastTransitionTime - type: Gauge diff --git a/config/metrics/templates/header.yaml b/config/metrics/templates/header.yaml deleted file mode 100644 index 6b74624c47d6..000000000000 --- a/config/metrics/templates/header.yaml +++ /dev/null @@ -1,3 +0,0 @@ -kind: CustomResourceStateMetrics -spec: - resources: diff --git a/config/metrics/templates/kubeadmconfig.yaml b/config/metrics/templates/kubeadmconfig.yaml deleted file mode 100644 index ffb240172a60..000000000000 --- a/config/metrics/templates/kubeadmconfig.yaml +++ /dev/null @@ -1,30 +0,0 @@ - - groupVersionKind: - group: bootstrap.cluster.x-k8s.io - kind: KubeadmConfig - version: v1beta1 - labelsFromPath: - cluster_name: - - metadata - - labels - - cluster.x-k8s.io/cluster-name - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_kubeadmconfig - metrics: - - name: info - help: Information about a kubeadmconfig. - each: - info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. - labelsFromPath: - name: - - metadata - - name - type: Info diff --git a/config/metrics/templates/kubeadmcontrolplane.yaml b/config/metrics/templates/kubeadmcontrolplane.yaml deleted file mode 100644 index 08db0c4e4f0e..000000000000 --- a/config/metrics/templates/kubeadmcontrolplane.yaml +++ /dev/null @@ -1,84 +0,0 @@ - - groupVersionKind: - group: controlplane.cluster.x-k8s.io - kind: KubeadmControlPlane - version: v1beta1 - labelsFromPath: - cluster_name: - - metadata - - ownerReferences - - '[kind=Cluster]' - - name - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_kubeadmcontrolplane - metrics: - - name: info - help: Information about a kubeadmcontrolplane. - each: - info: - labelsFromPath: - version: - - spec - - version - type: Info - - name: status_replicas - help: The number of replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_unavailable - help: The number of unavailable replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - unavailableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_updated - help: The number of updated replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - updatedReplicas - nilIsZero: true - type: Gauge - - name: spec_replicas - help: The number of desired machines for a kubeadmcontrolplane. - each: - gauge: - path: - - spec - - replicas - type: Gauge - - name: spec_strategy_rollingupdate_max_surge - help: Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a kubeadmcontrolplane. - each: - gauge: - path: - - spec - - rolloutStrategy - - rollingUpdate - - maxSurge - type: Gauge diff --git a/config/metrics/templates/machine.yaml b/config/metrics/templates/machine.yaml deleted file mode 100644 index b49b1d3b7c7e..000000000000 --- a/config/metrics/templates/machine.yaml +++ /dev/null @@ -1,130 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: Machine - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machine - metrics: - - name: info - help: Information about a machine. - each: - info: - labelsFromPath: - container_runtime_version: - - status - - nodeInfo - - containerRuntimeVersion - failure_domain: - - spec - - failureDomain - kernel_version: - - status - - nodeInfo - - kernelVersion - kubelet_version: - - status - - nodeInfo - - kubeletVersion - kube_proxy_version: - - status - - nodeInfo - - kubeProxyVersion - os_image: - - status - - nodeInfo - - osImage - provider_id: - - spec - - providerID - version: - - spec - - version - bootstrap_reference_kind: - - spec - - bootstrap - - configRef - - kind - bootstrap_reference_name: - - spec - - bootstrap - - configRef - - name - infrastructure_reference_kind: - - spec - - infrastructureRef - - kind - infrastructure_reference_name: - - spec - - infrastructureRef - - name - control_plane_name: - - metadata - - labels - - cluster.x-k8s.io/control-plane-name - type: Info - - name: addresses - help: Address information about a machine. - each: - info: - path: - - status - - addresses - labelsFromPath: - type: - - type - address: - - address - type: Info - - name: status_certificatesexpirydate - help: Information about certificate expiration date of a control plane node. - each: - gauge: - nilIsZero: true - path: - - status - - certificatesExpiryDate - type: Gauge - - name: status_noderef - help: Information about the node reference of a machine. - each: - info: - labelsFromPath: - node_name: - - status - - nodeRef - - name - node_uid: - - status - - nodeRef - - uid - type: Info - - name: status_phase - help: The machines current phase. - each: - stateSet: - labelName: phase - list: - - Pending - - Provisioning - - Provisioned - - Running - - Deleting - - Deleted - - Failed - - Unknown - path: - - status - - phase - type: StateSet diff --git a/config/metrics/templates/machinedeployment.yaml b/config/metrics/templates/machinedeployment.yaml deleted file mode 100644 index 1ece3552149a..000000000000 --- a/config/metrics/templates/machinedeployment.yaml +++ /dev/null @@ -1,153 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: MachineDeployment - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machinedeployment - metrics: - - name: info - help: Information about a machinedeployment. - each: - info: - labelsFromPath: - version: - - spec - - template - - spec - - version - bootstrap_reference_kind: - - spec - - template - - spec - - bootstrap - - configRef - - kind - bootstrap_reference_name: - - spec - - template - - spec - - bootstrap - - configRef - - name - infrastructure_reference_kind: - - spec - - template - - spec - - infrastructureRef - - kind - infrastructure_reference_name: - - spec - - template - - spec - - infrastructureRef - - name - type: Info - - name: spec_paused - help: Whether the machinedeployment is paused and any of its resources will not be processed by the controllers. - each: - gauge: - nilIsZero: true - path: - - spec - - paused - type: Gauge - - name: spec_replicas - help: The number of desired machines for a machinedeployment. - each: - gauge: - path: - - spec - - replicas - type: Gauge - - name: spec_strategy_rollingupdate_max_surge - help: Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a machinedeployment. - each: - gauge: - path: - - spec - - strategy - - rollingUpdate - - maxSurge - type: Gauge - - name: spec_strategy_rollingupdate_max_unavailable - help: Maximum number of unavailable replicas during a rolling update of a machinedeployment. - each: - gauge: - path: - - spec - - strategy - - rollingUpdate - - maxUnavailable - type: Gauge - - name: status_phase - help: The machinedeployments current phase. - each: - stateSet: - labelName: phase - list: - - ScalingUp - - ScalingDown - - Running - - Failed - - Unknown - path: - - status - - phase - type: StateSet - - name: status_replicas - help: The number of replicas per machinedeployment. - each: - gauge: - path: - - status - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_available - help: The number of available replicas per machinedeployment. - each: - gauge: - path: - - status - - availableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machinedeployment. - each: - gauge: - path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_unavailable - help: The number of unavailable replicas per machinedeployment. - each: - gauge: - path: - - status - - unavailableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_updated - help: The number of updated replicas per machinedeployment. - each: - gauge: - path: - - status - - updatedReplicas - nilIsZero: true - type: Gauge diff --git a/config/metrics/templates/machinehealthcheck.yaml b/config/metrics/templates/machinehealthcheck.yaml deleted file mode 100644 index a14a164be72b..000000000000 --- a/config/metrics/templates/machinehealthcheck.yaml +++ /dev/null @@ -1,53 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: MachineHealthCheck - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machinehealthcheck - metrics: - - name: info - help: Information about a machinehealthcheck. - each: - info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. - labelsFromPath: - name: - - metadata - - name - type: Info - - name: status_current_healthy - help: Current number of healthy machines. - each: - gauge: - path: - - status - - currentHealthy - type: Gauge - - name: status_expected_machines - help: Total number of pods counted by this machinehealthcheck. - each: - gauge: - path: - - status - - expectedMachines - type: Gauge - - name: status_remediations_allowed - help: Number of machine remediations that are currently allowed. - each: - gauge: - path: - - status - - remediationsAllowed - type: Gauge diff --git a/config/metrics/templates/machinepool.yaml b/config/metrics/templates/machinepool.yaml deleted file mode 100644 index a4dbb4aa7254..000000000000 --- a/config/metrics/templates/machinepool.yaml +++ /dev/null @@ -1,119 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: MachinePool - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machinepool - metrics: - - name: spec_replicas - help: The number of desired machines for a machinepool. - each: - gauge: - path: - - spec - - replicas - type: Gauge - - name: status_replicas - help: The number of replicas per machinepool. - each: - gauge: - path: - - status - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machinepool. - each: - gauge: - path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_available - help: The number of available replicas per machinepool. - each: - gauge: - path: - - status - - availableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_unavailable - help: The number of unavailable replicas per machinepool. - each: - gauge: - path: - - status - - unavailableReplicas - nilIsZero: true - type: Gauge - - name: info - each: - type: Info - info: - labelsFromPath: - infrastructure_reference_name: - - spec - - template - - spec - - infrastructureRef - - name - infrastructure_reference_kind: - - spec - - template - - spec - - infrastructureRef - - kind - bootstrap_configuration_reference_name: - - spec - - template - - spec - - bootstrap - - configRef - - name - bootstrap_configuration_reference_kind: - - spec - - template - - spec - - bootstrap - - configRef - - kind - failure_domain: - - spec - - template - - spec - - failureDomain - version: - - spec - - template - - spec - - version - - name: status_phase - help: The machinepools current phase. - each: - stateSet: - labelName: phase - list: - - ScalingUp - - ScalingDown - - Running - - Failed - - Unknown - path: - - status - - phase - type: StateSet diff --git a/config/metrics/templates/machineset.yaml b/config/metrics/templates/machineset.yaml deleted file mode 100644 index e2bde1ecde6e..000000000000 --- a/config/metrics/templates/machineset.yaml +++ /dev/null @@ -1,100 +0,0 @@ - - groupVersionKind: - group: cluster.x-k8s.io - kind: MachineSet - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machineset - metrics: - - name: info - help: Information about a machineset. - each: - info: - labelsFromPath: - version: - - spec - - template - - spec - - version - bootstrap_reference_kind: - - spec - - template - - spec - - bootstrap - - configRef - - kind - bootstrap_reference_name: - - spec - - template - - spec - - bootstrap - - configRef - - name - infrastructure_reference_kind: - - spec - - template - - spec - - infrastructureRef - - kind - infrastructure_reference_name: - - spec - - template - - spec - - infrastructureRef - - name - type: Info - - name: spec_replicas - help: The number of desired machines for a machineset. - each: - gauge: - path: - - spec - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_available - help: The number of available replicas per machineset. - each: - gauge: - path: - - status - - availableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_fully_labeled - help: The number of fully labeled replicas per machineset. - each: - gauge: - path: - - status - - fullyLabeledReplicas - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machineset. - each: - gauge: - path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas - help: The number of replicas per machineset. - each: - gauge: - path: - - status - - replicas - nilIsZero: true - type: Gauge diff --git a/config/metrics/templates/owner_metric.yaml b/config/metrics/templates/owner_metric.yaml deleted file mode 100644 index ae276010ef00..000000000000 --- a/config/metrics/templates/owner_metric.yaml +++ /dev/null @@ -1,17 +0,0 @@ - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid - path: - - metadata - - ownerReferences - type: Info From 94ca6ce33781c5b6dac97832f59234edd3067e4e Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 10:56:55 +0200 Subject: [PATCH 3/7] metrics: sort entries in metrics.yaml for better comparison to the new generated one --- config/metrics/metrics.yaml | 1733 +++++++++++++++++++---------------- 1 file changed, 921 insertions(+), 812 deletions(-) diff --git a/config/metrics/metrics.yaml b/config/metrics/metrics.yaml index 718af5a9bd9f..391aa77a1663 100644 --- a/config/metrics/metrics.yaml +++ b/config/metrics/metrics.yaml @@ -1,12 +1,15 @@ -# This file was auto-generated via: make generate-metrics-config -kind: CustomResourceStateMetrics spec: resources: - - groupVersionKind: - group: cluster.x-k8s.io - kind: ClusterClass + - errorLogV: 0 + groupVersionKind: + group: bootstrap.cluster.x-k8s.io + kind: KubeadmConfig version: v1beta1 labelsFromPath: + cluster_name: + - metadata + - labels + - cluster.x-k8s.io/cluster-name name: - metadata - name @@ -16,48 +19,66 @@ spec: uid: - metadata - uid - metricNamePrefix: capi_clusterclass + metricNamePrefix: capi_kubeadmconfig metrics: - - name: info - help: Information about a clusterclass. - each: + - each: info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. labelsFromPath: - name: - - metadata - - name + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused type: Info - - name: created - help: Unix creation timestamp. - each: + help: Whether the kubeadmconfig is paused and any of its resources will not + be processed by the controllers. + name: annotation_paused + - each: gauge: + nilIsZero: false path: - metadata - creationTimestamp + valueFrom: null type: Gauge - - name: annotation_paused - help: Whether the clusterclass is paused and any of its resources will not be processed by the controllers. - each: + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + name: + - metadata + - name + path: null + type: Info + help: Information about a kubeadmconfig. + name: info + - each: info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid path: - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] + - ownerReferences type: Info - - name: status_condition - help: The condition of a clusterclass. - each: + help: Owner references. + name: owner + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -65,39 +86,27 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a clusterclass. - each: + help: The condition of a kubeadmconfig. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid - path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: + help: The condition last transition time of a kubeadmconfig. + name: status_condition_last_transition_time + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: group: cluster.x-k8s.io kind: Cluster version: v1beta1 @@ -113,19 +122,31 @@ spec: - uid metricNamePrefix: capi_cluster metrics: - - name: info - help: Information about a cluster. - each: + - each: + info: + labelsFromPath: + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the cluster is paused and any of its resources will not be processed + by the controllers. + name: annotation_paused + - each: + gauge: + nilIsZero: false + path: + - metadata + - creationTimestamp + valueFrom: null + type: Gauge + help: Unix creation timestamp. + name: created + - each: info: labelsFromPath: - topology_version: - - spec - - topology - - version - topology_class: - - spec - - topology - - class control_plane_endpoint_host: - spec - controlPlaneEndpoint @@ -150,62 +171,38 @@ spec: - spec - infrastructureRef - name + topology_class: + - spec + - topology + - class + topology_version: + - spec + - topology + - version + path: null type: Info - - name: spec_paused - help: Whether the cluster is paused and any of its resources will not be processed by the controllers. - each: + help: Information about a cluster. + name: info + - each: gauge: nilIsZero: true path: - spec - paused + valueFrom: null type: Gauge - - name: status_phase - help: The clusters current phase. - each: - stateSet: - labelName: phase - list: - - Pending - - Provisioning - - Provisioned - - Deleting - - Failed - - Unknown - path: - - status - - phase - type: StateSet - - name: created - help: Unix creation timestamp. - each: - gauge: - path: - - metadata - - creationTimestamp - type: Gauge - - name: annotation_paused - help: Whether the cluster is paused and any of its resources will not be processed by the controllers. - each: - info: - path: - - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] - type: Info - - name: status_condition - help: The condition of a cluster. - each: + help: Whether the cluster is paused and any of its resources will not be processed + by the controllers. + name: spec_paused + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -213,31 +210,48 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a cluster. - each: + help: The condition of a cluster. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - groupVersionKind: - group: controlplane.cluster.x-k8s.io - kind: KubeadmControlPlane + help: The condition last transition time of a cluster. + name: status_condition_last_transition_time + - each: + stateSet: + labelName: phase + list: + - Pending + - Provisioning + - Provisioned + - Deleting + - Failed + - Unknown + path: + - status + - phase + valueFrom: null + type: StateSet + help: The clusters current phase. + name: status_phase + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: + group: cluster.x-k8s.io + kind: ClusterClass version: v1beta1 labelsFromPath: - cluster_name: - - metadata - - ownerReferences - - '[kind=Cluster]' - - name name: - metadata - name @@ -247,101 +261,66 @@ spec: uid: - metadata - uid - metricNamePrefix: capi_kubeadmcontrolplane + metricNamePrefix: capi_clusterclass metrics: - - name: info - help: Information about a kubeadmcontrolplane. - each: + - each: info: labelsFromPath: - version: - - spec - - version - type: Info - - name: status_replicas - help: The number of replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_unavailable - help: The number of unavailable replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - unavailableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_updated - help: The number of updated replicas per kubeadmcontrolplane. - each: - gauge: - path: - - status - - updatedReplicas - nilIsZero: true - type: Gauge - - name: spec_replicas - help: The number of desired machines for a kubeadmcontrolplane. - each: - gauge: - path: - - spec - - replicas - type: Gauge - - name: spec_strategy_rollingupdate_max_surge - help: Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a kubeadmcontrolplane. - each: - gauge: + paused_value: [] path: - - spec - - rolloutStrategy - - rollingUpdate - - maxSurge - type: Gauge - - name: created - help: Unix creation timestamp. - each: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the clusterclass is paused and any of its resources will not be + processed by the controllers. + name: annotation_paused + - each: gauge: + nilIsZero: false path: - metadata - creationTimestamp + valueFrom: null type: Gauge - - name: annotation_paused - help: Whether the kubeadmcontrolplane is paused and any of its resources will not be processed by the controllers. - each: + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + name: + - metadata + - name + path: null + type: Info + help: Information about a clusterclass. + name: info + - each: info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid path: - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] + - ownerReferences type: Info - - name: status_condition - help: The condition of a kubeadmcontrolplane. - each: + help: Owner references. + name: owner + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -349,47 +328,34 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a kubeadmcontrolplane. - each: + help: The condition of a clusterclass. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid - path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: - group: bootstrap.cluster.x-k8s.io - kind: KubeadmConfig + help: The condition last transition time of a clusterclass. + name: status_condition_last_transition_time + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: + group: cluster.x-k8s.io + kind: Machine version: v1beta1 labelsFromPath: cluster_name: - - metadata - - labels - - cluster.x-k8s.io/cluster-name + - spec + - clusterName name: - metadata - name @@ -399,130 +365,87 @@ spec: uid: - metadata - uid - metricNamePrefix: capi_kubeadmconfig + metricNamePrefix: capi_machine metrics: - - name: info - help: Information about a kubeadmconfig. - each: + - each: info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. labelsFromPath: - name: - - metadata - - name - type: Info - - name: created - help: Unix creation timestamp. - each: - gauge: + address: + - address + type: + - type path: - - metadata - - creationTimestamp - type: Gauge - - name: annotation_paused - help: Whether the kubeadmconfig is paused and any of its resources will not be processed by the controllers. - each: + - status + - addresses + type: Info + help: Address information about a machine. + name: addresses + - each: info: + labelsFromPath: + paused_value: [] path: - metadata - annotations - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] type: Info - - name: status_condition - help: The condition of a kubeadmconfig. - each: - stateSet: - labelName: status - labelsFromPath: - type: - - type - list: - - 'True' - - 'False' - - Unknown - path: - - status - - conditions - valueFrom: - - status - type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a kubeadmconfig. - each: + help: Whether the machine is paused and any of its resources will not be processed + by the controllers. + name: annotation_paused + - each: gauge: - labelsFromPath: - type: - - type - status: - - status + nilIsZero: false path: - - status - - conditions - valueFrom: - - lastTransitionTime + - metadata + - creationTimestamp + valueFrom: null type: Gauge - - name: owner - help: Owner references. - each: + help: Unix creation timestamp. + name: created + - each: info: labelsFromPath: - owner_is_controller: - - controller - owner_kind: + bootstrap_reference_kind: + - spec + - bootstrap + - configRef - kind - owner_name: + bootstrap_reference_name: + - spec + - bootstrap + - configRef - name - owner_uid: - - uid - path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: - group: cluster.x-k8s.io - kind: Machine - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machine - metrics: - - name: info - help: Information about a machine. - each: - info: - labelsFromPath: container_runtime_version: - status - nodeInfo - containerRuntimeVersion + control_plane_name: + - metadata + - labels + - cluster.x-k8s.io/control-plane-name failure_domain: - spec - failureDomain + infrastructure_reference_kind: + - spec + - infrastructureRef + - kind + infrastructure_reference_name: + - spec + - infrastructureRef + - name kernel_version: - status - nodeInfo - kernelVersion - kubelet_version: - - status - - nodeInfo - - kubeletVersion kube_proxy_version: - status - nodeInfo - kubeProxyVersion + kubelet_version: + - status + - nodeInfo + - kubeletVersion os_image: - status - nodeInfo @@ -533,113 +456,46 @@ spec: version: - spec - version - bootstrap_reference_kind: - - spec - - bootstrap - - configRef - - kind - bootstrap_reference_name: - - spec - - bootstrap - - configRef - - name - infrastructure_reference_kind: - - spec - - infrastructureRef - - kind - infrastructure_reference_name: - - spec - - infrastructureRef - - name - control_plane_name: - - metadata - - labels - - cluster.x-k8s.io/control-plane-name - type: Info - - name: addresses - help: Address information about a machine. - each: - info: - path: - - status - - addresses - labelsFromPath: - type: - - type - address: - - address + path: null type: Info - - name: status_certificatesexpirydate - help: Information about certificate expiration date of a control plane node. - each: - gauge: - nilIsZero: true - path: - - status - - certificatesExpiryDate - type: Gauge - - name: status_noderef - help: Information about the node reference of a machine. - each: + help: Information about a machine. + name: info + - each: info: labelsFromPath: - node_name: - - status - - nodeRef + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: - name - node_uid: - - status - - nodeRef + owner_uid: - uid - type: Info - - name: status_phase - help: The machines current phase. - each: - stateSet: - labelName: phase - list: - - Pending - - Provisioning - - Provisioned - - Running - - Deleting - - Deleted - - Failed - - Unknown path: - - status - - phase - type: StateSet - - name: created - help: Unix creation timestamp. - each: + - metadata + - ownerReferences + type: Info + help: Owner references. + name: owner + - each: gauge: + nilIsZero: true path: - - metadata - - creationTimestamp + - status + - certificatesExpiryDate + valueFrom: null type: Gauge - - name: annotation_paused - help: Whether the machine is paused and any of its resources will not be processed by the controllers. - each: - info: - path: - - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] - type: Info - - name: status_condition - help: The condition of a machine. - each: + help: Information about certificate expiration date of a control plane node. + name: status_certificatesexpirydate + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -647,39 +503,61 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a machine. - each: + help: The condition of a machine. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: + help: The condition last transition time of a machine. + name: status_condition_last_transition_time + - each: info: labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: + node_name: + - status + - nodeRef - name - owner_uid: + node_uid: + - status + - nodeRef - uid - path: - - metadata - - ownerReferences + path: null type: Info - - groupVersionKind: + help: Information about the node reference of a machine. + name: status_noderef + - each: + stateSet: + labelName: phase + list: + - Pending + - Provisioning + - Provisioned + - Running + - Deleting + - Deleted + - Failed + - Unknown + path: + - status + - phase + valueFrom: null + type: StateSet + help: The machines current phase. + name: status_phase + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: group: cluster.x-k8s.io kind: MachineDeployment version: v1beta1 @@ -698,18 +576,33 @@ spec: - uid metricNamePrefix: capi_machinedeployment metrics: - - name: info - help: Information about a machinedeployment. - each: + - each: info: labelsFromPath: - version: - - spec - - template - - spec - - version - bootstrap_reference_kind: - - spec + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the machinedeployment is paused and any of its resources will + not be processed by the controllers. + name: annotation_paused + - each: + gauge: + nilIsZero: false + path: + - metadata + - creationTimestamp + valueFrom: null + type: Gauge + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + bootstrap_reference_kind: + - spec - template - spec - bootstrap @@ -734,47 +627,113 @@ spec: - spec - infrastructureRef - name + version: + - spec + - template + - spec + - version + path: null + type: Info + help: Information about a machinedeployment. + name: info + - each: + info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid + path: + - metadata + - ownerReferences type: Info - - name: spec_paused - help: Whether the machinedeployment is paused and any of its resources will not be processed by the controllers. - each: + help: Owner references. + name: owner + - each: gauge: nilIsZero: true path: - spec - paused + valueFrom: null type: Gauge - - name: spec_replicas - help: The number of desired machines for a machinedeployment. - each: + help: Whether the machinedeployment is paused and any of its resources will + not be processed by the controllers. + name: spec_paused + - each: gauge: + nilIsZero: false path: - spec - replicas + valueFrom: null type: Gauge - - name: spec_strategy_rollingupdate_max_surge - help: Maximum number of replicas that can be scheduled above the desired number of replicas during a rolling update of a machinedeployment. - each: + help: The number of desired machines for a machinedeployment. + name: spec_replicas + - each: gauge: + nilIsZero: false path: - spec - strategy - rollingUpdate - maxSurge + valueFrom: null type: Gauge - - name: spec_strategy_rollingupdate_max_unavailable - help: Maximum number of unavailable replicas during a rolling update of a machinedeployment. - each: + help: Maximum number of replicas that can be scheduled above the desired number + of replicas during a rolling update of a machinedeployment. + name: spec_strategy_rollingupdate_max_surge + - each: gauge: + nilIsZero: false path: - spec - strategy - rollingUpdate - maxUnavailable + valueFrom: null type: Gauge - - name: status_phase - help: The machinedeployments current phase. - each: + help: Maximum number of unavailable replicas during a rolling update of a machinedeployment. + name: spec_strategy_rollingupdate_max_unavailable + - each: + stateSet: + labelName: status + labelsFromPath: + type: + - type + list: + - "True" + - "False" + - Unknown + path: + - status + - conditions + valueFrom: + - status + type: StateSet + help: The condition of a machinedeployment. + name: status_condition + - each: + gauge: + labelsFromPath: + status: + - status + type: + - type + nilIsZero: false + path: + - status + - conditions + valueFrom: + - lastTransitionTime + type: Gauge + help: The condition last transition time of a machinedeployment. + name: status_condition_last_transition_time + - each: stateSet: labelName: phase list: @@ -786,122 +745,63 @@ spec: path: - status - phase + valueFrom: null type: StateSet - - name: status_replicas - help: The number of replicas per machinedeployment. - each: + help: The machinedeployments current phase. + name: status_phase + - each: gauge: + nilIsZero: true path: - status - replicas - nilIsZero: true + valueFrom: null type: Gauge - - name: status_replicas_available - help: The number of available replicas per machinedeployment. - each: + help: The number of replicas per machinedeployment. + name: status_replicas + - each: gauge: + nilIsZero: true path: - status - availableReplicas - nilIsZero: true + valueFrom: null type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machinedeployment. - each: + help: The number of available replicas per machinedeployment. + name: status_replicas_available + - each: gauge: + nilIsZero: true path: - status - readyReplicas - nilIsZero: true + valueFrom: null type: Gauge - - name: status_replicas_unavailable - help: The number of unavailable replicas per machinedeployment. - each: + help: The number of ready replicas per machinedeployment. + name: status_replicas_ready + - each: gauge: + nilIsZero: true path: - status - unavailableReplicas - nilIsZero: true + valueFrom: null type: Gauge - - name: status_replicas_updated - help: The number of updated replicas per machinedeployment. - each: + help: The number of unavailable replicas per machinedeployment. + name: status_replicas_unavailable + - each: gauge: - path: - - status - - updatedReplicas nilIsZero: true - type: Gauge - - name: created - help: Unix creation timestamp. - each: - gauge: - path: - - metadata - - creationTimestamp - type: Gauge - - name: annotation_paused - help: Whether the machinedeployment is paused and any of its resources will not be processed by the controllers. - each: - info: - path: - - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] - type: Info - - name: status_condition - help: The condition of a machinedeployment. - each: - stateSet: - labelName: status - labelsFromPath: - type: - - type - list: - - 'True' - - 'False' - - Unknown - path: - - status - - conditions - valueFrom: - - status - type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a machinedeployment. - each: - gauge: - labelsFromPath: - type: - - type - status: - - status path: - status - - conditions - valueFrom: - - lastTransitionTime + - updatedReplicas + valueFrom: null type: Gauge - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid - path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: + help: The number of updated replicas per machinedeployment. + name: status_replicas_updated + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: group: cluster.x-k8s.io kind: MachineHealthCheck version: v1beta1 @@ -920,70 +820,64 @@ spec: - uid metricNamePrefix: capi_machinehealthcheck metrics: - - name: info - help: Information about a machinehealthcheck. - each: + - each: info: - # TODO: added metadata.name even it's already defined above as the metric doesn't work with empty labelsFromPath. labelsFromPath: - name: - - metadata - - name - type: Info - - name: status_current_healthy - help: Current number of healthy machines. - each: - gauge: - path: - - status - - currentHealthy - type: Gauge - - name: status_expected_machines - help: Total number of pods counted by this machinehealthcheck. - each: - gauge: - path: - - status - - expectedMachines - type: Gauge - - name: status_remediations_allowed - help: Number of machine remediations that are currently allowed. - each: - gauge: + paused_value: [] path: - - status - - remediationsAllowed - type: Gauge - - name: created - help: Unix creation timestamp. - each: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the machinehealthcheck is paused and any of its resources will + not be processed by the controllers. + name: annotation_paused + - each: gauge: + nilIsZero: false path: - metadata - creationTimestamp + valueFrom: null type: Gauge - - name: annotation_paused - help: Whether the machinehealthcheck is paused and any of its resources will not be processed by the controllers. - each: + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + name: + - metadata + - name + path: null + type: Info + help: Information about a machinehealthcheck. + name: info + - each: info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid path: - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] + - ownerReferences type: Info - - name: status_condition - help: The condition of a machinehealthcheck. - each: + help: Owner references. + name: owner + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -991,41 +885,59 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a machinehealthcheck. - each: + help: The condition of a machinehealthcheck. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid + help: The condition last transition time of a machinehealthcheck. + name: status_condition_last_transition_time + - each: + gauge: + nilIsZero: false path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: + - status + - currentHealthy + valueFrom: null + type: Gauge + help: Current number of healthy machines. + name: status_current_healthy + - each: + gauge: + nilIsZero: false + path: + - status + - expectedMachines + valueFrom: null + type: Gauge + help: Total number of pods counted by this machinehealthcheck. + name: status_expected_machines + - each: + gauge: + nilIsZero: false + path: + - status + - remediationsAllowed + valueFrom: null + type: Gauge + help: Number of machine remediations that are currently allowed. + name: status_remediations_allowed + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: group: cluster.x-k8s.io - kind: MachineSet + kind: MachinePool version: v1beta1 labelsFromPath: cluster_name: @@ -1040,32 +952,52 @@ spec: uid: - metadata - uid - metricNamePrefix: capi_machineset + metricNamePrefix: capi_machinepool metrics: - - name: info - help: Information about a machineset. - each: + - each: info: labelsFromPath: - version: - - spec - - template - - spec - - version - bootstrap_reference_kind: - - spec - - template - - spec - - bootstrap - - configRef - - kind - bootstrap_reference_name: - - spec - - template + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the machinepool is paused and any of its resources will not be + processed by the controllers. + name: annotation_paused + - each: + gauge: + nilIsZero: false + path: + - metadata + - creationTimestamp + valueFrom: null + type: Gauge + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + bootstrap_configuration_reference_kind: + - spec + - template + - spec + - bootstrap + - configRef + - kind + bootstrap_configuration_reference_name: + - spec + - template - spec - bootstrap - configRef - name + failure_domain: + - spec + - template + - spec + - failureDomain infrastructure_reference_kind: - spec - template @@ -1078,81 +1010,51 @@ spec: - spec - infrastructureRef - name + version: + - spec + - template + - spec + - version + path: null type: Info - - name: spec_replicas - help: The number of desired machines for a machineset. - each: - gauge: - path: - - spec - - replicas - nilIsZero: true - type: Gauge - - name: status_replicas_available - help: The number of available replicas per machineset. - each: - gauge: - path: - - status - - availableReplicas - nilIsZero: true - type: Gauge - - name: status_replicas_fully_labeled - help: The number of fully labeled replicas per machineset. - each: - gauge: - path: - - status - - fullyLabeledReplicas - type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machineset. - each: - gauge: + help: "" + name: info + - each: + info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid path: - - status - - readyReplicas - nilIsZero: true - type: Gauge - - name: status_replicas - help: The number of replicas per machineset. - each: + - metadata + - ownerReferences + type: Info + help: Owner references. + name: owner + - each: gauge: + nilIsZero: false path: - - status + - spec - replicas - nilIsZero: true - type: Gauge - - name: created - help: Unix creation timestamp. - each: - gauge: - path: - - metadata - - creationTimestamp + valueFrom: null type: Gauge - - name: annotation_paused - help: Whether the machineset is paused and any of its resources will not be processed by the controllers. - each: - info: - path: - - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] - type: Info - - name: status_condition - help: The condition of a machineset. - each: + help: The number of desired machines for a machinepool. + name: spec_replicas + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -1160,187 +1062,197 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a machineset. - each: + help: The condition of a machinepool. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: - info: - labelsFromPath: - owner_is_controller: - - controller - owner_kind: - - kind - owner_name: - - name - owner_uid: - - uid + help: The condition last transition time of a machinepool. + name: status_condition_last_transition_time + - each: + stateSet: + labelName: phase + list: + - ScalingUp + - ScalingDown + - Running + - Failed + - Unknown path: - - metadata - - ownerReferences - type: Info - - groupVersionKind: - group: cluster.x-k8s.io - kind: MachinePool - version: v1beta1 - labelsFromPath: - cluster_name: - - spec - - clusterName - name: - - metadata - - name - namespace: - - metadata - - namespace - uid: - - metadata - - uid - metricNamePrefix: capi_machinepool - metrics: - - name: spec_replicas - help: The number of desired machines for a machinepool. - each: + - status + - phase + valueFrom: null + type: StateSet + help: The machinepools current phase. + name: status_phase + - each: gauge: + nilIsZero: true path: - - spec + - status - replicas + valueFrom: null type: Gauge - - name: status_replicas help: The number of replicas per machinepool. - each: + name: status_replicas + - each: gauge: + nilIsZero: true path: - status - - replicas - nilIsZero: true + - availableReplicas + valueFrom: null type: Gauge - - name: status_replicas_ready - help: The number of ready replicas per machinepool. - each: + help: The number of available replicas per machinepool. + name: status_replicas_available + - each: gauge: + nilIsZero: true path: - status - readyReplicas - nilIsZero: true + valueFrom: null type: Gauge - - name: status_replicas_available - help: The number of available replicas per machinepool. - each: + help: The number of ready replicas per machinepool. + name: status_replicas_ready + - each: gauge: + nilIsZero: true path: - status - - availableReplicas - nilIsZero: true + - unavailableReplicas + valueFrom: null type: Gauge - - name: status_replicas_unavailable help: The number of unavailable replicas per machinepool. - each: + name: status_replicas_unavailable + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: + group: cluster.x-k8s.io + kind: MachineSet + version: v1beta1 + labelsFromPath: + cluster_name: + - spec + - clusterName + name: + - metadata + - name + namespace: + - metadata + - namespace + uid: + - metadata + - uid + metricNamePrefix: capi_machineset + metrics: + - each: + info: + labelsFromPath: + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the machineset is paused and any of its resources will not be + processed by the controllers. + name: annotation_paused + - each: gauge: + nilIsZero: false path: - - status - - unavailableReplicas - nilIsZero: true + - metadata + - creationTimestamp + valueFrom: null type: Gauge - - name: info - each: - type: Info + help: Unix creation timestamp. + name: created + - each: info: labelsFromPath: - infrastructure_reference_name: - - spec - - template - - spec - - infrastructureRef - - name - infrastructure_reference_kind: + bootstrap_reference_kind: - spec - template - spec - - infrastructureRef + - bootstrap + - configRef - kind - bootstrap_configuration_reference_name: + bootstrap_reference_name: - spec - template - spec - bootstrap - configRef - name - bootstrap_configuration_reference_kind: + infrastructure_reference_kind: - spec - template - spec - - bootstrap - - configRef + - infrastructureRef - kind - failure_domain: + infrastructure_reference_name: - spec - template - spec - - failureDomain + - infrastructureRef + - name version: - spec - template - spec - version - - name: status_phase - help: The machinepools current phase. - each: - stateSet: - labelName: phase - list: - - ScalingUp - - ScalingDown - - Running - - Failed - - Unknown - path: - - status - - phase - type: StateSet - - name: created - help: Unix creation timestamp. - each: - gauge: - path: - - metadata - - creationTimestamp - type: Gauge - - name: annotation_paused - help: Whether the machinepool is paused and any of its resources will not be processed by the controllers. - each: + path: null + type: Info + help: Information about a machineset. + name: info + - each: info: + labelsFromPath: + owner_is_controller: + - controller + owner_kind: + - kind + owner_name: + - name + owner_uid: + - uid path: - metadata - - annotations - - cluster.x-k8s.io/paused - labelsFromPath: - paused_value: [] + - ownerReferences type: Info - - name: status_condition - help: The condition of a machinepool. - each: + help: Owner references. + name: owner + - each: + gauge: + nilIsZero: true + path: + - spec + - replicas + valueFrom: null + type: Gauge + help: The number of desired machines for a machineset. + name: spec_replicas + - each: stateSet: labelName: status labelsFromPath: type: - type list: - - 'True' - - 'False' + - "True" + - "False" - Unknown path: - status @@ -1348,24 +1260,120 @@ spec: valueFrom: - status type: StateSet - - name: status_condition_last_transition_time - help: The condition last transition time of a machinepool. - each: + help: The condition of a machineset. + name: status_condition + - each: gauge: labelsFromPath: - type: - - type status: - status + type: + - type + nilIsZero: false path: - status - conditions valueFrom: - lastTransitionTime type: Gauge - - name: owner - help: Owner references. - each: + help: The condition last transition time of a machineset. + name: status_condition_last_transition_time + - each: + gauge: + nilIsZero: true + path: + - status + - replicas + valueFrom: null + type: Gauge + help: The number of replicas per machineset. + name: status_replicas + - each: + gauge: + nilIsZero: true + path: + - status + - availableReplicas + valueFrom: null + type: Gauge + help: The number of available replicas per machineset. + name: status_replicas_available + - each: + gauge: + nilIsZero: false + path: + - status + - fullyLabeledReplicas + valueFrom: null + type: Gauge + help: The number of fully labeled replicas per machineset. + name: status_replicas_fully_labeled + - each: + gauge: + nilIsZero: true + path: + - status + - readyReplicas + valueFrom: null + type: Gauge + help: The number of ready replicas per machineset. + name: status_replicas_ready + resourcePlural: "" + - errorLogV: 0 + groupVersionKind: + group: controlplane.cluster.x-k8s.io + kind: KubeadmControlPlane + version: v1beta1 + labelsFromPath: + cluster_name: + - metadata + - ownerReferences + - '[kind=Cluster]' + - name + name: + - metadata + - name + namespace: + - metadata + - namespace + uid: + - metadata + - uid + metricNamePrefix: capi_kubeadmcontrolplane + metrics: + - each: + info: + labelsFromPath: + paused_value: [] + path: + - metadata + - annotations + - cluster.x-k8s.io/paused + type: Info + help: Whether the kubeadmcontrolplane is paused and any of its resources will + not be processed by the controllers. + name: annotation_paused + - each: + gauge: + nilIsZero: false + path: + - metadata + - creationTimestamp + valueFrom: null + type: Gauge + help: Unix creation timestamp. + name: created + - each: + info: + labelsFromPath: + version: + - spec + - version + path: null + type: Info + help: Information about a kubeadmcontrolplane. + name: info + - each: info: labelsFromPath: owner_is_controller: @@ -1380,3 +1388,104 @@ spec: - metadata - ownerReferences type: Info + help: Owner references. + name: owner + - each: + gauge: + nilIsZero: false + path: + - spec + - replicas + valueFrom: null + type: Gauge + help: The number of desired machines for a kubeadmcontrolplane. + name: spec_replicas + - each: + gauge: + nilIsZero: false + path: + - spec + - rolloutStrategy + - rollingUpdate + - maxSurge + valueFrom: null + type: Gauge + help: Maximum number of replicas that can be scheduled above the desired number + of replicas during a rolling update of a kubeadmcontrolplane. + name: spec_strategy_rollingupdate_max_surge + - each: + stateSet: + labelName: status + labelsFromPath: + type: + - type + list: + - "True" + - "False" + - Unknown + path: + - status + - conditions + valueFrom: + - status + type: StateSet + help: The condition of a kubeadmcontrolplane. + name: status_condition + - each: + gauge: + labelsFromPath: + status: + - status + type: + - type + nilIsZero: false + path: + - status + - conditions + valueFrom: + - lastTransitionTime + type: Gauge + help: The condition last transition time of a kubeadmcontrolplane. + name: status_condition_last_transition_time + - each: + gauge: + nilIsZero: true + path: + - status + - replicas + valueFrom: null + type: Gauge + help: The number of replicas per kubeadmcontrolplane. + name: status_replicas + - each: + gauge: + nilIsZero: true + path: + - status + - readyReplicas + valueFrom: null + type: Gauge + help: The number of ready replicas per kubeadmcontrolplane. + name: status_replicas_ready + - each: + gauge: + nilIsZero: true + path: + - status + - unavailableReplicas + valueFrom: null + type: Gauge + help: The number of unavailable replicas per kubeadmcontrolplane. + name: status_replicas_unavailable + - each: + gauge: + nilIsZero: true + path: + - status + - updatedReplicas + valueFrom: null + type: Gauge + help: The number of updated replicas per kubeadmcontrolplane. + name: status_replicas_updated + resourcePlural: "" + From 599a20aac292a918dca5509d46f3bf84dfe68276 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 10:57:25 +0200 Subject: [PATCH 4/7] metrics: adjust generate-metrics-config to use controller-gen --- Makefile | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 945462337d44..4efb4f7cbd71 100644 --- a/Makefile +++ b/Makefile @@ -615,18 +615,12 @@ generate-e2e-templates-main: $(KUSTOMIZE) $(KUSTOMIZE) build $(INMEMORY_TEMPLATES)/main/cluster-template --load-restrictor LoadRestrictionsNone > $(INMEMORY_TEMPLATES)/main/cluster-template.yaml .PHONY: generate-metrics-config -generate-metrics-config: $(ENVSUBST_BIN) ## Generate ./config/metrics/crd-metrics-config.yaml - OUTPUT_FILE="./config/metrics/crd-metrics-config.yaml"; \ - METRIC_TEMPLATES_DIR="./config/metrics/templates"; \ - echo "# This file was auto-generated via: make generate-metrics-config" > "$${OUTPUT_FILE}"; \ - cat "$${METRIC_TEMPLATES_DIR}/header.yaml" >> "$${OUTPUT_FILE}"; \ - for resource in clusterclass cluster kubeadmcontrolplane kubeadmconfig machine machinedeployment machinehealthcheck machineset machinepool; do \ - cat "$${METRIC_TEMPLATES_DIR}/$${resource}.yaml"; \ - RESOURCE="$${resource}" ${ENVSUBST_BIN} < "$${METRIC_TEMPLATES_DIR}/common_metrics.yaml"; \ - if [[ "$${resource}" != "cluster" ]]; then \ - cat "$${METRIC_TEMPLATES_DIR}/owner_metric.yaml"; \ - fi \ - done >> "$${OUTPUT_FILE}"; \ +generate-metrics-config: $(CONTROLLER_GEN) ## Generate ./config/metrics/crd-metrics-config.yaml + $(CONTROLLER_GEN) metrics output:metrics:dir=./config/metrics \ + paths=./api/... \ + paths=./controlplane/kubeadm/api/... \ + paths=./bootstrap/kubeadm/api/... \ + paths=./exp/api/... .PHONY: generate-diagrams generate-diagrams: ## Generate diagrams for *.plantuml files From c6a4347409e50ccc3965fd4956e78b3f480a97a1 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 11:15:23 +0200 Subject: [PATCH 5/7] DROPME: use controller-gen from fork --- Makefile | 6 ++- scripts/go_install_fork.sh | 85 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100755 scripts/go_install_fork.sh diff --git a/Makefile b/Makefile index 4efb4f7cbd71..8e528a7342d6 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,7 @@ CAPD_DIR := $(TEST_DIR)/infrastructure/docker CAPIM_DIR := $(TEST_DIR)/infrastructure/inmemory TEST_EXTENSION_DIR := $(TEST_DIR)/extension GO_INSTALL := ./scripts/go_install.sh +GO_INSTALL_FORK := ./scripts/go_install_fork.sh OBSERVABILITY_DIR := hack/observability export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH) @@ -106,10 +107,11 @@ SETUP_ENVTEST_BIN := setup-envtest SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER)) SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest -CONTROLLER_GEN_VER := v0.16.1 +CONTROLLER_GEN_VER := 28f149a996f13a897b7b60ad18f4080b9a183ff9 CONTROLLER_GEN_BIN := controller-gen CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)) CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen +CONTROLLER_GEN_PKG_REPLACE := sigs.k8s.io/controller-tools=github.com/chrischdi/controller-tools GOTESTSUM_VER := v1.11.0 GOTESTSUM_BIN := gotestsum @@ -1426,7 +1428,7 @@ $(GOVULNCHECK_BIN): $(GOVULNCHECK) ## Build a local copy of govulncheck. $(IMPORT_BOSS_BIN): $(IMPORT_BOSS) $(CONTROLLER_GEN): # Build controller-gen from tools folder. - GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER) + GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL_FORK) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER) $(CONTROLLER_GEN_PKG_REPLACE) ## We are forcing a rebuilt of conversion-gen via PHONY so that we're always using an up-to-date version. ## We can't use a versioned name for the binary, because that would be reflected in generated files. diff --git a/scripts/go_install_fork.sh b/scripts/go_install_fork.sh new file mode 100755 index 000000000000..39204ad658ee --- /dev/null +++ b/scripts/go_install_fork.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +if [ -z "${1}" ]; then + echo "must provide module as first parameter" + exit 1 +fi + +if [ -z "${2}" ]; then + echo "must provide binary name as second parameter" + exit 1 +fi + +if [ -z "${3}" ]; then + echo "must provide version as third parameter" + exit 1 +fi + +if [ -z "${4}" ]; then + echo "must provide the replace parameter as third parameter" + exit 1 +fi + +if [ -z "${GOBIN}" ]; then + echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory." + exit 1 +fi + +rm -f "${GOBIN}/${2}"* || true + +export GOWORK="off" + +ORIGINAL_WORKDIR="$(pwd)" +TMP_MODULE_DIR="${2}.tmp" + +# Create TMP_MODULE_DIR to create a go module for building the binary. +# This is required because CAPI's hack/tools is not compatible to `go install`. +rm -r "${TMP_MODULE_DIR}" || true +mkdir -p "${TMP_MODULE_DIR}" +cd "${TMP_MODULE_DIR}" + +# Initialize a go module and place a tools.go file for building the binary. +go mod init "tools" + +# Set a replace from the original module to the fork +go mod edit -replace "${4}@${3}" + +# Create go file which imports the required package and resolve dependencies. +cat << EOF > tools.go +//go:build tools +// +build tools +package tools + +import ( + _ "${1}" +) +EOF + +go mod tidy + +# Build the binary. +go build -tags=tools -o "${GOBIN}/${2}-${3}" "${1}" + +# Get back to the original directory and cleanup the temporary directory. +cd "${ORIGINAL_WORKDIR}" +rm -r "${TMP_MODULE_DIR}" + +# Link the unversioned name to the versioned binary. +ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}" From 28382282716bcbbcd6d719eadd508bbca8c110e8 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 12:25:38 +0200 Subject: [PATCH 6/7] DROPME: diff due to generate and controller-gen version --- ...strap.cluster.x-k8s.io_kubeadmconfigs.yaml | 2 +- ...uster.x-k8s.io_kubeadmconfigtemplates.yaml | 2 +- bootstrap/kubeadm/config/rbac/role.yaml | 14 ++--- .../clusterctl.cluster.x-k8s.io_metadata.yaml | 2 +- ...clusterctl.cluster.x-k8s.io_providers.yaml | 2 +- .../config/manifest/clusterctl-api.yaml | 2 +- ...r.x-k8s.io_clusterresourcesetbindings.yaml | 2 +- ....cluster.x-k8s.io_clusterresourcesets.yaml | 2 +- .../cluster.x-k8s.io_clusterclasses.yaml | 2 +- .../crd/bases/cluster.x-k8s.io_clusters.yaml | 2 +- .../cluster.x-k8s.io_machinedeployments.yaml | 2 +- .../cluster.x-k8s.io_machinehealthchecks.yaml | 2 +- .../bases/cluster.x-k8s.io_machinepools.yaml | 2 +- .../crd/bases/cluster.x-k8s.io_machines.yaml | 2 +- .../bases/cluster.x-k8s.io_machinesets.yaml | 2 +- ...ipam.cluster.x-k8s.io_ipaddressclaims.yaml | 2 +- .../ipam.cluster.x-k8s.io_ipaddresses.yaml | 2 +- ...ime.cluster.x-k8s.io_extensionconfigs.yaml | 2 +- config/rbac/role.yaml | 58 +++++++++---------- ...cluster.x-k8s.io_kubeadmcontrolplanes.yaml | 2 +- ...x-k8s.io_kubeadmcontrolplanetemplates.yaml | 2 +- controlplane/kubeadm/config/rbac/role.yaml | 36 ++++++------ ...cture.cluster.x-k8s.io_dockerclusters.yaml | 2 +- ...uster.x-k8s.io_dockerclustertemplates.yaml | 2 +- ...e.cluster.x-k8s.io_dockermachinepools.yaml | 2 +- ...r.x-k8s.io_dockermachinepooltemplates.yaml | 2 +- ...cture.cluster.x-k8s.io_dockermachines.yaml | 2 +- ...uster.x-k8s.io_dockermachinetemplates.yaml | 2 +- ...ure.cluster.x-k8s.io_inmemoryclusters.yaml | 2 +- ...ter.x-k8s.io_inmemoryclustertemplates.yaml | 2 +- ...ure.cluster.x-k8s.io_inmemorymachines.yaml | 2 +- ...ter.x-k8s.io_inmemorymachinetemplates.yaml | 2 +- 32 files changed, 83 insertions(+), 83 deletions(-) diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml index 07d4fbdee075..f405e68cbdc9 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: kubeadmconfigs.bootstrap.cluster.x-k8s.io spec: group: bootstrap.cluster.x-k8s.io diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml index 6b2a65bab791..c4aa14c0a895 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: kubeadmconfigtemplates.bootstrap.cluster.x-k8s.io spec: group: bootstrap.cluster.x-k8s.io diff --git a/bootstrap/kubeadm/config/rbac/role.yaml b/bootstrap/kubeadm/config/rbac/role.yaml index 7e08acbef052..8b78a26a4f20 100644 --- a/bootstrap/kubeadm/config/rbac/role.yaml +++ b/bootstrap/kubeadm/config/rbac/role.yaml @@ -17,6 +17,13 @@ rules: - patch - update - watch +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch - apiGroups: - authentication.k8s.io resources: @@ -56,10 +63,3 @@ rules: - get - list - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch diff --git a/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_metadata.yaml b/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_metadata.yaml index aec029772427..9da79b7caa0d 100644 --- a/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_metadata.yaml +++ b/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_metadata.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: metadata.clusterctl.cluster.x-k8s.io spec: group: clusterctl.cluster.x-k8s.io diff --git a/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_providers.yaml b/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_providers.yaml index 9c508cc48be5..a19c7085d8db 100644 --- a/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_providers.yaml +++ b/cmd/clusterctl/config/crd/bases/clusterctl.cluster.x-k8s.io_providers.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: providers.clusterctl.cluster.x-k8s.io spec: group: clusterctl.cluster.x-k8s.io diff --git a/cmd/clusterctl/config/manifest/clusterctl-api.yaml b/cmd/clusterctl/config/manifest/clusterctl-api.yaml index ffda27c50978..0df903beffe3 100644 --- a/cmd/clusterctl/config/manifest/clusterctl-api.yaml +++ b/cmd/clusterctl/config/manifest/clusterctl-api.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: providers.clusterctl.cluster.x-k8s.io spec: group: clusterctl.cluster.x-k8s.io diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml index 066798121e5e..13c6e2fca4de 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: clusterresourcesetbindings.addons.cluster.x-k8s.io spec: group: addons.cluster.x-k8s.io diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml index 889a31ed0739..dd23f29406b0 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: clusterresourcesets.addons.cluster.x-k8s.io spec: group: addons.cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml index 80cd56ba7d17..82865cebe081 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: clusterclasses.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index cc62b73a7dd9..c8cc072b7f16 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: clusters.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml index 96b88497ba05..7281afb20ced 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: machinedeployments.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml index e8deecb8ed2c..ea006d84a599 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: machinehealthchecks.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml index 801658b64dda..da53a715073a 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: machinepools.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_machines.yaml b/config/crd/bases/cluster.x-k8s.io_machines.yaml index 493d6aca6646..b73075b08ee3 100644 --- a/config/crd/bases/cluster.x-k8s.io_machines.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machines.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: machines.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml index a1ddfd4ebe8e..da913619d432 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: machinesets.cluster.x-k8s.io spec: group: cluster.x-k8s.io diff --git a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml index f05f04474d99..a1cec945d516 100644 --- a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml +++ b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: ipaddressclaims.ipam.cluster.x-k8s.io spec: group: ipam.cluster.x-k8s.io diff --git a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml index b25fee0ab11e..e47c1a47863e 100644 --- a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml +++ b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: ipaddresses.ipam.cluster.x-k8s.io spec: group: ipam.cluster.x-k8s.io diff --git a/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml b/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml index b66fbce4ac04..3501bb605112 100644 --- a/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml +++ b/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: extensionconfigs.runtime.cluster.x-k8s.io spec: group: runtime.cluster.x-k8s.io diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index f48a8c6a3a98..c9e3c0658a43 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -4,6 +4,23 @@ kind: ClusterRole metadata: name: manager-role rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - patch + - update + - watch +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch - apiGroups: - "" resources: @@ -12,6 +29,18 @@ rules: - get - list - watch +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - addons.cluster.x-k8s.io resources: @@ -89,35 +118,6 @@ rules: - patch - update - watch -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch -- apiGroups: - - "" - resources: - - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - ipam.cluster.x-k8s.io resources: diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index cb4668d56d03..0b7340ac3fcb 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: kubeadmcontrolplanes.controlplane.cluster.x-k8s.io spec: group: controlplane.cluster.x-k8s.io diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml index 8ce2a88e96f5..f4d74c905d82 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: kubeadmcontrolplanetemplates.controlplane.cluster.x-k8s.io spec: group: controlplane.cluster.x-k8s.io diff --git a/controlplane/kubeadm/config/rbac/role.yaml b/controlplane/kubeadm/config/rbac/role.yaml index ef8f27924a74..140e8640ed8a 100644 --- a/controlplane/kubeadm/config/rbac/role.yaml +++ b/controlplane/kubeadm/config/rbac/role.yaml @@ -4,6 +4,24 @@ kind: ClusterRole metadata: name: manager-role rules: +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - secrets + verbs: + - create + - get + - list + - patch + - update + - watch - apiGroups: - apiextensions.k8s.io resources: @@ -61,21 +79,3 @@ rules: - patch - update - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch -- apiGroups: - - "" - resources: - - secrets - verbs: - - create - - get - - list - - patch - - update - - watch diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml index 944eaeff6ef6..16cd4f5c1395 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockerclusters.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclustertemplates.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclustertemplates.yaml index b38829d1038b..f28ace5cd6cc 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclustertemplates.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockerclustertemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockerclustertemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml index 93d21b8b10af..392c53326575 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepools.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockermachinepools.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepooltemplates.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepooltemplates.yaml index dc3b18a4050a..98b22534a9eb 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepooltemplates.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinepooltemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockermachinepooltemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml index 8c7378d0f573..64520ab6240e 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachines.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockermachines.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml index 8a5431476f18..f6ff92426f08 100644 --- a/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml +++ b/test/infrastructure/docker/config/crd/bases/infrastructure.cluster.x-k8s.io_dockermachinetemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: dockermachinetemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclusters.yaml b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclusters.yaml index c2f5b343d221..90af945bc7e7 100644 --- a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclusters.yaml +++ b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: inmemoryclusters.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclustertemplates.yaml b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclustertemplates.yaml index 144333f6b43a..fd059bc59074 100644 --- a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclustertemplates.yaml +++ b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemoryclustertemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: inmemoryclustertemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachines.yaml b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachines.yaml index 10ac09a960fe..163354561dd1 100644 --- a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachines.yaml +++ b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachines.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: inmemorymachines.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io diff --git a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachinetemplates.yaml b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachinetemplates.yaml index b87651396a77..bb9bb8888bef 100644 --- a/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachinetemplates.yaml +++ b/test/infrastructure/inmemory/config/crd/bases/infrastructure.cluster.x-k8s.io_inmemorymachinetemplates.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.1 + controller-gen.kubebuilder.io/version: v0.0.0-00010101000000-000000000000 name: inmemorymachinetemplates.infrastructure.cluster.x-k8s.io spec: group: infrastructure.cluster.x-k8s.io From 4e61080e1cff2fac8c77afbb9740ca4b72bd66d8 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Fri, 30 Aug 2024 12:26:03 +0200 Subject: [PATCH 7/7] metrics: regenerate --- config/metrics/metrics.yaml | 31 ++++++++++++++++--------------- config/metrics/rbac.yaml | 22 +++++++++++----------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/config/metrics/metrics.yaml b/config/metrics/metrics.yaml index 391aa77a1663..50ed111216ae 100644 --- a/config/metrics/metrics.yaml +++ b/config/metrics/metrics.yaml @@ -1,3 +1,7 @@ +# Generated by controller-gen version v0.0.0-00010101000000-000000000000 +# Generated based on types for kube-state-metrics v2.13.0 +--- +kind: CustomResourceStateMetrics spec: resources: - errorLogV: 0 @@ -525,14 +529,12 @@ spec: info: labelsFromPath: node_name: - - status - - nodeRef - name node_uid: - - status - - nodeRef - uid - path: null + path: + - status + - nodeRef type: Info help: Information about the node reference of a machine. name: status_noderef @@ -845,9 +847,9 @@ spec: - each: info: labelsFromPath: - name: - - metadata - - name + maxUnhealthy: + - spec + - maxUnhealthy path: null type: Info help: Information about a machinehealthcheck. @@ -905,7 +907,7 @@ spec: name: status_condition_last_transition_time - each: gauge: - nilIsZero: false + nilIsZero: true path: - status - currentHealthy @@ -915,17 +917,17 @@ spec: name: status_current_healthy - each: gauge: - nilIsZero: false + nilIsZero: true path: - status - expectedMachines valueFrom: null type: Gauge - help: Total number of pods counted by this machinehealthcheck. + help: Total number of machines counted by this machinehealthcheck. name: status_expected_machines - each: gauge: - nilIsZero: false + nilIsZero: true path: - status - remediationsAllowed @@ -1017,7 +1019,7 @@ spec: - version path: null type: Info - help: "" + help: Information about a machinepool. name: info - each: info: @@ -1300,7 +1302,7 @@ spec: name: status_replicas_available - each: gauge: - nilIsZero: false + nilIsZero: true path: - status - fullyLabeledReplicas @@ -1488,4 +1490,3 @@ spec: help: The number of updated replicas per kubeadmcontrolplane. name: status_replicas_updated resourcePlural: "" - diff --git a/config/metrics/rbac.yaml b/config/metrics/rbac.yaml index bcd5bde16ba3..bed50b0a70a0 100644 --- a/config/metrics/rbac.yaml +++ b/config/metrics/rbac.yaml @@ -2,20 +2,28 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: kube-state-metrics-custom-resource-capi labels: kube-state-metrics/aggregate-to-manager: "true" + name: manager-metrics-role rules: +- apiGroups: + - bootstrap.cluster.x-k8s.io + resources: + - kubeadmconfigs + verbs: + - get + - list + - watch - apiGroups: - cluster.x-k8s.io resources: - clusterclasses - clusters - machinedeployments + - machinehealthchecks - machinepools - - machinesets - machines - - machinehealthchecks + - machinesets verbs: - get - list @@ -28,11 +36,3 @@ rules: - get - list - watch -- apiGroups: - - bootstrap.cluster.x-k8s.io - resources: - - kubeadmconfigs - verbs: - - get - - list - - watch