• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kubevirt / hyperconverged-cluster-operator / 22618055699

03 Mar 2026 10:06AM UTC coverage: 79.031%. First build
22618055699

Pull #4063

github

web-flow
Merge 46a578e49 into c24cc7c74
Pull Request #4063: CNV-78904: Add webhooks for v1 + conversion webhook

555 of 660 new or added lines in 7 files covered. (84.09%)

9294 of 11760 relevant lines covered (79.03%)

1.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.47
/pkg/components/components.go
1
package components
2

3
import (
4
        persesv1alpha1 "github.com/rhobs/perses-operator/api/v1alpha1"
5
        admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
6
        appsv1 "k8s.io/api/apps/v1"
7
        corev1 "k8s.io/api/core/v1"
8
        networkingv1 "k8s.io/api/networking/v1"
9
        rbacv1 "k8s.io/api/rbac/v1"
10
        "k8s.io/apimachinery/pkg/api/resource"
11
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
        "k8s.io/apimachinery/pkg/runtime"
13
        "k8s.io/apimachinery/pkg/util/intstr"
14
        "k8s.io/utils/ptr"
15

16
        cnaoapi "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1"
17
        kvapi "kubevirt.io/api/core"
18
        aaqapi "kubevirt.io/application-aware-quota/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core"
19
        cdiapi "kubevirt.io/containerized-data-importer-api/pkg/apis/core"
20
        migrationapi "kubevirt.io/kubevirt-migration-operator/api/v1alpha1"
21
        sspapi "kubevirt.io/ssp-operator/api/v1beta3"
22

23
        hcov1beta1 "github.com/kubevirt/hyperconverged-cluster-operator/api/v1beta1"
24
        "github.com/kubevirt/hyperconverged-cluster-operator/pkg/util"
25
)
26

27
const DisableOperandDeletionAnnotation = "console.openshift.io/disable-operand-delete"
28

29
const (
30
        crName = util.HyperConvergedName
31
)
32

33
type DeploymentOperatorParams struct {
34
        Namespace                string
35
        Image                    string
36
        WebhookImage             string
37
        CliDownloadsImage        string
38
        KVUIPluginImage          string
39
        KVUIProxyImage           string
40
        PasstImage               string
41
        PasstCNIImage            string
42
        WaspAgentImage           string
43
        ImagePullPolicy          string
44
        ConversionContainer      string
45
        VmwareContainer          string
46
        VirtIOWinContainer       string
47
        Smbios                   string
48
        Machinetype              string
49
        Amd64MachineType         string
50
        Arm64MachineType         string
51
        S390xMachineType         string
52
        HcoKvIoVersion           string
53
        KubevirtVersion          string
54
        KvVirtLancherOsVersion   string
55
        CdiVersion               string
56
        CnaoVersion              string
57
        SspVersion               string
58
        HppoVersion              string
59
        MtqVersion               string
60
        AaqVersion               string
61
        MigrationOperatorVersion string
62
        Env                      []corev1.EnvVar
63
        AddNetworkPolicyLabels   bool
64
}
65

66
func GetDeploymentSpecOperator(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
67
        envs := buildEnvVars(params)
×
68

×
69
        return appsv1.DeploymentSpec{
×
70
                Replicas: ptr.To[int32](1),
×
71
                Selector: &metav1.LabelSelector{
×
72
                        MatchLabels: map[string]string{
×
73
                                "name": util.HCOOperatorName,
×
74
                        },
×
75
                },
×
76
                Strategy: appsv1.DeploymentStrategy{
×
77
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
78
                },
×
79
                Template: corev1.PodTemplateSpec{
×
80
                        ObjectMeta: metav1.ObjectMeta{
×
81
                                Labels: getLabelsWithNetworkPolicies(util.HCOOperatorName, params),
×
82
                        },
×
83
                        Spec: corev1.PodSpec{
×
84
                                ServiceAccountName: util.HCOOperatorName,
×
85
                                SecurityContext:    GetStdPodSecurityContext(),
×
86
                                Containers: []corev1.Container{
×
87
                                        {
×
88
                                                Name:            util.HCOOperatorName,
×
89
                                                Image:           params.Image,
×
90
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
91
                                                Command:         stringListToSlice(util.HCOOperatorName),
×
92
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
93
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
94
                                                Env:             envs,
×
95
                                                Resources: corev1.ResourceRequirements{
×
96
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
97
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
98
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
99
                                                        },
×
100
                                                },
×
101
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
102
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
103
                                                Ports: []corev1.ContainerPort{
×
104
                                                        getMetricsPort(),
×
105
                                                },
×
106
                                        },
×
107
                                },
×
108
                                PriorityClassName: "system-cluster-critical",
×
109
                        },
×
110
                },
×
111
        }
