1 package v1alpha1 2 3 import ( 4 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 5 ) 6 7 // +genclient 8 // +genclient:nonNamespaced 9 // +kubebuilder:resource:scope=Cluster 10 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 11 // 12 // DataGather provides data gather configuration options and status for the particular Insights data gathering. 13 // 14 // 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. 15 // +openshift:compatibility-gen:level=4 16 type DataGather struct { 17 metav1.TypeMeta `json:",inline"` 18 metav1.ObjectMeta `json:"metadata,omitempty"` 19 20 // spec holds user settable values for configuration 21 // +kubebuilder:validation:Required 22 Spec DataGatherSpec `json:"spec"` 23 // status holds observed values from the cluster. They may not be overridden. 24 // +optional 25 Status DataGatherStatus `json:"status"` 26 } 27 28 type DataGatherSpec struct { 29 // dataPolicy allows user to enable additional global obfuscation of the IP addresses and base domain 30 // in the Insights archive data. Valid values are "ClearText" and "ObfuscateNetworking". 31 // When set to ClearText the data is not obfuscated. 32 // When set to ObfuscateNetworking the IP addresses and the cluster domain name are obfuscated. 33 // When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time. 34 // The current default is ClearText. 35 // +optional 36 DataPolicy DataPolicy `json:"dataPolicy"` 37 // gatherers is a list of gatherers configurations. 38 // The particular gatherers IDs can be found at https://github.com/openshift/insights-operator/blob/master/docs/gathered-data.md. 39 // Run the following command to get the names of last active gatherers: 40 // "oc get insightsoperators.operator.openshift.io cluster -o json | jq '.status.gatherStatus.gatherers[].name'" 41 // +optional 42 Gatherers []GathererConfig `json:"gatherers"` 43 } 44 45 const ( 46 // No data obfuscation 47 NoPolicy DataPolicy = "ClearText" 48 // IP addresses and cluster domain name are obfuscated 49 ObfuscateNetworking DataPolicy = "ObfuscateNetworking" 50 // Data gathering is running 51 Running DataGatherState = "Running" 52 // Data gathering is completed 53 Completed DataGatherState = "Completed" 54 // Data gathering failed 55 Failed DataGatherState = "Failed" 56 // Data gathering is pending 57 Pending DataGatherState = "Pending" 58 // Gatherer state marked as disabled, which means that the gatherer will not run. 59 Disabled GathererState = "Disabled" 60 // Gatherer state marked as enabled, which means that the gatherer will run. 61 Enabled GathererState = "Enabled" 62 ) 63 64 // dataPolicy declares valid data policy types 65 // +kubebuilder:validation:Enum="";ClearText;ObfuscateNetworking 66 type DataPolicy string 67 68 // state declares valid gatherer state types. 69 // +kubebuilder:validation:Enum="";Enabled;Disabled 70 type GathererState string 71 72 // gathererConfig allows to configure specific gatherers 73 type GathererConfig struct { 74 // name is the name of specific gatherer 75 // +kubebuilder:validation:Required 76 Name string `json:"name"` 77 // state allows you to configure specific gatherer. Valid values are "Enabled", "Disabled" and omitted. 78 // When omitted, this means no opinion and the platform is left to choose a reasonable default. 79 // The current default is Enabled. 80 // +optional 81 State GathererState `json:"state"` 82 } 83 84 // dataGatherState declares valid gathering state types 85 // +kubebuilder:validation:Optional 86 // +kubebuilder:validation:Enum=Running;Completed;Failed;Pending 87 // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Running' && self == 'Pending')", message="dataGatherState cannot transition from Running to Pending" 88 // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Completed' && self == 'Pending')", message="dataGatherState cannot transition from Completed to Pending" 89 // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Failed' && self == 'Pending')", message="dataGatherState cannot transition from Failed to Pending" 90 // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Completed' && self == 'Running')", message="dataGatherState cannot transition from Completed to Running" 91 // +kubebuilder:validation:XValidation:rule="!(oldSelf == 'Failed' && self == 'Running')", message="dataGatherState cannot transition from Failed to Running" 92 type DataGatherState string 93 94 // +kubebuilder:validation:XValidation:rule="(!has(oldSelf.insightsRequestID) || has(self.insightsRequestID))",message="cannot remove insightsRequestID attribute from status" 95 // +kubebuilder:validation:XValidation:rule="(!has(oldSelf.startTime) || has(self.startTime))",message="cannot remove startTime attribute from status" 96 // +kubebuilder:validation:XValidation:rule="(!has(oldSelf.finishTime) || has(self.finishTime))",message="cannot remove finishTime attribute from status" 97 // +kubebuilder:validation:XValidation:rule="(!has(oldSelf.dataGatherState) || has(self.dataGatherState))",message="cannot remove dataGatherState attribute from status" 98 // +kubebuilder:validation:Optional 99 type DataGatherStatus struct { 100 // conditions provide details on the status of the gatherer job. 101 // +patchMergeKey=type 102 // +patchStrategy=merge 103 // +listType=map 104 // +listMapKey=type 105 // +optional 106 Conditions []metav1.Condition `json:"conditions" patchStrategy:"merge" patchMergeKey:"type"` 107 // dataGatherState reflects the current state of the data gathering process. 108 // +optional 109 State DataGatherState `json:"dataGatherState,omitempty"` 110 // gatherers is a list of active gatherers (and their statuses) in the last gathering. 111 // +listType=map 112 // +listMapKey=name 113 // +optional 114 Gatherers []GathererStatus `json:"gatherers,omitempty"` 115 // startTime is the time when Insights data gathering started. 116 // +kubebuilder:validation:Optional 117 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="startTime is immutable once set" 118 // +optional 119 StartTime metav1.Time `json:"startTime,omitempty"` 120 // finishTime is the time when Insights data gathering finished. 121 // +kubebuilder:validation:Optional 122 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="finishTime is immutable once set" 123 // +optional 124 FinishTime metav1.Time `json:"finishTime,omitempty"` 125 // relatedObjects is a list of resources which are useful when debugging or inspecting the data 126 // gathering Pod 127 // +optional 128 RelatedObjects []ObjectReference `json:"relatedObjects,omitempty"` 129 // insightsRequestID is an Insights request ID to track the status of the 130 // Insights analysis (in console.redhat.com processing pipeline) for the corresponding Insights data archive. 131 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="insightsRequestID is immutable once set" 132 // +kubebuilder:validation:Optional 133 // +optional 134 InsightsRequestID string `json:"insightsRequestID,omitempty"` 135 // insightsReport provides general Insights analysis results. 136 // When omitted, this means no data gathering has taken place yet or the 137 // corresponding Insights analysis (identified by "insightsRequestID") is not available. 138 // +optional 139 InsightsReport InsightsReport `json:"insightsReport,omitempty"` 140 } 141 142 // gathererStatus represents information about a particular 143 // data gatherer. 144 type GathererStatus struct { 145 // conditions provide details on the status of each gatherer. 146 // +patchMergeKey=type 147 // +patchStrategy=merge 148 // +listType=map 149 // +listMapKey=type 150 // +kubebuilder:validation:Required 151 // +kubebuilder:validation:MinItems=1 152 Conditions []metav1.Condition `json:"conditions" patchStrategy:"merge" patchMergeKey:"type"` 153 // name is the name of the gatherer. 154 // +kubebuilder:validation:Required 155 // +kubebuilder:validation:MaxLength=256 156 // +kubebuilder:validation:MinLength=5 157 Name string `json:"name"` 158 // lastGatherDuration represents the time spent gathering. 159 // +kubebuilder:validation:Required 160 // +kubebuilder:validation:Type=string 161 // +kubebuilder:validation:Pattern="^([1-9][0-9]*(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$" 162 LastGatherDuration metav1.Duration `json:"lastGatherDuration"` 163 } 164 165 // insightsReport provides Insights health check report based on the most 166 // recently sent Insights data. 167 type InsightsReport struct { 168 // downloadedAt is the time when the last Insights report was downloaded. 169 // An empty value means that there has not been any Insights report downloaded yet and 170 // it usually appears in disconnected clusters (or clusters when the Insights data gathering is disabled). 171 // +optional 172 DownloadedAt metav1.Time `json:"downloadedAt,omitempty"` 173 // healthChecks provides basic information about active Insights health checks 174 // in a cluster. 175 // +listType=atomic 176 // +optional 177 HealthChecks []HealthCheck `json:"healthChecks,omitempty"` 178 // uri provides the URL link from which the report was downloaded. 179 // +kubebuilder:validation:Pattern=`^https:\/\/\S+` 180 // +optional 181 URI string `json:"uri,omitempty"` 182 } 183 184 // healthCheck represents an Insights health check attributes. 185 type HealthCheck struct { 186 // description provides basic description of the healtcheck. 187 // +kubebuilder:validation:Required 188 // +kubebuilder:validation:MaxLength=2048 189 // +kubebuilder:validation:MinLength=10 190 Description string `json:"description"` 191 // totalRisk of the healthcheck. Indicator of the total risk posed 192 // by the detected issue; combination of impact and likelihood. The values can be from 1 to 4, 193 // and the higher the number, the more important the issue. 194 // +kubebuilder:validation:Required 195 // +kubebuilder:validation:Minimum=1 196 // +kubebuilder:validation:Maximum=4 197 TotalRisk int32 `json:"totalRisk"` 198 // advisorURI provides the URL link to the Insights Advisor. 199 // +kubebuilder:validation:Required 200 // +kubebuilder:validation:Pattern=`^https:\/\/\S+` 201 AdvisorURI string `json:"advisorURI"` 202 // state determines what the current state of the health check is. 203 // Health check is enabled by default and can be disabled 204 // by the user in the Insights advisor user interface. 205 // +kubebuilder:validation:Required 206 State HealthCheckState `json:"state"` 207 } 208 209 // healthCheckState provides information about the status of the 210 // health check (for example, the health check may be marked as disabled by the user). 211 // +kubebuilder:validation:Enum:=Enabled;Disabled 212 type HealthCheckState string 213 214 const ( 215 // enabled marks the health check as enabled 216 HealthCheckEnabled HealthCheckState = "Enabled" 217 // disabled marks the health check as disabled 218 HealthCheckDisabled HealthCheckState = "Disabled" 219 ) 220 221 // ObjectReference contains enough information to let you inspect or modify the referred object. 222 type ObjectReference struct { 223 // group is the API Group of the Resource. 224 // Enter empty string for the core group. 225 // This value should consist of only lowercase alphanumeric characters, hyphens and periods. 226 // Example: "", "apps", "build.openshift.io", etc. 227 // +kubebuilder:validation:Pattern:="^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$" 228 // +kubebuilder:validation:Required 229 Group string `json:"group"` 230 // resource is the type that is being referenced. 231 // It is normally the plural form of the resource kind in lowercase. 232 // This value should consist of only lowercase alphanumeric characters and hyphens. 233 // Example: "deployments", "deploymentconfigs", "pods", etc. 234 // +kubebuilder:validation:Required 235 // +kubebuilder:validation:Pattern:="^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" 236 Resource string `json:"resource"` 237 // name of the referent. 238 // +kubebuilder:validation:Required 239 Name string `json:"name"` 240 // namespace of the referent. 241 // +optional 242 Namespace string `json:"namespace,omitempty"` 243 } 244 245 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 246 247 // DataGatherList is a collection of items 248 // 249 // 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. 250 // +openshift:compatibility-gen:level=4 251 type DataGatherList struct { 252 metav1.TypeMeta `json:",inline"` 253 metav1.ListMeta `json:"metadata"` 254 Items []DataGather `json:"items"` 255 } 256