Skip to content

Commit

Permalink
Added Logging configuration to telemetry-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
jlarriba committed Nov 21, 2023
1 parent 5fdafd0 commit 48b3c37
Show file tree
Hide file tree
Showing 23 changed files with 1,250 additions and 20 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ resources:
kind: Autoscaling
path: github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: telemetry
kind: Logging
path: github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1
version: v1beta1
version: "3"
156 changes: 156 additions & 0 deletions api/bases/telemetry.openstack.org_loggings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: loggings.telemetry.openstack.org
spec:
group: telemetry.openstack.org
names:
kind: Logging
listKind: LoggingList
plural: loggings
singular: logging
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: Logging is the Schema for the loggings API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: LoggingSpec defines the desired state of Logging
properties:
cloNamespace:
default: openshift-logging
description: CLONamespace points to the namespace where the cluster-logging-operator
is deployed
type: string
ipaddr:
description: IPAddr is the address where the service will listen on
type: string
network:
description: The openstack network that will be used to connect computes
nodes
type: string
nodeSetName:
description: NodeSetName specifies the OpenStackDataPlaneNodeSet name
for the edpm nodes we want logging enabled
type: string
port:
default: 10514
description: Port is the port where the service will listen on
format: int32
type: integer
protocol:
default: TCP
description: 'The protocol of the connection the Service will listen
on: tcp or upd'
enum:
- TCP
- UDP
type: string
rsyslogPersistInterval:
default: 10
description: The number of seconds between sending log attempts
format: int32
type: integer
rsyslogQueueSize:
default: 10000
description: The size of the local queue of logs
format: int32
type: integer
rsyslogQueueType:
default: linkedList
description: The type of the local queue of logs
enum:
- fixedArray
- linkedList
- direct
- disk
type: string
rsyslogRetries:
default: 100
description: The number of retries rsyslog will attempt before abandoning
format: int32
type: integer
targetPort:
default: 10514
description: TargetPort is the port where the logging syslog receiver
is listening
type: integer
required:
- ipaddr
- network
type: object
status:
description: LoggingStatus defines the observed state of Logging
properties:
conditions:
description: Conditions
items:
description: Condition defines an observation of a API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase.
type: string
severity:
description: Severity provides a classification of Reason code,
so the current situation is immediately understandable and
could act accordingly. It is meant for situations where Status=False
and it should be indicated if it is just informational, warning
(next reconciliation might fix it) or an error (e.g. DB create
issue and no actions to automatically resolve the issue can/should
be done). For conditions where Status=Unknown or Status=True
the Severity should be SeverityNone.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
hash:
additionalProperties:
type: string
description: Map of hashes to track e.g. job status
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
8 changes: 4 additions & 4 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -49,13 +49,13 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
11 changes: 5 additions & 6 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd h1:r8yyd+DJDmsUhGrRBxH5Pj7KeFK5l+Y3FsgT8keqKtk=
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -189,7 +188,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand All @@ -214,8 +213,9 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
Expand All @@ -239,8 +239,7 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
131 changes: 131 additions & 0 deletions api/v1beta1/logging_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
Copyright 2022.
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.
*/

package v1beta1

import (
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// LoggingSpec defines the desired state of Logging
type LoggingSpec struct {

// The openstack network that will be used to connect computes nodes
// +kubebuilder:validation:Required
Network string `json:"network"`

// IPAddr is the address where the service will listen on
// +kubebuilder:validation:Required
IPAddr string `json:"ipaddr"`

// NodeSetName specifies the OpenStackDataPlaneNodeSet name for the edpm nodes we want logging enabled
// +kubebuilder:validation:Required
NodeSetName string `json:"nodeSetName,omitempty"`

// Port is the port where the service will listen on
// +kubebuilder:validation:Optional
// +kubebuilder:default=10514
Port int32 `json:"port,omitempty"`

// TargetPort is the port where the logging syslog receiver is listening
// +kubebuilder:validation:Optional
// +kubebuilder:default=10514
TargetPort int `json:"targetPort,omitempty"`

// The protocol of the connection the Service will listen on: tcp or upd
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=TCP;UDP
// +kubebuilder:default:=TCP
Protocol string `json:"protocol,omitempty"`

// CLONamespace points to the namespace where the cluster-logging-operator is deployed
// +kubebuilder:validation:Optional
// +kubebuilder:default=openshift-logging
CLONamespace string `json:"cloNamespace,omitempty"`

// The number of retries rsyslog will attempt before abandoning
// +kubebuilder:validation:Optional
// +kubebuilder:default=100
RsyslogRetries int32 `json:"rsyslogRetries,omitempty"`

// The type of the local queue of logs
// +kubebuilder:validation:Enum=fixedArray;linkedList;direct;disk
// +kubebuilder:default=linkedList
RsyslogQueueType string `json:"rsyslogQueueType,omitempty"`

// The size of the local queue of logs
// +kubebuilder:validation:Optional
// +kubebuilder:default=10000
RsyslogQueueSize int32 `json:"rsyslogQueueSize,omitempty"`

// The number of seconds between sending log attempts
// +kubebuilder:validation:Optional
// +kubebuilder:default=10
RsyslogPersistInterval int32 `json:"rsyslogPersistInterval,omitempty"`

}

// LoggingStatus defines the observed state of Logging
type LoggingStatus struct {
// Map of hashes to track e.g. job status
Hash map[string]string `json:"hash,omitempty"`

// Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Logging is the Schema for the loggings API
type Logging struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LoggingSpec `json:"spec,omitempty"`
Status LoggingStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// LoggingList contains a list of Logging
type LoggingList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Logging `json:"items"`
}

func init() {
SchemeBuilder.Register(&Logging{}, &LoggingList{})
}

// RbacConditionsSet - set the conditions for the rbac object
func (instance Logging) RbacConditionsSet(c *condition.Condition) {
instance.Status.Conditions.Set(c)
}

// RbacNamespace - return the namespace
func (instance Logging) RbacNamespace() string {
return instance.Namespace
}

// RbacResourceName - return the name to be used for rbac objects (serviceaccount, role, rolebinding)
func (instance Logging) RbacResourceName() string {
return "telemetry-" + instance.Name
}
Loading

0 comments on commit 48b3c37

Please sign in to comment.