×
112
}
×
113

114
func buildEnvVars(params *DeploymentOperatorParams) []corev1.EnvVar {
×
115
        envs := append([]corev1.EnvVar{
×
116
                {
×
117
                        // deprecated: left here for CI test.
×
118
                        Name:  util.OperatorWebhookModeEnv,
×
119
                        Value: "false",
×
120
                },
×
121
                {
×
122
                        Name:  util.ContainerAppName,
×
123
                        Value: util.ContainerOperatorApp,
×
124
                },
×
125
                {
×
126
                        Name:  "KVM_EMULATION",
×
127
                        Value: "",
×
128
                },
×
129
                {
×
130
                        Name:  "OPERATOR_IMAGE",
×
131
                        Value: params.Image,
×
132
                },
×
133
                {
×
134
                        Name:  "OPERATOR_NAME",
×
135
                        Value: util.HCOOperatorName,
×
136
                },
×
137
                {
×
138
                        Name:  "OPERATOR_NAMESPACE",
×
139
                        Value: params.Namespace,
×
140
                },
×
141
                {
×
142
                        Name: "POD_NAME",
×
143
                        ValueFrom: &corev1.EnvVarSource{
×
144
                                FieldRef: &corev1.ObjectFieldSelector{
×
145
                                        FieldPath: "metadata.name",
×
146
                                },
×
147
                        },
×
148
                },
×
149
                {
×
150
                        Name:  "VIRTIOWIN_CONTAINER",
×
151
                        Value: params.VirtIOWinContainer,
×
152
                },
×
153
                {
×
154
                        Name:  "SMBIOS",
×
155
                        Value: params.Smbios,
×
156
                },
×
157
                {
×
158
                        Name:  "MACHINETYPE",
×
159
                        Value: params.Machinetype,
×
160
                },
×
161
                {
×
162
                        Name:  "AMD64_MACHINETYPE",
×
163
                        Value: params.Amd64MachineType,
×
164
                },
×
165
                {
×
166
                        Name:  "ARM64_MACHINETYPE",
×
167
                        Value: params.Arm64MachineType,
×
168
                },
×
169
                {
×
170
                        Name:  "S390X_MACHINETYPE",
×
171
                        Value: params.S390xMachineType,
×
172
                },
×
173
                {
×
174
                        Name:  util.HcoKvIoVersionName,
×
175
                        Value: params.HcoKvIoVersion,
×
176
                },
×
177
                {
×
178
                        Name:  util.KubevirtVersionEnvV,
×
179
                        Value: params.KubevirtVersion,
×
180
                },
×
181
                {
×
182
                        Name:  util.CdiVersionEnvV,
×
183
                        Value: params.CdiVersion,
×
184
                },
×
185
                {
×
186
                        Name:  util.CnaoVersionEnvV,
×
187
                        Value: params.CnaoVersion,
×
188
                },
×
189
                {
×
190
                        Name:  util.SspVersionEnvV,
×
191
                        Value: params.SspVersion,
×
192
                },
×
193
                {
×
194
                        Name:  util.HppoVersionEnvV,
×
195
                        Value: params.HppoVersion,
×
196
                },
×
197
                {
×
198
                        Name:  util.AaqVersionEnvV,
×
199
                        Value: params.AaqVersion,
×
200
                },
×
201
                {
×
202
                        Name:  util.MigrationOperatorVersionEnvV,
×
203
                        Value: params.MigrationOperatorVersion,
×
204
                },
×
205
                {
×
206
                        Name:  util.KVUIPluginImageEnvV,
×
207
                        Value: params.KVUIPluginImage,
×
208
                },
×
209
                {
×
210
                        Name:  util.KVUIProxyImageEnvV,
×
211
                        Value: params.KVUIProxyImage,
×
212
                },
×
213
                {
×
214
                        Name:  util.PasstImageEnvV,
×
215
                        Value: params.PasstImage,
×
216
                },
×
217
                {
×
218
                        Name:  util.PasstCNIImageEnvV,
×
219
                        Value: params.PasstCNIImage,
×
220
                },
×
221
                {
×
222
                        Name:  util.WaspAgentImageEnvV,
×
223
                        Value: params.WaspAgentImage,
×
224
                },
×
225
        }, params.Env...)
×
226

×
227
        if params.KvVirtLancherOsVersion != "" {
×
228
                envs = append(envs, corev1.EnvVar{
×
229
                        Name:  util.KvVirtLauncherOSVersionEnvV,
×
230
                        Value: params.KvVirtLancherOsVersion,
×
231
                })
×
232
        }
×
233

234
        if params.AddNetworkPolicyLabels {
×
235
                envs = append(envs, corev1.EnvVar{
×
236
                        Name:  util.DeployNetworkPoliciesEnvV,
×
237
                        Value: "true",
×
238
                })
×
239
        }
×
240

241
        return envs
×
242
}
243

