-
Notifications
You must be signed in to change notification settings - Fork 539
/
Copy pathtypes_insights.go
152 lines (134 loc) · 8.37 KB
/
types_insights.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//
// InsightsDataGather provides data gather configuration options for the the Insights Operator.
//
// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=insightsdatagathers,scope=Cluster
// +kubebuilder:subresource:status
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/1245
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
// +openshift:enable:FeatureGate=InsightsConfig
// +openshift:compatibility-gen:level=4
type InsightsDataGather struct {
metav1.TypeMeta `json:",inline"`
// metadata is the standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// spec holds user settable values for configuration
// +required
Spec InsightsDataGatherSpec `json:"spec"`
// status holds observed values from the cluster. They may not be overridden.
// +optional
Status InsightsDataGatherStatus `json:"status"`
}
type InsightsDataGatherSpec struct {
// gatherConfig spec attribute includes all the configuration options related to gathering of the Insights data and its uploading to the ingress.
// +optional
GatherConfig GatherConfig `json:"gatherConfig,omitempty"`
}
type InsightsDataGatherStatus struct{}
// gatherConfig provides data gathering configuration options.
type GatherConfig struct {
// dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain in the Insights archive data.
// Valid values are "None" and "ObfuscateNetworking".
// When set to None the data is not obfuscated.
// When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated.
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
// +optional
DataPolicy DataPolicy `json:"dataPolicy,omitempty"`
// disabledGatherers is a list of gatherers to be excluded from the gathering. All the gatherers can be disabled by providing "all" value.
// If all the gatherers are disabled, the Insights operator does not gather any data.
// The format for the disabledGatherer should be: {gatherer}/{function} where the function is optional.
// Gatherer consists of a lowercase letters only that may include underscores (_).
// Function consists of a lowercase letters only that may include underscores (_) and is separated from the gatherer by a forward slash (/).
// The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md.
// Run the following command to get the names of last active gatherers:
// "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'"
// An example of disabling gatherers looks like this: `disabledGatherers: ["clusterconfig/machine_configs", "workloads/workload_info"]`
// +kubebuilder:validation:MaxItems=100
// +optional
DisabledGatherers []DisabledGatherer `json:"disabledGatherers"`
// storage is an optional field that allows user to define persistent storage for gathering jobs to store the Insights data archive.
// If omitted, the gathering job will use ephemeral storage.
// +optional
StorageSpec *Storage `json:"storage,omitempty"`
}
// disabledGatherer is a string that represents a gatherer that should be disabled
// +kubebuilder:validation:MaxLength=256
// +kubebuilder:validation:XValidation:rule=`self.matches("^[a-z]+[_a-z]*[a-z]([/a-z][_a-z]*)?[a-z]$")`,message=`disabledGatherer must be in the format of {gatherer}/{function} where the gatherer and function are lowercase letters only that may include underscores (_) and are separated by a forward slash (/) if the function is provided`
type DisabledGatherer string
// storage provides persistent storage configuration options for gathering jobs.
// If the type is set to PersistentVolume, then the PersistentVolume must be defined.
// If the type is set to Ephemeral, then the PersistentVolume must not be defined.
// +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'PersistentVolume' ? has(self.persistentVolume) : !has(self.persistentVolume)",message="persistentVolume is required when type is PersistentVolume, and forbidden otherwise"
type Storage struct {
// type is a required field that specifies the type of storage that will be used to store the Insights data archive.
// Valid values are "PersistentVolume" and "Ephemeral".
// When set to Ephemeral, the Insights data archive is stored in the ephemeral storage of the gathering job.
// When set to PersistentVolume, the Insights data archive is stored in the PersistentVolume that is defined by the persistentVolume field.
// +required
Type StorageType `json:"type"`
// persistentVolume is an optional field that specifies the PersistentVolume that will be used to store the Insights data archive.
// The PersistentVolume must be created in the openshift-insights namespace.
// +optional
PersistentVolume *PersistentVolumeConfig `json:"persistentVolume,omitempty"`
}
// storageType declares valid storage types
// +kubebuilder:validation:Enum=PersistentVolume;Ephemeral
type StorageType string
const (
// StorageTypePersistentVolume storage type
StorageTypePersistentVolume StorageType = "PersistentVolume"
// StorageTypeEphemeral storage type
StorageTypeEphemeral StorageType = "Ephemeral"
)
// persistentVolumeConfig provides configuration options for PersistentVolume storage.
type PersistentVolumeConfig struct {
// claim is a required field that specifies the configuration of the PersistentVolumeClaim that will be used to store the Insights data archive.
// The PersistentVolumeClaim must be created in the openshift-insights namespace.
// +required
Claim PersistentVolumeClaimReference `json:"claim"`
// mountPath is an optional field specifying the directory where the PVC will be mounted inside the Insights data gathering Pod.
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
// The current default mount path is /var/lib/insights-operator
// The path may not exceed 1024 characters and must not contain a colon.
// +kubebuilder:validation:MaxLength=1024
// +kubebuilder:validation:XValidation:rule="!self.contains(':')",message="mountPath must not contain a colon"
// +optional
MountPath string `json:"mountPath,omitempty"`
}
// persistentVolumeClaimReference is a reference to a PersistentVolumeClaim.
type PersistentVolumeClaimReference struct {
// name is a string that follows the DNS1123 subdomain format.
// It must be at most 253 characters in length, and must consist only of lower case alphanumeric characters, '-' and '.', and must start and end with an alphanumeric character.
// +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
// +kubebuilder:validation:MaxLength:=253
// +required
Name string `json:"name"`
}
const (
// No data obfuscation
NoPolicy DataPolicy = "None"
// IP addresses and cluster domain name are obfuscated
ObfuscateNetworking DataPolicy = "ObfuscateNetworking"
)
// dataPolicy declares valid data policy types
// +kubebuilder:validation:Enum="";None;ObfuscateNetworking
type DataPolicy string
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// InsightsDataGatherList is a collection of items
//
// Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support.
// +openshift:compatibility-gen:level=4
type InsightsDataGatherList struct {
metav1.TypeMeta `json:",inline"`
// metadata is the standard list's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ListMeta `json:"metadata"`
Items []InsightsDataGather `json:"items"`
}