Skip to content

Commit 87e8146

Browse files
Merge pull request #487 from paramite/ksm-new
Add kube-state-metrics for service monitoring
2 parents 35b81b2 + 6833aeb commit 87e8146

17 files changed

+1088
-167
lines changed

api/bases/telemetry.openstack.org_ceilometers.yaml

+78
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,70 @@ spec:
3030
object represents. Servers may infer this from the endpoint the client
3131
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
3232
type: string
33+
ksmStatus:
34+
description: KSMStatus defines the observed state of kube-state-metrics
35+
properties:
36+
conditions:
37+
description: Conditions
38+
items:
39+
description: Condition defines an observation of a API resource
40+
operational state.
41+
properties:
42+
lastTransitionTime:
43+
description: Last time the condition transitioned from one status
44+
to another. This should be when the underlying condition changed.
45+
If that is not known, then using the time when the API field
46+
changed is acceptable.
47+
format: date-time
48+
type: string
49+
message:
50+
description: A human readable message indicating details about
51+
the transition.
52+
type: string
53+
reason:
54+
description: The reason for the condition's last transition
55+
in CamelCase.
56+
type: string
57+
severity:
58+
description: Severity provides a classification of Reason code,
59+
so the current situation is immediately understandable and
60+
could act accordingly. It is meant for situations where Status=False
61+
and it should be indicated if it is just informational, warning
62+
(next reconciliation might fix it) or an error (e.g. DB create
63+
issue and no actions to automatically resolve the issue can/should
64+
be done). For conditions where Status=Unknown or Status=True
65+
the Severity should be SeverityNone.
66+
type: string
67+
status:
68+
description: Status of the condition, one of True, False, Unknown.
69+
type: string
70+
type:
71+
description: Type of condition in CamelCase.
72+
type: string
73+
required:
74+
- lastTransitionTime
75+
- status
76+
- type
77+
type: object
78+
type: array
79+
hash:
80+
additionalProperties:
81+
type: string
82+
description: Map of hashes to track e.g. job status
83+
type: object
84+
observedGeneration:
85+
description: ObservedGeneration - the most recent generation observed
86+
for this service. If the observed generation is less than the spec
87+
generation, then the controller has not processed the latest changes
88+
injected by the openstack-operator in the top-level CR (e.g. the
89+
ContainerImage)
90+
format: int64
91+
type: integer
92+
readyCount:
93+
description: ReadyCount of ksm instances
94+
format: int32
95+
type: integer
96+
type: object
3397
metadata:
3498
type: object
3599
spec:
@@ -57,6 +121,19 @@ spec:
57121
type: object
58122
ipmiImage:
59123
type: string
124+
ksmImage:
125+
type: string
126+
ksmTls:
127+
description: KSMTLS - Parameters related to the TLS for kube-state-metrics
128+
properties:
129+
caBundleSecretName:
130+
description: CaBundleSecretName - holding the CA certs in a pre-created
131+
bundle file
132+
type: string
133+
secretName:
134+
description: SecretName - holding the cert, key for the service
135+
type: string
136+
type: object
60137
networkAttachmentDefinitions:
61138
description: NetworkAttachmentDefinitions list of network attachment
62139
definitions the service pod gets attached to
@@ -116,6 +193,7 @@ spec:
116193
- centralImage
117194
- computeImage
118195
- ipmiImage
196+
- ksmImage
119197
- notificationImage
120198
- proxyImage
121199
- secret

api/bases/telemetry.openstack.org_telemetries.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,19 @@ spec:
439439
type: boolean
440440
ipmiImage:
441441
type: string
442+
ksmImage:
443+
type: string
444+
ksmTls:
445+
description: KSMTLS - Parameters related to the TLS for kube-state-metrics
446+
properties:
447+
caBundleSecretName:
448+
description: CaBundleSecretName - holding the CA certs in
449+
a pre-created bundle file
450+
type: string
451+
secretName:
452+
description: SecretName - holding the cert, key for the service
453+
type: string
454+
type: object
442455
networkAttachmentDefinitions:
443456
description: NetworkAttachmentDefinitions list of network attachment
444457
definitions the service pod gets attached to
@@ -498,6 +511,7 @@ spec:
498511
- centralImage
499512
- computeImage
500513
- ipmiImage
514+
- ksmImage
501515
- notificationImage
502516
- proxyImage
503517
- secret

api/v1beta1/ceilometer_types.go

+35-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222

23-
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2423
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
24+
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2525
)
2626