244
func GetDeploymentSpecCliDownloads(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
245
        return appsv1.DeploymentSpec{
×
246
                Replicas: ptr.To[int32](1),
×
247
                Selector: &metav1.LabelSelector{
×
248
                        MatchLabels: map[string]string{
×
249
                                "name": util.CLIDownloadsName,
×
250
                        },
×
251
                },
×
252
                Strategy: appsv1.DeploymentStrategy{
×
253
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
254
                },
×
255
                Template: corev1.PodTemplateSpec{
×
256
                        ObjectMeta: metav1.ObjectMeta{
×
257
                                Labels: GetLabels(util.CLIDownloadsName, params.HcoKvIoVersion),
×
258
                        },
×
259
                        Spec: corev1.PodSpec{
×
260
                                ServiceAccountName:           util.CLIDownloadsName,
×
261
                                AutomountServiceAccountToken: ptr.To(false),
×
262
                                SecurityContext:              GetStdPodSecurityContext(),
×
263
                                Containers: []corev1.Container{
×
264
                                        {
×
265
                                                Name:            "server",
×
266
                                                Image:           params.CliDownloadsImage,
×
267
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
268
                                                Resources: corev1.ResourceRequirements{
×
269
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
270
                                                                corev1.ResourceCPU:    resource.MustParse("10m"),
×
271
                                                                corev1.ResourceMemory: resource.MustParse("96Mi"),
×
272
                                                        },
×
273
                                                },
×
274
                                                Ports: []corev1.ContainerPort{
×
275
                                                        {
×
276
                                                                Protocol:      corev1.ProtocolTCP,
×
277
                                                                ContainerPort: util.CliDownloadsServerPort,
×
278
                                                        },
×
279
                                                },
×
280
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
281
                                                ReadinessProbe:           getReadinessProbe("/health", util.CliDownloadsServerPort),
×
282
                                                LivenessProbe:            getLivenessProbe("/health", util.CliDownloadsServerPort),
×
283
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
284
                                        },
×
285
                                },
×
286
                                PriorityClassName: "system-cluster-critical",
×
287
                        },
×
288
                },
×
289
        }
×
290
}
×
291

292
func GetLabels(name, hcoKvIoVersion string) map[string]string {
×
293
        return map[string]string{
×
294
                "name":                 name,
×
295
                util.AppLabelVersion:   hcoKvIoVersion,
×
296
                util.AppLabelPartOf:    util.HyperConvergedCluster,
×
297
                util.AppLabelComponent: string(util.AppComponentDeployment),
×
298
        }
×
299
}
×
300

301
func getLabelsWithNetworkPolicies(deploymentName string, params *DeploymentOperatorParams) map[string]string {
×
302
        labels := GetLabels(deploymentName, params.HcoKvIoVersion)
×
303
        if params.AddNetworkPolicyLabels {
×
304
                labels[util.AllowEgressToDNSAndAPIServerLabel] = "true"
×
305
                labels[util.AllowIngressToMetricsEndpointLabel] = "true"
×
306
        }
×
307

308
        return labels
×
309
}
310

311
func GetStdPodSecurityContext() *corev1.PodSecurityContext {
3✔
312
        return &corev1.PodSecurityContext{
3✔
313
                RunAsNonRoot: ptr.To(true),
3✔
314
                SeccompProfile: &corev1.SeccompProfile{
3✔
315
                        Type: corev1.SeccompProfileTypeRuntimeDefault,
3✔
316
                },
3✔
317
        }
3✔
318
}
3✔
319

