Skip to content

Commit 33fd509

Browse files
committed
set all required markers
1 parent a5a6064 commit 33fd509

File tree

6 files changed

+97
-6
lines changed

6 files changed

+97
-6
lines changed

api/v1beta1/machine_types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ type MachineSpec struct {
142142
type MachineStatus struct {
143143
// NodeRef will point to the corresponding Node if it exists.
144144
// +optional
145+
// +Metrics:info:name="status_noderef",help="Information about the node reference of a machine.",labelsFromPath={node_name:{"name"},node_uid:{"uid"}}
145146
NodeRef *corev1.ObjectReference `json:"nodeRef,omitempty"`
146147

147148
// NodeInfo is a set of ids/uuids to uniquely identify the node.
@@ -194,11 +195,13 @@ type MachineStatus struct {
194195
// Addresses is a list of addresses assigned to the machine.
195196
// This field is copied from the infrastructure provider reference.
196197
// +optional
198+
// +Metrics:info:name="addresses",help="Address information about a machine.",labelsFromPath={address:{address},type:{type}}
197199
Addresses MachineAddresses `json:"addresses,omitempty"`
198200

199201
// Phase represents the current phase of machine actuation.
200202
// E.g. Pending, Running, Terminating, Failed etc.
201203
// +optional
204+
// +Metrics:stateset:name="status_phase",help="The machines current phase.",labelName="phase",list={"Pending","Provisioning","Provisioned","Running","Deleting","Deleted","Failed","Unknown"}
202205
Phase string `json:"phase,omitempty"`
203206

204207
// CertificatesExpiryDate is the expiry date of the machine certificates.
@@ -220,6 +223,7 @@ type MachineStatus struct {
220223

221224
// Conditions defines current service state of the Machine.
222225
// +optional
226+
// +Metrics:stateset:name="status_condition",help="The condition of a machine.",labelName="status",JSONPath={"status"},list={"True","False","Unknown"},labelsFromPath={"type":{"type"}}
223227
Conditions Conditions `json:"conditions,omitempty"`
224228
}
225229

@@ -279,8 +283,17 @@ type Bootstrap struct {
279283
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version",description="Kubernetes version associated with this Machine"
280284

281285
// Machine is the Schema for the machines API.
286+
// +Metrics:namePrefix="capi_machine"
287+
// +Metrics:labelFromPath:name="name",JSONPath={"metadata","name"}
288+
// +Metrics:labelFromPath:name="namespace",JSONPath={"metadata","namespace"}
289+
// +Metrics:labelFromPath:name="uid",JSONPath={"metadata","uid"}
290+
// +Metrics:labelFromPath:name="cluster_name",JSONPath={"spec","clusterName"}
291+
// +Metrics:info:name="info",help="Information about a machine.",labelsFromPath={container_runtime_version:{status,nodeInfo,containerRuntimeVersion},failure_domain:{spec,failureDomain},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}}
282292
type Machine struct {
283-
metav1.TypeMeta `json:",inline"`
293+
metav1.TypeMeta `json:",inline"`
294+
// +Metrics:gauge:name="created",JSONPath={"creationTimestamp"},help="Unix creation timestamp."
295+
// +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:{}}
296+
// +Metrics:info:name="owner",JSONPath={"ownerReferences"},help="Owner references.",labelsFromPath={owner_is_controller:{controller},owner_kind:{kind},owner_name:{name},owner_uid:{uid}}
284297
metav1.ObjectMeta `json:"metadata,omitempty"`
285298

286299
Spec MachineSpec `json:"spec,omitempty"`

api/v1beta1/machinedeployment_types.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type MachineDeploymentSpec struct {
9797
// * An existing MachineDeployment which initially wasn't controlled by the autoscaler
9898
// should be later controlled by the autoscaler
9999
// +optional
100+
// +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a machinedeployment."
100101
Replicas *int32 `json:"replicas,omitempty"`
101102

102103
// RolloutAfter is a field to indicate a rollout should be performed
@@ -134,6 +135,7 @@ type MachineDeploymentSpec struct {
134135

135136
// Indicates that the deployment is paused.
136137
// +optional
138+
// +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
137139
Paused bool `json:"paused,omitempty"`
138140

139141
// The maximum time in seconds for a deployment to make progress before it
@@ -183,6 +185,7 @@ type MachineRollingUpdateDeployment struct {
183185
// that the total number of machines available at all times
184186
// during the update is at least 70% of desired machines.
185187
// +optional
188+
// +Metrics:gauge:name="spec_strategy_rollingupdate_max_unavailable",help="Maximum number of unavailable replicas during a rolling update of a machinedeployment."
186189
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
187190

188191
// The maximum number of machines that can be scheduled above the
@@ -199,6 +202,7 @@ type MachineRollingUpdateDeployment struct {
199202
// be scaled up further, ensuring that total number of machines running
200203
// at any time during the update is at most 130% of desired machines.
201204
// +optional
205+
// +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."
202206
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
203207

204208
// DeletePolicy defines the policy used by the MachineDeployment to identify nodes to delete when downscaling.
@@ -228,20 +232,24 @@ type MachineDeploymentStatus struct {
228232
// Total number of non-terminated machines targeted by this deployment
229233
// (their labels match the selector).
230234
// +optional
235+
// +Metrics:gauge:name="status_replicas",help="The number of replicas per machinedeployment.",nilIsZero=true
231236
Replicas int32 `json:"replicas"`
232237

233238
// Total number of non-terminated machines targeted by this deployment
234239
// that have the desired template spec.
235240
// +optional
241+
// +Metrics:gauge:name="status_replicas_updated",help="The number of updated replicas per machinedeployment.",nilIsZero=true
236242
UpdatedReplicas int32 `json:"updatedReplicas"`
237243

238244
// Total number of ready machines targeted by this deployment.
239245
// +optional
246+
// +Metrics:gauge:name="status_ready_replicas",help="The number of ready replicas per machinedeployment.",nilIsZero=true
240247
ReadyReplicas int32 `json:"readyReplicas"`
241248

242249
// Total number of available machines (ready for at least minReadySeconds)
243250
// targeted by this deployment.
244251
// +optional
252+
// +Metrics:gauge:name="status_replicas_available",help="The number of available replicas per machinedeployment.",nilIsZero=true
245253
AvailableReplicas int32 `json:"availableReplicas"`
246254

247255
// Total number of unavailable machines targeted by this deployment.
@@ -250,14 +258,17 @@ type MachineDeploymentStatus struct {
250258
// be machines that are running but not yet available or machines
251259
// that still have not been created.
252260
// +optional
261+
// +Metrics:gauge:name="status_replicas_unavailable",help="The number of unavailable replicas per machinedeployment.",nilIsZero=true
253262
UnavailableReplicas int32 `json:"unavailableReplicas"`
254263

255264
// Phase represents the current phase of a MachineDeployment (ScalingUp, ScalingDown, Running, Failed, or Unknown).
256265
// +optional
266+
// +Metrics:stateset:name="status_phase",help="The machinedeployments current phase.",labelName="phase",list={"ScalingUp","ScalingDown","Running","Failed","Unknown"}
257267
Phase string `json:"phase,omitempty"`
258268

259269
// Conditions defines current service state of the MachineDeployment.
260270
// +optional
271+
// +Metrics:stateset:name="status_condition",help="The condition of a machinedeployment.",labelName="status",JSONPath={"status"},list={"True","False","Unknown"},labelsFromPath={"type":{"type"}}
261272
Conditions Conditions `json:"conditions,omitempty"`
262273
}
263274

@@ -319,8 +330,16 @@ func (md *MachineDeploymentStatus) GetTypedPhase() MachineDeploymentPhase {
319330
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineDeployment"
320331

321332
// MachineDeployment is the Schema for the machinedeployments API.
333+
// +Metrics:namePrefix="capi_machinedeployment"
334+
// +Metrics:labelFromPath:name="name",JSONPath={"metadata","name"}
335+
// +Metrics:labelFromPath:name="namespace",JSONPath={"metadata","namespace"}
336+
// +Metrics:labelFromPath:name="uid",JSONPath={"metadata","uid"}
337+
// +Metrics:labelFromPath:name="cluster_name",JSONPath={"spec","clusterName"}
322338
type MachineDeployment struct {
323-
metav1.TypeMeta `json:",inline"`
339+
metav1.TypeMeta `json:",inline"`
340+
// +Metrics:gauge:name="created",JSONPath={"creationTimestamp"},help="Unix creation timestamp."
341+
// +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:{}}
342+
// +Metrics:info:name="owner",JSONPath={"ownerReferences"},help="Owner references.",labelsFromPath={owner_is_controller:{controller},owner_kind:{kind},owner_name:{name},owner_uid:{uid}}
324343
metav1.ObjectMeta `json:"metadata,omitempty"`
325344

326345
Spec MachineDeploymentSpec `json:"spec,omitempty"`

api/v1beta1/machinehealthcheck_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,20 @@ type MachineHealthCheckStatus struct {
109109
// total number of machines counted by this machine health check
110110
// +kubebuilder:validation:Minimum=0
111111
// +optional
112+
// +Metrics:gauge:name="status_expected_machines",help="Total number of machines counted by this machinehealthcheck.",nilIsZero=true
112113
ExpectedMachines int32 `json:"expectedMachines"`
113114

114115
// total number of healthy machines counted by this machine health check
115116
// +kubebuilder:validation:Minimum=0
116117
// +optional
118+
// +Metrics:gauge:name="status_current_healthy",help="Current number of healthy machines.",nilIsZero=true
117119
CurrentHealthy int32 `json:"currentHealthy"`
118120

119121
// RemediationsAllowed is the number of further remediations allowed by this machine health check before
120122
// maxUnhealthy short circuiting will be applied
121123
// +kubebuilder:validation:Minimum=0
122124
// +optional
125+
// +Metrics:gauge:name="status_remediations_allowed",help="Number of machine remediations that are currently allowed.",nilIsZero=true
123126
RemediationsAllowed int32 `json:"remediationsAllowed"`
124127

125128
// ObservedGeneration is the latest generation observed by the controller.
@@ -132,6 +135,7 @@ type MachineHealthCheckStatus struct {
132135

133136
// Conditions defines current service state of the MachineHealthCheck.
134137
// +optional
138+
// +Metrics:stateset:name="status_condition",help="The condition of a machinehealthcheck.",labelName="status",JSONPath={"status"},list={"True","False","Unknown"},labelsFromPath={"type":{"type"}}
135139
Conditions Conditions `json:"conditions,omitempty"`
136140
}
137141

@@ -148,8 +152,16 @@ type MachineHealthCheckStatus struct {
148152
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of MachineHealthCheck"
149153

150154
// MachineHealthCheck is the Schema for the machinehealthchecks API.
155+
// +Metrics:namePrefix="capi_machinehealthcheck"
156+
// +Metrics:labelFromPath:name="name",JSONPath={"metadata","name"}
157+
// +Metrics:labelFromPath:name="namespace",JSONPath={"metadata","namespace"}
158+
// +Metrics:labelFromPath:name="uid",JSONPath={"metadata","uid"}
159+
// +Metrics:labelFromPath:name="cluster_name",JSONPath={"spec","clusterName"}
151160
type MachineHealthCheck struct {
152-
metav1.TypeMeta `json:",inline"`
161+
metav1.TypeMeta `json:",inline"`
162+
// +Metrics:gauge:name="created",JSONPath={"creationTimestamp"},help="Unix creation timestamp."
163+
// +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:{}}
164+
// +Metrics:info:name="owner",JSONPath={"ownerReferences"},help="Owner references.",labelsFromPath={owner_is_controller:{controller},owner_kind:{kind},owner_name:{name},owner_uid:{uid}}
153165
metav1.ObjectMeta `json:"metadata,omitempty"`
154166

155167
// Specification of machine health check policy

api/v1beta1/machineset_types.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type MachineSetSpec struct {
4444
// Defaults to 1.
4545
// +optional
4646
// +kubebuilder:default=1
47+
// +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a machineset.",nilIsZero=true
4748
Replicas *int32 `json:"replicas,omitempty"`
4849

4950
// MinReadySeconds is the minimum number of seconds for which a Node for a newly created machine should be ready before considering the replica available.
@@ -128,18 +129,22 @@ type MachineSetStatus struct {
128129

129130
// Replicas is the most recently observed number of replicas.
130131
// +optional
132+
// +Metrics:gauge:name="status_replicas",help="The number of replicas per machineset.",nilIsZero=true
131133
Replicas int32 `json:"replicas"`
132134

133135
// The number of replicas that have labels matching the labels of the machine template of the MachineSet.
134136
// +optional
137+
// +Metrics:gauge:name="status_fully_labeled_replicas",help="The number of fully labeled replicas per machineset.",nilIsZero=true
135138
FullyLabeledReplicas int32 `json:"fullyLabeledReplicas"`
136139

137140
// The number of ready replicas for this MachineSet. A machine is considered ready when the node has been created and is "Ready".
138141
// +optional
142+
// +Metrics:gauge:name="status_ready_replicas",help="The number of ready replicas per machineset.",nilIsZero=true
139143
ReadyReplicas int32 `json:"readyReplicas"`
140144

141145
// The number of available replicas (ready for at least minReadySeconds) for this MachineSet.
142146
// +optional
147+
// +Metrics:gauge:name="status_available_replicas",help="The number of available replicas per machineset.",nilIsZero=true
143148
AvailableReplicas int32 `json:"availableReplicas"`
144149

145150
// ObservedGeneration reflects the generation of the most recently observed MachineSet.
@@ -170,6 +175,7 @@ type MachineSetStatus struct {
170175
FailureMessage *string `json:"failureMessage,omitempty"`
171176
// Conditions defines current service state of the MachineSet.
172177
// +optional
178+
// +Metrics:stateset:name="status_condition",help="The condition of a machineset.",labelName="status",JSONPath={"status"},list={"True","False","Unknown"},labelsFromPath={"type":{"type"}}
173179
Conditions Conditions `json:"conditions,omitempty"`
174180
}
175181

@@ -212,8 +218,16 @@ func (m *MachineSet) Validate() field.ErrorList {
212218
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.template.spec.version",description="Kubernetes version associated with this MachineSet"
213219

214220
// MachineSet is the Schema for the machinesets API.
221+
// +Metrics:namePrefix="capi_machineset"
222+
// +Metrics:labelFromPath:name="name",JSONPath={"metadata","name"}
223+
// +Metrics:labelFromPath:name="namespace",JSONPath={"metadata","namespace"}
224+
// +Metrics:labelFromPath:name="uid",JSONPath={"metadata","uid"}
225+
// +Metrics:labelFromPath:name="cluster_name",JSONPath={"spec","clusterName"}
215226
type MachineSet struct {
216-
metav1.TypeMeta `json:",inline"`
227+
metav1.TypeMeta `json:",inline"`
228+
// +Metrics:gauge:name="created",JSONPath={"creationTimestamp"},help="Unix creation timestamp."
229+
// +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:{}}
230+
// +Metrics:info:name="owner",JSONPath={"ownerReferences"},help="Owner references.",labelsFromPath={owner_is_controller:{controller},owner_kind:{kind},owner_name:{name},owner_uid:{uid}}
217231
metav1.ObjectMeta `json:"metadata,omitempty"`
218232

219233
Spec MachineSetSpec `json:"spec,omitempty"`

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_types.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type KubeadmControlPlaneSpec struct {
7676
// odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members).
7777
// This is a pointer to distinguish between explicit zero and not specified.
7878
// +optional
79+
// +Metrics:gauge:name="spec_replicas",help="The number of desired machines for a kubeadmcontrolplane."
7980
Replicas *int32 `json:"replicas,omitempty"`
8081

8182
// Version defines the desired Kubernetes version.
@@ -181,6 +182,7 @@ type RollingUpdate struct {
181182
// Example: when this is set to 1, the control plane can be scaled
182183
// up immediately when the rolling update starts.
183184
// +optional
185+
// +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."
184186
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
185187
}
186188

@@ -241,6 +243,7 @@ type KubeadmControlPlaneStatus struct {
241243
// Total number of non-terminated machines targeted by this control plane
242244
// (their labels match the selector).
243245
// +optional
246+
// +Metrics:gauge:name="status_replicas",help="The number of replicas per kubeadmcontrolplane.",nilIsZero=true
244247
Replicas int32 `json:"replicas"`
245248

246249
// Version represents the minimum Kubernetes version for the control plane machines
@@ -251,10 +254,12 @@ type KubeadmControlPlaneStatus struct {
251254
// Total number of non-terminated machines targeted by this control plane
252255
// that have the desired template spec.
253256
// +optional
257+
// +Metrics:gauge:name="status_replicas_updated",help="The number of updated replicas per kubeadmcontrolplane.",nilIsZero=true
254258
UpdatedReplicas int32 `json:"updatedReplicas"`
255259

256260
// Total number of fully running and ready control plane machines.
257261
// +optional
262+
// +Metrics:gauge:name="status_ready_replicas",help="The number of ready replicas per kubeadmcontrolplane.",nilIsZero=true
258263
ReadyReplicas int32 `json:"readyReplicas"`
259264

260265
// Total number of unavailable machines targeted by this control plane.
@@ -263,6 +268,7 @@ type KubeadmControlPlaneStatus struct {
263268
// be machines that are running but not yet ready or machines
264269
// that still have not been created.
265270
// +optional
271+
// +Metrics:gauge:name="status_replicas_unavailable",help="The number of unavailable replicas per kubeadmcontrolplane.",nilIsZero=true
266272
UnavailableReplicas int32 `json:"unavailableReplicas"`
267273

268274
// Initialized denotes whether or not the control plane has the
@@ -292,6 +298,7 @@ type KubeadmControlPlaneStatus struct {
292298

293299
// Conditions defines current service state of the KubeadmControlPlane.
294300
// +optional
301+
// +Metrics:stateset:name="status_condition",help="The condition of a kubeadmcontrolplane.",labelName="status",JSONPath={"status"},list={"True","False","Unknown"},labelsFromPath={"type":{"type"}}
295302
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
296303

297304
// LastRemediation stores info about last remediation performed.
@@ -331,8 +338,18 @@ type LastRemediationStatus struct {
331338
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="Kubernetes version associated with this control plane"
332339

333340
// KubeadmControlPlane is the Schema for the KubeadmControlPlane API.
341+
// +Metrics:namePrefix="capi_kubeadmcontrolplane"
342+
// +Metrics:labelFromPath:name="name",JSONPath={"metadata","name"}
343+
// +Metrics:labelFromPath:name="cluster_name",JSONPath={metadata,ownerReferences,[kind=Cluster],name}
344+
// +Metrics:labelFromPath:name="name",JSONPath={metadata,name}
345+
// +Metrics:labelFromPath:name="namespace",JSONPath={metadata,namespace}
346+
// +Metrics:labelFromPath:name="uid",JSONPath={metadata,uid}
347+
// +Metrics:info:name="info",help="Information about a kubeadmcontrolplane.",labelsFromPath={version:{"spec","version"}}
334348
type KubeadmControlPlane struct {
335-
metav1.TypeMeta `json:",inline"`
349+
metav1.TypeMeta `json:",inline"`
350+
// +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:{}}
351+
// +Metrics:gauge:name="created",JSONPath={"creationTimestamp"},help="Unix creation timestamp."
352+
// +Metrics:info:name="owner",JSONPath={"ownerReferences"},help="Owner references.",labelsFromPath={owner_is_controller:{controller},owner_kind:{kind},owner_name:{name},owner_uid:{uid}}
336353
metav1.ObjectMeta `json:"metadata,omitempty"`
337354

338355
Spec KubeadmControlPlaneSpec `json:"spec,omitempty"`

0 commit comments

Comments
 (0)