2727
const (
@@ -38,6 +38,8 @@ const (
3838
// CeilometerProxyContainerImage - default fall-back image for proxy container
3939
// CeilometerProxyContainerImage = "registry.redhat.io/ubi9/httpd-24:latest"
4040
CeilometerProxyContainerImage = "quay.io/podified-antelope-centos9/openstack-aodh-api:current-podified"
41+
// KubeStateMetricsImage - default fall-back image for KSM
42+
KubeStateMetricsImage = "registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.10.0"
4143
)
4244

4345
// CeilometerSpec defines the desired state of Ceilometer
@@ -62,6 +64,8 @@ type CeilometerSpec struct {
6264
// +kubebuilder:validation:Required
6365
ProxyImage string `json:"proxyImage"`
6466

67+
// +kubebuilder:validation:Required
68+
KSMImage string `json:"ksmImage"`
6569
}
6670

6771
// CeilometerSpecCore defines the desired state of Ceilometer. This version is used by the OpenStackControlplane (no image parameters)
@@ -103,6 +107,11 @@ type CeilometerSpecCore struct {
103107
// +operator-sdk:csv:customresourcedefinitions:type=spec
104108
// TLS - Parameters related to the TLS
105109
TLS tls.SimpleService `json:"tls,omitempty"`
110+
111+
// +kubebuilder:validation:Optional
112+
// +operator-sdk:csv:customresourcedefinitions:type=spec
113+
// KSMTLS - Parameters related to the TLS for kube-state-metrics
114+
KSMTLS tls.SimpleService `json:"ksmTls,omitempty"`
106115
}
107116

108117
// CeilometerStatus defines the observed state of Ceilometer
@@ -129,6 +138,24 @@ type CeilometerStatus struct {
129138
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
130139
}
131140

141+
// KSMStatus defines the observed state of kube-state-metrics
142+
type KSMStatus struct {
143+
// ReadyCount of ksm instances
144+
ReadyCount int32 `json:"readyCount,omitempty"`
145+
146+
// Map of hashes to track e.g. job status
147+
Hash map[string]string `json:"hash,omitempty"`
148+
149+
// Conditions
150+
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
151+
152+
// ObservedGeneration - the most recent generation observed for this
153+
// service. If the observed generation is less than the spec generation,
154+
// then the controller has not processed the latest changes injected by
155+
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
156+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
157+
}
158+
132159
//+kubebuilder:object:root=true
133160
//+kubebuilder:subresource:status
134161

@@ -137,8 +164,9 @@ type Ceilometer struct {
137164
metav1.TypeMeta `json:",inline"`
138165
metav1.ObjectMeta `json:"metadata,omitempty"`
139166

140-
Spec CeilometerSpec `json:"spec,omitempty"`
141-
Status CeilometerStatus `json:"status,omitempty"`
167+
Spec CeilometerSpec `json:"spec,omitempty"`
168+
CeilometerStatus CeilometerStatus `json:"status,omitempty"`
169+
KSMStatus KSMStatus `json:"ksmStatus,omitempty"`
142170
}
143171

144172
//+kubebuilder:object:root=true
@@ -152,7 +180,8 @@ type CeilometerList struct {
152180

153181
// IsReady - returns true if Ceilometer is reconciled successfully
154182
func (instance Ceilometer) IsReady() bool {
155-
return instance.Status.Conditions.IsTrue(condition.ReadyCondition)
183+
return instance.CeilometerStatus.Conditions.IsTrue(condition.ReadyCondition) &&
184+
instance.KSMStatus.Conditions.IsTrue(condition.ReadyCondition)
156185
}
157186

158187
func init() {
@@ -161,7 +190,7 @@ func init() {
161190

162191
// RbacConditionsSet - set the conditions for the rbac object
163192
func (instance Ceilometer) RbacConditionsSet(c *condition.Condition) {
164-
instance.Status.Conditions.Set(c)
193+
instance.CeilometerStatus.Conditions.Set(c)
165194
}
166195

167196
// RbacNamespace - return the namespace
@@ -184,6 +213,7 @@ func SetupDefaultsCeilometer() {
184213
ComputeContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_COMPUTE_IMAGE_URL_DEFAULT", CeilometerComputeContainerImage),
185214
IpmiContainerImageURL: util.GetEnvVar("RELATED_IMAGE_CEILOMETER_IPMI_IMAGE_URL_DEFAULT", CeilometerIpmiContainerImage),
186215
ProxyContainerImageURL: util.GetEnvVar("RELATED_IMAGE_APACHE_IMAGE_URL_DEFAULT", CeilometerProxyContainerImage),
216+
KSMContainerImageURL: util.GetEnvVar("RELATED_IMAGE_KSM_IMAGE_URL_DEFAULT", KubeStateMetricsImage),
187217
}
188218

189219
SetupCeilometerDefaults(ceilometerDefaults)

api/v1beta1/ceilometer_webhook.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type CeilometerDefaults struct {
3232
ComputeContainerImageURL string
3333
IpmiContainerImageURL string
3434
ProxyContainerImageURL string
35+
KSMContainerImageURL string
3536
}
3637

3738
var ceilometerDefaults CeilometerDefaults
@@ -85,6 +86,9 @@ func (spec *CeilometerSpec) Default() {
8586
if spec.ProxyImage == "" {
8687
spec.ProxyImage = ceilometerDefaults.ProxyContainerImageURL
8788
}
89+
if spec.KSMImage == "" {
90+
spec.KSMImage = ceilometerDefaults.KSMContainerImageURL
91+
}
8892
}
8993

9094
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.

api/v1beta1/conditions.go

+18
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const (
5555
DashboardDatasourceReadyCondition condition.Type = "DashboardDatasourceReady"
5656

5757
DashboardDefinitionReadyCondition condition.Type = "DashboardDefinitionReady"
58+
59+
// KSMReadyCondition Status=True condition which indicates if the KSM is configured and operational
60+
KSMReadyCondition condition.Type = "KSMReady"
5861
)
5962

6063
// Telemetry Reasons used by API objects.
@@ -189,4 +192,19 @@ const (
189192

190193
DashboardDefinitionReadyInitMessage = "Dashboard Definition not started"
191194
DashboardDefinitionFailedMessage = "Error occured when trying to install the dashboard definitions: %s"
195+
196+
//
197+
// KSMReady condition messages
198+
//
199+
// KSMReadyInitMessage
200+
KSMReadyInitMessage = "KSM not started"
201+
202+
// KSMReadyMessage
203+
KSMReadyMessage = "KSM completed"
204+
205+
// KSMReadyErrorMessage
206+
KSMReadyErrorMessage = "KSM error occured %s"
207+
208+
// KSMReadyRunningMessage
209+
KSMReadyRunningMessage = "KSM in progress"
192210
)

api/v1beta1/zz_generated.deepcopy.go

+32-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)