320
func GetStdContainerSecurityContext() *corev1.SecurityContext {
3✔
321
        return &corev1.SecurityContext{
3✔
322
                AllowPrivilegeEscalation: ptr.To(false),
3✔
323
                Capabilities: &corev1.Capabilities{
3✔
324
                        Drop: []corev1.Capability{"ALL"},
3✔
325
                },
3✔
326
        }
3✔
327
}
3✔
328

329
// Currently we are abusing the pod readiness to signal to OLM that HCO is not ready
330
// for an upgrade. This has a lot of side effects, one of this is the validating webhook
331
// being not able to receive traffic when exposed by a pod that is not reporting ready=true.
332
// This can cause a lot of side effects if not deadlocks when the system reach a status where,
333
// for any possible reason, HCO pod cannot be ready and so HCO pod cannot validate any further update or
334
// delete request on HCO CR.
335
// A proper solution is properly use the readiness probe only to report the pod readiness and communicate
336
// status to OLM via conditions once OLM will be ready for:
337
// https://github.com/operator-framework/enhancements/blob/master/enhancements/operator-conditions.md
338
// in the meanwhile a quick (but dirty!) solution is to expose the same hco binary on two distinct pods:
339
// the first one will run only the controller and the second one (almost always ready) just the validating
340
// webhook one.
341
func GetDeploymentSpecWebhook(params *DeploymentOperatorParams) appsv1.DeploymentSpec {
×
342
        return appsv1.DeploymentSpec{
×
343
                Replicas: ptr.To[int32](1),
×
344
                Selector: &metav1.LabelSelector{
×
345
                        MatchLabels: map[string]string{
×
346
                                "name": util.HCOWebhookName,
×
347
                        },
×
348
                },
×
349
                Strategy: appsv1.DeploymentStrategy{
×
350
                        Type: appsv1.RollingUpdateDeploymentStrategyType,
×
351
                },
×
352
                Template: corev1.PodTemplateSpec{
×
353
                        ObjectMeta: metav1.ObjectMeta{
×
354
                                Labels: getLabelsWithNetworkPolicies(util.HCOWebhookName, params),
×
355
                        },
×
356
                        Spec: corev1.PodSpec{
×
357
                                ServiceAccountName: util.HCOOperatorName,
×
358
                                SecurityContext:    GetStdPodSecurityContext(),
×
359
                                Containers: []corev1.Container{
×
360
                                        {
×
361
                                                Name:            util.HCOWebhookName,
×
362
                                                Image:           params.WebhookImage,
×
363
                                                ImagePullPolicy: corev1.PullPolicy(params.ImagePullPolicy),
×
364
                                                Command:         stringListToSlice(util.HCOWebhookName),
×
365
                                                ReadinessProbe:  getReadinessProbe(util.ReadinessEndpointName, util.HealthProbePort),
×
366
                                                LivenessProbe:   getLivenessProbe(util.LivenessEndpointName, util.HealthProbePort),
×
367
                                                Env: append([]corev1.EnvVar{
×
368
                                                        {
×
369
                                                                // deprecated: left here for CI test.
×
370
                                                                Name:  util.OperatorWebhookModeEnv,
×
371
                                                                Value: "true",
×
372
                                                        },
×
373
                                                        {
×
374
                                                                Name:  util.ContainerAppName,
×
375
                                                                Value: util.ContainerWebhookApp,
×
376
                                                        },
×
377
                                                        {
×
378
                                                                Name:  "OPERATOR_IMAGE",
×
379
                                                                Value: params.WebhookImage,
×
380
                                                        },
×
381
                                                        {
×
382
                                                                Name:  "OPERATOR_NAME",
×
383
                                                                Value: util.HCOWebhookName,
×
384
                                                        },
×
385
                                                        {
×
386
                                                                Name:  "OPERATOR_NAMESPACE",
×
387
                                                                Value: params.Namespace,
×
388
                                                        },
×
389
                                                        {
×
390
                                                                Name: "POD_NAME",
×
391
                                                                ValueFrom: &corev1.EnvVarSource{
×
392
                                                                        FieldRef: &corev1.ObjectFieldSelector{
×
393
                                                                                FieldPath: "metadata.name",
×
394
                                                                        },
×
395
                                                                },
×
396
                                                        },
×
397
                                                        {
×
398
                                                                Name:  util.HcoKvIoVersionName,
×
399
                                                                Value: params.HcoKvIoVersion,
×
400
                                                        },
×
401
                                                }, params.Env...),
×
402
                                                Resources: corev1.ResourceRequirements{
×
403
                                                        Requests: map[corev1.ResourceName]resource.Quantity{
×
404
                                                                corev1.ResourceCPU:    resource.MustParse("5m"),
×
405
                                                                corev1.ResourceMemory: resource.MustParse("48Mi"),
×
406
                                                        },
×
407
                                                },
×
408
                                                SecurityContext:          GetStdContainerSecurityContext(),
×
409
                                                TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError,
×
410
                                                Ports: []corev1.ContainerPort{
×
411
                                                        getWebhookPort(),
×
412
                                                        getMetricsPort(),
×
413
                                                },
×
414
                                        },
×
415
                                },
×
416
                                PriorityClassName: "system-node-critical",
×
417
                        },
×
418
                },
×
419
        }
×
420
}
×
421

