-
Notifications
You must be signed in to change notification settings - Fork 20
/
razeedeployment_types.go
363 lines (323 loc) · 17.3 KB
/
razeedeployment_types.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// Copyright 2020 IBM Corp.
//
// 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 v1alpha1
import (
"github.com/redhat-marketplace/redhat-marketplace-operator/v2/apis/marketplace/common"
status "github.com/redhat-marketplace/redhat-marketplace-operator/v2/pkg/utils/status"
batch "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// Configuration values used by Razee to communicate with the Red Hat Marketplace backend
type RazeeConfigurationValues struct {
// Api key used to access the bucket IBM COS
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
IbmCosReaderKey *corev1.SecretKeySelector `json:"ibmCosReaderKey,omitempty"`
// BucketName is the name of the bucket in Cloud Object Storage and correlates to your accountID
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
BucketName string `json:"bucketName,omitempty"`
// Base url for the instance of IBM COS
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
IbmCosURL string `json:"ibmCosUrl,omitempty"`
// Key used to identify a particular razee instance
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
RazeeDashOrgKey *corev1.SecretKeySelector `json:"razeeDashOrgKey,omitempty"`
// The file name of the child RemoteResourecS3
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
ChildRSS3FIleName string `json:"childRRS3FileName,omitempty"`
// Url used by the razee install to post data
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
RazeeDashUrl string `json:"razeeDashUrl,omitempty"`
// FileSourceURL DEPRECATED: The url of the filesource arg that gets passed into the razeedeploy-job
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
FileSourceURL *string `json:"fileSourceUrl,omitempty"`
}
// RazeeDeploymentSpec defines the desired state of RazeeDeployment
// +k8s:openapi-gen=true
type RazeeDeploymentSpec struct {
// Enabled is the flag that controls if the controller does work. Setting
// enabled to true will create a Razee namespace and deploy it's components. Set to false to bypass Razee installation
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
Enabled bool `json:"enabled"`
// ClusterUUID is the cluster identifier, used for installing razee.
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
ClusterUUID string `json:"clusterUUID"`
// DeploySecretName is the name of our secret where Razee
// variables are stored.
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
DeploySecretName *string `json:"deploySecretName,omitempty"`
// TargetNamespace is configurable target of the razee namespace
// This is to support legancy installs. Please do not edit.
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
TargetNamespace *string `json:"targetNamespace,omitempty"`
// Configuration values provided from redhat marketplace
// These are used internally by the Operator
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
DeployConfig *RazeeConfigurationValues `json:"deployConfig,omitempty"`
// Location of your IBM Cloud Object Storage resources
// Used internally by the Operator
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
ChildUrl *string `json:"childUrl,omitempty"`
// Flag used by the RazeeDeployment Controller to decide whether to run legacy uninstall job
// Used internally by the Operator
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
LegacyUninstallHasRun *bool `json:"legacyUninstallHasRun,omitempty"`
// InstallIBMCatalogSource is the flag that indicates if the IBM Catalog Source is installed
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Install IBM Catalog Source?"
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
InstallIBMCatalogSource *bool `json:"installIBMCatalogSource,omitempty"`
// The features that can be enabled or disabled
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Features"
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="hidden"
Features *common.Features `json:"features,omitempty"`
// The ClusterDisplayName is a unique name of for a cluster specified by the admin during registration
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Features"
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="hidden"
ClusterDisplayName string `json:"clusterDisplayName,omitempty"`
}
// TODO: on version change, rename conditions to jobConditions
// TODO: on version change, rename installConditions to conditions
// RazeeDeploymentStatus defines the observed state of RazeeDeployment
// +k8s:openapi-gen=true
type RazeeDeploymentStatus struct {
// RazeeConditions represent the latest available observations of an object's stateonfig
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
Conditions status.Conditions `json:"installConditions,omitempty"`
// JobConditions DEPRECATED: represent the latest available observations of an object's stateonfig
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
JobConditions *batch.JobCondition `json:"conditions,omitempty"`
// JobState DEPRECATED: is the status of the Razee Install Job
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
JobState *batch.JobStatus `json:"jobState,omitempty"`
// MissingValuesFromSecret validates the secret provided has all the correct fields
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
MissingDeploySecretValues []string `json:"missingValuesFromSecret,omitempty"`
// RazeePrerequestesCreated is the list of configmaps and secrets required to be installed
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
RazeePrerequisitesCreated []string `json:"razeePrerequisitesCreated,omitempty"`
// LocalSecretVarsPopulated DEPRECATED: informs if the correct local variables are correct set.
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
LocalSecretVarsPopulated *bool `json:"localSecretVarsPopulated,omitempty"`
// RedHatMarketplaceSecretFound DEPRECATED: is the status of finding the secret in the cluster
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
RedHatMarketplaceSecretFound *bool `json:"redHatMarketplaceSecretFound,omitempty"`
// RazeeJobInstall contains information regarding the install job so it can be removed
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
RazeeJobInstall *RazeeJobInstallStruct `json:"razee_job_install,omitempty"`
// NodesFromRazeeDeployments contains the pods names created by the rhm-watch-keeper and rhm-remote-resources3-controller deployments
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
NodesFromRazeeDeployments []string `json:"nodesFromRazeeDeployments,omitempty"`
// NodesFromRazeeDeploymentsCount contains the pods names created by the rhm-watch-keeper and rhm-remote-resources3-controller deployments
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
// +optional
NodesFromRazeeDeploymentsCount int `json:"nodesFromRazeeDeploymentsCount,omitempty"`
}
type RazeeJobInstallStruct struct {
// RazeeNamespace is the namespace targeted for the Razee install
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
RazeeNamespace string `json:"razee_namespace"`
// RazeeInstallURL is the url used to install the Razee resources
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
RazeeInstallURL string `json:"razee_install_url"`
}
// +kubebuilder:object:root=true
// RazeeDeployment is the resources that deploys Razee for the Red Hat Marketplace.
// This is an internal resource not meant to be modified directly.
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=razeedeployments,scope=Namespaced
// +kubebuilder:printcolumn:name="INSTALLING",type=string,JSONPath=`.status.installConditions[?(@.type == "Installing")].status`
// +kubebuilder:printcolumn:name="STEP",type=string,JSONPath=`.status.installConditions[?(@.type == "Installing")].reason`
// +kubebuilder:printcolumn:name="APPS",type=integer,JSONPath=`.status.nodesFromRazeeDeploymentsCount`
// +operator-sdk:gen-csv:customresourcedefinitions.displayName="(Internal) Razee Deployment"
// +operator-sdk:gen-csv:customresourcedefinitions.resources=`Deployment,v1,"redhat-marketplace-operator"`
// +operator-sdk:gen-csv:customresourcedefinitions.resources=`ConfigMap,v1,"redhat-marketplace-operator"`
// +operator-sdk:gen-csv:customresourcedefinitions.resources=`Secret,v1,"redhat-marketplace-operator"`
type RazeeDeployment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RazeeDeploymentSpec `json:"spec,omitempty"`
Status RazeeDeploymentStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// RazeeDeploymentList contains a list of RazeeDeployment
type RazeeDeploymentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RazeeDeployment `json:"items"`
}
func init() {
SchemeBuilder.Register(&RazeeDeployment{}, &RazeeDeploymentList{})
}
// These are valid conditions of RazeeDeployment
const (
// Reasons for install
ReasonRazeeStartInstall status.ConditionReason = "StartRazeeInstall"
ReasonWatchKeeperNonNamespacedInstalled status.ConditionReason = "FinishedWatchKeeperNonNamespaceInstall"
ReasonWatchKeeperLimitPollInstalled status.ConditionReason = "FinishedWatchKeeperLimitPollInstall"
ReasonRazeeClusterMetaDataInstalled status.ConditionReason = "FinishedRazeeClusterMetaDataInstall"
ReasonWatchKeeperConfigInstalled status.ConditionReason = "FinishedWatchKeeperConfigInstall"
ReasonWatchKeeperSecretInstalled status.ConditionReason = "FinishedWatchKeeperSecretInstall"
ReasonCosReaderKeyInstalled status.ConditionReason = "FinishedCosReaderKeyInstall"
ReasonRazeeDeployJobStart status.ConditionReason = "StartRazeeDeployJob"
ReasonRazeeDeployJobFinished status.ConditionReason = "FinishedRazeeDeployJob"
ReasonParentRRS3Installed status.ConditionReason = "FinishParentRRS3Install"
ReasonChildRRS3Migrated status.ConditionReason = "ChildRRS3Migrated"
ReasonRazeeInstallFinished status.ConditionReason = "FinishedRazeeInstall"
ReasonWatchKeeperDeploymentStart status.ConditionReason = "StartWatchKeeperDeploymentInstall"
ReasonWatchKeeperDeploymentInstalled status.ConditionReason = "FinishedWatchKeeperDeploymentInstall"
ReasonRhmRemoteResourceDeploymentStart status.ConditionReason = "StartRemoteResourceDeploymentInstall"
ReasonRhmRemoteResourceDeploymentInstalled status.ConditionReason = "FinishedRemoteResourceDeploymentInstall"
ReasonRhmRemoteResourceDeploymentEnabled status.ConditionReason = "EnabledRemoteResourceDeploymentInstall"
ReasonRhmRegistrationWatchkeeperEnabled status.ConditionReason = "EnabledRegistrationWatchkeeperInstall"
)
var (
ConditionWatchKeeperNonNamespacedInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonWatchKeeperNonNamespacedInstalled,
Message: "watch-keeper-non-namespaced install finished",
}
ConditionWatchKeeperLimitPollInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonWatchKeeperLimitPollInstalled,
Message: "watch-keeper-limit-poll install finished",
}
ConditionRazeeClusterMetaDataInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonRazeeClusterMetaDataInstalled,
Message: "Razee cluster meta data install finished",
}
ConditionWatchKeeperConfigInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonWatchKeeperConfigInstalled,
Message: "watch-keeper-config install finished",
}
ConditionWatchKeeperSecretInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonWatchKeeperSecretInstalled,
Message: "watch-keeper-secret install finished",
}
ConditionCosReaderKeyInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonCosReaderKeyInstalled,
Message: "Cos-reader-key install finished",
}
ConditionRazeeInstallFinished = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionFalse,
Reason: ReasonRazeeInstallFinished,
Message: "Razee install complete",
}
ConditionRazeeInstallComplete = status.Condition{
Type: ConditionComplete,
Status: corev1.ConditionTrue,
Reason: ReasonRazeeInstallFinished,
Message: "Razee install complete",
}
ConditionRazeeNotEnabled = status.Condition{
Type: ConditionComplete,
Status: corev1.ConditionTrue,
Reason: ReasonRazeeInstallFinished,
Message: "Razee not enabled",
}
ConditionRazeeNameMismatch = status.Condition{
Type: ConditionComplete,
Status: corev1.ConditionTrue,
Reason: ReasonRazeeInstallFinished,
Message: "RazeeDeploy Resource name does not match expected",
}
ConditionRazeeStartInstall = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonRazeeStartInstall,
Message: "Razee Install starting",
}
ConditionResourceDeploymentDisabled = status.Condition{
Type: ConditionDeploymentEnabled,
Status: corev1.ConditionFalse,
Reason: ReasonRhmRemoteResourceDeploymentEnabled,
Message: "Deployment feature is disabled. RemoteResource deployment disabled. Operator deployment will be unavailable on marketplace.redhat.com",
}
ConditionRhmRegistrationWatchkeeperDisabled = status.Condition{
Type: ConditionRegistrationEnabled,
Status: corev1.ConditionFalse,
Reason: ReasonRhmRegistrationWatchkeeperEnabled,
Message: "Registration feature is disabled. WatchKeeper disabled. Registration status will be unavailable on marketplace.redhat.com",
}
ConditionRhmRemoteResourceDeploymentEnabled = status.Condition{
Type: ConditionDeploymentEnabled,
Status: corev1.ConditionTrue,
Reason: ReasonRhmRemoteResourceDeploymentEnabled,
Message: "RemoteResource deployment enabled",
}
ConditionRhmRegistrationWatchkeeperEnabled = status.Condition{
Type: ConditionRegistrationEnabled,
Status: corev1.ConditionTrue,
Reason: ReasonRhmRegistrationWatchkeeperEnabled,
Message: "Registration deployment enabled",
}
ConditionParentRRInstalled = status.Condition{
Type: ConditionInstalling,
Status: corev1.ConditionTrue,
Reason: ReasonParentRRS3Installed,
Message: "ParentRR install finished",
}
ConditionChildRRS3MigrationComplete = status.Condition{
Type: ConditionChildMigrationComplete,
Status: corev1.ConditionTrue,
Reason: ReasonChildRRS3Migrated,
Message: "Child RRS3 Migration successful",
}
)