@@ -67,8 +67,10 @@ difficult with current solutions.
67
67
68
68
### OperatorPolicy Syntax
69
69
70
+ Note: See Implementation Details for the previous ` v1beta1 ` version.
71
+
70
72
``` yaml
71
- apiVersion : policy.open-cluster-management.io/v1beta1
73
+ apiVersion : policy.open-cluster-management.io/v1beta2
72
74
kind : OperatorPolicy
73
75
metadata :
74
76
name : my-operator
@@ -141,7 +143,7 @@ fields based on specified defaults in the operator's PackageManifest. For exampl
141
143
default channel to possibly be different on different clusters, reflecting the default channel in
142
144
each cluster's catalog. It is not allowed to set `spec.subscription.installPlanApproval`; the policy
143
145
will determine and set a value for that field based on the policy's `spec.versions` and
144
- ` spec.updgradeApproval ` settings.
146
+ ` spec.upgradeApproval ` settings.
145
147
146
148
In "musthave" mode, the `spec.versions` list specifies what installed versions are considered
147
149
Compliant when the policy is in `inform` mode, and which InstallPlans can be approved when in
@@ -154,14 +156,13 @@ The `spec.upgradeApproval` field specifies whether an enforced "musthave" policy
154
156
upgrade InstallPlans for the operator. *It has no effect when the policy is in "mustnothave" mode*.
155
157
This only affects InstallPlans for operators that are already installed on the cluster,
156
158
which upgrade or replace the operator; initial InstallPlans for an operator can be approved
157
- regardless of this flag. Allowed values here include `Automatic` and `None`. If not set, the
158
- controller will behave as if it were set to `Automatic`.
159
+ regardless of this flag. Allowed values here include `Automatic` and `None`.
159
160
160
- Only when the policy is operating as if `spec.upgradeApproval` was set to `Automatic`, and the
161
- ` spec.versions ` field is empty (allowing all versions of the operator) will the subscription
162
- managed by this policy have its `installPlanApproval` field set to `Automatic`. Otherwise, the field
163
- will be set to `Manual`, but it should be noted that this controller will approve InstallPlans
164
- matching the desired versions automatically.
161
+ Only when the policy's `spec.upgradeApproval` is set to `Automatic`, and the `spec.versions` field
162
+ is empty (allowing all versions of the operator) will the subscription managed by this policy have
163
+ its `installPlanApproval` field set to `Automatic`. Otherwise, the field will be set to `Manual`,
164
+ but it should be noted that this controller will approve InstallPlans matching the desired versions
165
+ automatically.
165
166
166
167
The `spec.removalBehavior` field allows configuration of what might be removed by the controller
167
168
when the policy is in "mustnothave" mode. *It has no effect when the policy is in "musthave" mode.*
@@ -332,7 +333,7 @@ complete and all of Deployments listed in the operator's CSV are healthy.
332
333
333
334
Example yaml to apply (not including the Placement) :
334
335
` ` ` yaml
335
- apiVersion: policy.open-cluster-management.io/v1beta1
336
+ apiVersion: policy.open-cluster-management.io/v1beta2
336
337
kind: OperatorPolicy
337
338
metadata:
338
339
name: strimzi-policy
@@ -344,10 +345,10 @@ spec:
344
345
channel: stable
345
346
name: strimzi-kafka-operator
346
347
namespace: openshift-operators
347
- installPlanApproval: Manual
348
348
source: community-operators
349
349
sourceNamespace: openshift-marketplace
350
350
startingCSV: strimzi-cluster-operator.v0.35.0
351
+ upgradeApproval: None
351
352
versions:
352
353
- strimzi-cluster-operator.v0.35.0
353
354
` ` `
@@ -361,7 +362,7 @@ progress to that version.
361
362
362
363
For example, to upgrade the operator, the policy from story 1 could be updated to match this :
363
364
` ` ` yaml
364
- apiVersion: policy.open-cluster-management.io/v1beta1
365
+ apiVersion: policy.open-cluster-management.io/v1beta2
365
366
kind: OperatorPolicy
366
367
metadata:
367
368
name: strimzi-policy
@@ -373,10 +374,10 @@ spec:
373
374
channel: stable
374
375
name: strimzi-kafka-operator
375
376
namespace: openshift-operators
376
- installPlanApproval: Manual
377
377
source: community-operators
378
378
sourceNamespace: openshift-marketplace
379
379
startingCSV: strimzi-cluster-operator.v0.35.0
380
+ upgradeApproval: Automatic
380
381
versions:
381
382
- strimzi-cluster-operator.v0.35.0
382
383
- strimzi-cluster-operator.v0.35.1
@@ -389,7 +390,7 @@ available. The policy status should clearly indicate what new version is availab
389
390
390
391
The policy yaml would look like this, including some relevant fields from the status :
391
392
` ` ` yaml
392
- apiVersion: policy.open-cluster-management.io/v1beta1
393
+ apiVersion: policy.open-cluster-management.io/v1beta2
393
394
kind: OperatorPolicy
394
395
metadata:
395
396
name: strimzi-policy
@@ -401,10 +402,10 @@ spec:
401
402
channel: stable
402
403
name: strimzi-kafka-operator
403
404
namespace: openshift-operators
404
- installPlanApproval: Manual
405
405
source: community-operators
406
406
sourceNamespace: openshift-marketplace
407
407
startingCSV: strimzi-cluster-operator.v0.35.0
408
+ upgradeApproval: None
408
409
versions:
409
410
- strimzi-cluster-operator.v0.35.0
410
411
statusConfig:
@@ -442,7 +443,7 @@ the operator is in the process of being upgraded (basically, whenever something
442
443
the performance of the operator).
443
444
444
445
` ` ` yaml
445
- apiVersion: policy.open-cluster-management.io/v1beta1
446
+ apiVersion: policy.open-cluster-management.io/v1beta2
446
447
kind: OperatorPolicy
447
448
metadata:
448
449
name: strimzi-policy
@@ -454,9 +455,9 @@ spec:
454
455
channel: stable
455
456
name: strimzi-kafka-operator
456
457
namespace: openshift-operators
457
- installPlanApproval: Automatic
458
458
source: community-operators
459
459
sourceNamespace: openshift-marketplace
460
+ upgradeApproval: Automatic
460
461
statusConfig:
461
462
catalogSourceUnhealthy: NonCompliant
462
463
deploymentsUnavailable: NonCompliant
@@ -474,7 +475,7 @@ As a policy user, I want to install an operator to a specific namespace via a po
474
475
should become Compliant when the operator Deployments are fully available.
475
476
476
477
` ` ` yaml
477
- apiVersion: policy.open-cluster-management.io/v1beta1
478
+ apiVersion: policy.open-cluster-management.io/v1beta2
478
479
kind: OperatorPolicy
479
480
metadata:
480
481
name: strimzi-policy
@@ -492,9 +493,9 @@ spec:
492
493
channel: stable
493
494
name: strimzi-kafka-operator
494
495
namespace: strimzi-app-one
495
- installPlanApproval: Automatic
496
496
source: community-operators
497
497
sourceNamespace: openshift-marketplace
498
+ upgradeApproval: Automatic
498
499
` ` `
499
500
500
501
# ### Story 6
@@ -503,7 +504,7 @@ As a policy user, I want to ensure a certain operator is not on the cluster. Whe
503
504
should be deleted based on what I specify in `spec.removalBehavior`.
504
505
505
506
` ` ` yaml
506
- apiVersion: policy.open-cluster-management.io/v1beta1
507
+ apiVersion: policy.open-cluster-management.io/v1beta2
507
508
kind: OperatorPolicy
508
509
metadata:
509
510
name: strimzi-policy
@@ -515,9 +516,9 @@ spec:
515
516
channel: stable
516
517
name: strimzi-kafka-operator
517
518
namespace: strimzi-app-one
518
- installPlanApproval: Automatic
519
519
source: community-operators
520
520
sourceNamespace: openshift-marketplace
521
+ upgradeApproval: Automatic
521
522
removalBehavior:
522
523
operatorGroups: DeleteIfUnused
523
524
subscriptions: Delete
@@ -547,9 +548,9 @@ spec:
547
548
channel: stable
548
549
name: strimzi-kafka-operator
549
550
namespace: strimzi-app-one
550
- installPlanApproval: Automatic
551
551
source: community-operators
552
552
sourceNamespace: openshift-marketplace
553
+ upgradeApproval: Automatic
553
554
versions:
554
555
- "strimzi-cluster-operator.v0.35.0"
555
556
removalBehavior:
@@ -597,6 +598,67 @@ setting, then that InstallPlan will be approved. If an InstallPlan is created fo
597
598
installations, it will not be approved by this controller, and it might cause an OperatorPolicy to
598
599
become NonCompliant.
599
600
601
+ # ### v1beta1 and v1beta2 Differences and Conversions
602
+
603
+ For reference, the `v1beta1` implementation used :
604
+ ` ` ` yaml
605
+ apiVersion: policy.open-cluster-management.io/v1beta1
606
+ kind: OperatorPolicy
607
+ metadata:
608
+ name: my-operator
609
+ spec:
610
+ remediationAction: enforce # or inform
611
+ severity: medium
612
+ complianceType: musthave
613
+ operatorGroup: # optional
614
+ name: my-operator-group
615
+ namespace: own-namespace
616
+ target:
617
+ namespaces:
618
+ - foo
619
+ - bar
620
+ # selector: # One of selector or namespaces is allowed.
621
+ # matchLabels: # or matchExpressions
622
+ # mydomain.io/prod: "true"
623
+ serviceAccountName: my-og-account # optional
624
+ subscription:
625
+ config: {} # optional
626
+ channel: stable
627
+ name: my-operator
628
+ namespace: own-namespace
629
+ installPlanApproval: Automatic # or Manual, may be overridden by other settings.
630
+ source: my-catalog
631
+ sourceNamespace: my-catalog-namespace
632
+ startingCSV: my-operator.v0.1.0 # optional
633
+ versions:
634
+ - my-operator.v0.1.1
635
+ - my-operator.v0.2.0
636
+ ` ` `
637
+
638
+ An initial implementation of this kind used `v1beta1` and focused on installation and upgrade
639
+ scenarios. It *required* `spec.subscription.installPlanApproval` to be set to either `Automatic` or
640
+ ` Manual` , but that setting was believed to be confusing. When set to `Automatic`, the contoller
641
+ needed to override that setting in the Subscription in order to restrict the possible upgrades, and
642
+ approve any upgrades matching the `versions` specified in the policy. And when set to `Manual`, the
643
+ controller would still approve those upgrades without user input, ie "automatically".
644
+
645
+ The breaking change in the `v1beta2` design is to *forbid* the user from setting the
646
+ ` spec.subscription.installPlanApproval` field in the subscription, while providing a similar setting
647
+ via `spec.upgradeApproval`. The revised design provides more details on the interactions of this
648
+ setting and the other fields.
649
+
650
+ The controller will expose a conversion webhook so that either version of the resource can be used.
651
+ It will convert `installPlanApproval : Automatic` to `upgradeApproval: Automatic` and vice-versa, and
652
+ `installPlanApproval : Manual` to `upgradeApproval: None` and vice-versa. This is effectively a
653
+ change in behavior : as stated earlier, originally policies using `installPlanApproval: Manual` would
654
+ approve some upgrades, but now those policies will *not approve any upgrades*. Since the original
655
+ behavior was unclear in the design, and the new behavior results in fewer actions by the controller
656
+ (and therefore, fewer possible surprises for the user), we believe this change is acceptable.
657
+
658
+ The policy framework does not need to "know" about this change. Thanks to the conversion webhook,
659
+ it can apply whatever version is defined in the Policy : if that version is not registered on the
660
+ managed cluster, it would have a `template-error` caused by the API call failing.
661
+
600
662
# ## Risks and Mitigation
601
663
602
664
# ## Open Questions [optional]
0 commit comments