422
var (
423
        emptyAPIGroup = []string{""}
424
)
425

426
func GetClusterPermissions() []rbacv1.PolicyRule {
×
427
        const configOpenshiftIO = "config.openshift.io"
×
428
        const operatorOpenshiftIO = "operator.openshift.io"
×
429
        return []rbacv1.PolicyRule{
×
430
                {
×
431
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
432
                        Resources: stringListToSlice("hyperconvergeds"),
×
433
                        Verbs:     stringListToSlice("get", "list", "update", "watch"),
×
434
                },
×
435
                {
×
436
                        APIGroups: stringListToSlice(util.APIVersionGroup),
×
437
                        Resources: stringListToSlice("hyperconvergeds/finalizers", "hyperconvergeds/status"),
×
438
                        Verbs:     stringListToSlice("get", "list", "create", "update", "watch"),
×
439
                },
×
440
                roleWithAllPermissions(kvapi.GroupName, stringListToSlice("kubevirts", "kubevirts/finalizers")),
×
441
                roleWithAllPermissions(cdiapi.GroupName, stringListToSlice("cdis", "cdis/finalizers")),
×
442
                roleWithAllPermissions(sspapi.GroupVersion.Group, stringListToSlice("ssps", "ssps/finalizers")),
×
443
                roleWithAllPermissions(cnaoapi.GroupVersion.Group, stringListToSlice("networkaddonsconfigs", "networkaddonsconfigs/finalizers")),
×
444
                roleWithAllPermissions(aaqapi.GroupName, stringListToSlice("aaqs", "aaqs/finalizers")),
×
445
                roleWithAllPermissions(migrationapi.GroupVersion.Group, stringListToSlice("migcontrollers", "migcontrollers/finalizers")),
×
446
                roleWithAllPermissions("", stringListToSlice("configmaps")),
×
447
                {
×
448
                        APIGroups: emptyAPIGroup,
×
449
                        Resources: stringListToSlice("events"),
×
450
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "patch"),
×
451
                },
×
452
                roleWithAllPermissions("", stringListToSlice("services")),
×
453
                {
×
454
                        APIGroups: emptyAPIGroup,
×
455
                        Resources: stringListToSlice("pods", "nodes"),
×
456
                        Verbs:     stringListToSlice("get", "list", "watch", "patch"),
×
457
                },
×
458
                roleWithAllPermissions("", stringListToSlice("secrets")),
×
459
                {
×
460
                        APIGroups: emptyAPIGroup,
×
461
                        Resources: stringListToSlice("endpoints"),
×
462
                        Verbs:     stringListToSlice("get", "list", "delete", "watch"),
×
463
                },
×
464
                {
×
465
                        APIGroups: emptyAPIGroup,
×
466
                        Resources: stringListToSlice("namespaces"),
×
467
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
468
                },
×
469
                {
×
470
                        APIGroups: stringListToSlice("apps"),
×
471
                        Resources: stringListToSlice("deployments", "replicasets", "daemonsets"),
×
472
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
473
                },
×
474
                roleWithAllPermissions("rbac.authorization.k8s.io",
×
475
                        stringListToSlice("roles", "clusterroles", "rolebindings", "clusterrolebindings")),
×
476
                {
×
477
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
478
                        Resources: stringListToSlice("customresourcedefinitions"),
×
NEW
479
                        Verbs:     stringListToSlice("get", "list", "update", "patch", "watch", "delete"),
×
480
                },
×
481
                {
×
482
                        APIGroups: stringListToSlice("apiextensions.k8s.io"),
×
483
                        Resources: stringListToSlice("customresourcedefinitions/status", "customresourcedefinitions/finalizers"),
×
484
                        Verbs:     stringListToSlice("get", "list", "watch", "patch", "update"),
×
485
                },
×
486
                roleWithAllPermissions("monitoring.coreos.com", stringListToSlice("servicemonitors", "prometheusrules")),
×
487
                {
×
488
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
489
                        Resources: stringListToSlice("clusterserviceversions"),
×
490
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
491
                },
×
492
                {
×
493
                        APIGroups: stringListToSlice("scheduling.k8s.io"),
×
494
                        Resources: stringListToSlice("priorityclasses"),
×
495
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "delete", "patch"),
×
496
                },
×
497
                {
×
498
                        APIGroups: stringListToSlice("admissionregistration.k8s.io"),
×
499
                        Resources: stringListToSlice("validatingwebhookconfigurations"),
×
500
                        Verbs:     stringListToSlice("list", "watch", "update", "patch"),
×
501
                },
×
502
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleclidownloads", "consolequickstarts")),
×
503
                {
×
504
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
505
                        Resources: stringListToSlice("clusterversions", "infrastructures", "networks"),
×
506
                        Verbs:     stringListToSlice("get", "list"),
×
507
                },
×
508
                {
×
509
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
510
                        Resources: stringListToSlice("ingresses"),
×
511
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
512
                },
×
513
                {
×
514
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
515
                        Resources: stringListToSlice("ingresses/status"),
×
516
                        Verbs:     stringListToSlice("update"),
×
517
                },
×
518
                {
×
519
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
520
                        Resources: stringListToSlice("apiservers"),
×
521
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
522
                },
×
523
                {
×
524
                        APIGroups: stringListToSlice(operatorOpenshiftIO),
×
525
                        Resources: stringListToSlice("kubedeschedulers"),
×
526
                        Verbs:     stringListToSlice("get", "list", "watch"),
×
527
                },
×
528
                {
×
529
                        APIGroups: stringListToSlice(configOpenshiftIO),
×
530
                        Resources: stringListToSlice("dnses"),
×
531
                        Verbs:     stringListToSlice("get"),
×
532
                },
×
533
                roleWithAllPermissions("coordination.k8s.io", stringListToSlice("leases")),
×
534
                roleWithAllPermissions("route.openshift.io", stringListToSlice("routes")),
×
535
                {
×
536
                        APIGroups: stringListToSlice("route.openshift.io"),
×
537
                        Resources: stringListToSlice("routes/custom-host"),
×
538
                        Verbs:     stringListToSlice("create", "update", "patch"),
×
539
                },
×
540
                {
×
541
                        APIGroups: stringListToSlice("operators.coreos.com"),
×
542
                        Resources: stringListToSlice("operatorconditions"),
×
543
                        Verbs:     stringListToSlice("get", "list", "watch", "update", "patch"),
×
544
                },
×
545
                roleWithAllPermissions("image.openshift.io", stringListToSlice("imagestreams")),
×
546
                roleWithAllPermissions("console.openshift.io", stringListToSlice("consoleplugins")),
×
547
                {
×
548
                        APIGroups: stringListToSlice("operator.openshift.io"),
×
549
                        Resources: stringListToSlice("consoles"),
×
550
                        Verbs:     stringListToSlice("get", "list", "watch", "update"),
×
551
                },
×
552
                {
×
553
                        APIGroups: stringListToSlice("monitoring.coreos.com"),
×
554
                        Resources: stringListToSlice("alertmanagers", "alertmanagers/api"),
×
555
                        Verbs:     stringListToSlice("get", "list", "create", "delete"),
×
556
                },
×
557
                {
×
558
                        APIGroups: stringListToSlice(""),
×
559
                        Resources: stringListToSlice("serviceaccounts"),
×
560
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
561
                },
×
562
                {
×
563
                        APIGroups: stringListToSlice("k8s.cni.cncf.io"),
×
564
                        Resources: stringListToSlice("network-attachment-definitions"),
×
565
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
566
                },
×
567
                {
×
568
                        APIGroups: stringListToSlice("security.openshift.io"),
×
569
                        Resources: stringListToSlice("securitycontextconstraints"),
×
570
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
571
                },
×
572
                {
×
573
                        APIGroups: stringListToSlice(networkingv1.GroupName),
×
574
                        Resources: stringListToSlice("networkpolicies"),
×
575
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
576
                },
×
577
                {
×
578
                        APIGroups: stringListToSlice(admissionregistrationv1.GroupName),
×
579
                        Resources: stringListToSlice("validatingadmissionpolicies", "validatingadmissionpolicybindings"),
×
580
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
581
                },
×
582
                {
×
583
                        APIGroups: stringListToSlice(persesv1alpha1.GroupVersion.Group),
×
584
                        Resources: stringListToSlice("persesdashboards", "persesdatasources"),
×
585
                        Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete"),
×
586
                },
×
587
        }
×
588
}
×
589

590
func roleWithAllPermissions(apiGroup string, resources []string) rbacv1.PolicyRule {
×
591
        return rbacv1.PolicyRule{
×
592
                APIGroups: stringListToSlice(apiGroup),
×
593
                Resources: resources,
×
594
                Verbs:     stringListToSlice("get", "list", "watch", "create", "update", "delete", "patch"),
×
595
        }
×
596
}
×
597

598
func GetOperatorCR() *hcov1beta1.HyperConverged {
13✔
599
        defaultScheme := runtime.NewScheme()
13✔
600
        _ = hcov1beta1.AddToScheme(defaultScheme)
13✔
601
        _ = hcov1beta1.RegisterDefaults(defaultScheme)
13✔
602
        defaultHco := &hcov1beta1.HyperConverged{
13✔
603
                TypeMeta: metav1.TypeMeta{
13✔
604
                        APIVersion: util.APIVersion,
13✔
605
                        Kind:       util.HyperConvergedKind,
13✔
606
                },
13✔
607
                ObjectMeta: metav1.ObjectMeta{
13✔
608
                        Name: crName,
13✔
609
                }}
13✔
610
        defaultScheme.Default(defaultHco)
13✔
611
        return defaultHco
13✔
612
}
13✔
613

614
func getReadinessProbe(endpoint string, port int32) *corev1.Probe {
×
615
        return &corev1.Probe{
×
616
                ProbeHandler: corev1.ProbeHandler{
×
617
                        HTTPGet: &corev1.HTTPGetAction{
×
618
                                Path: endpoint,
×
619
                                Port: intstr.IntOrString{
×
620
                                        Type:   intstr.Int,
×
621
                                        IntVal: port,
×
622
                                },
×
623
                                Scheme: corev1.URISchemeHTTP,
×
624
                        },
×
625
                },
×
626
                InitialDelaySeconds: 5,
×
627
                PeriodSeconds:       5,
×
628
                FailureThreshold:    1,
×
629
        }
×
630
}
×
631

632
func getLivenessProbe(endpoint string, port int32) *corev1.Probe {
×
633
        return &corev1.Probe{
×
634
                ProbeHandler: corev1.ProbeHandler{
×
635
                        HTTPGet: &corev1.HTTPGetAction{
×
636
                                Path: endpoint,
×
637
                                Port: intstr.IntOrString{
×
638
                                        Type:   intstr.Int,
×
639
                                        IntVal: port,
×
640
                                },
×
641
                                Scheme: corev1.URISchemeHTTP,
×
642
                        },
×
643
                },
×
644
                InitialDelaySeconds: 30,
×
645
                PeriodSeconds:       5,
×
646
                FailureThreshold:    1,
×
647
        }
×
648
}
×
649

650
func getMetricsPort() corev1.ContainerPort {
×
651
        return corev1.ContainerPort{
×
652
                Name:          util.MetricsPortName,
×
653
                ContainerPort: util.MetricsPort,
×
654
                Protocol:      corev1.ProtocolTCP,
×
655
        }
×
656
}
×
657

658
func getWebhookPort() corev1.ContainerPort {
×
659
        return corev1.ContainerPort{
×
660
                Name:          util.WebhookPortName,
×
661
                ContainerPort: util.WebhookPort,
×
662
                Protocol:      corev1.ProtocolTCP,
×
663
        }
×
664
}
×
665

666
func stringListToSlice(words ...string) []string {
×
667
        return words
×
668
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc