Skip to content

Commit a256cc0

Browse files
author
Arvind Thirumurugan
committed
handle both approval request objects
Signed-off-by: Arvind Thirumurugan <[email protected]>
1 parent 8b4e753 commit a256cc0

File tree

6 files changed

+181
-101
lines changed

6 files changed

+181
-101
lines changed

cmd/hubagent/workload/setup.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
clusterv1beta1 "github.com/kubefleet-dev/kubefleet/apis/cluster/v1beta1"
3434
placementv1beta1 "github.com/kubefleet-dev/kubefleet/apis/placement/v1beta1"
3535
"github.com/kubefleet-dev/kubefleet/cmd/hubagent/options"
36+
"github.com/kubefleet-dev/kubefleet/pkg/controllers/approvalrequest"
3637
"github.com/kubefleet-dev/kubefleet/pkg/controllers/bindingwatcher"
3738
"github.com/kubefleet-dev/kubefleet/pkg/controllers/clusterinventory/clusterprofile"
3839
"github.com/kubefleet-dev/kubefleet/pkg/controllers/clusterresourceplacementeviction"
@@ -328,6 +329,26 @@ func SetupControllers(ctx context.Context, wg *sync.WaitGroup, mgr ctrl.Manager,
328329
return err
329330
}
330331
}
332+
333+
// Set up the cluster approval request controller
334+
klog.Info("Setting up clusterApprovalRequest controller")
335+
if err = (&approvalrequest.Reconciler{
336+
Client: mgr.GetClient(),
337+
}).SetupWithManagerForClusterApprovalRequest(mgr); err != nil {
338+
klog.ErrorS(err, "Unable to set up clusterApprovalRequest controller")
339+
return err
340+
}
341+
342+
// Set up the approval request controller for namespaced resources
343+
if opts.EnableResourcePlacement {
344+
klog.Info("Setting up approvalRequest controller")
345+
if err = (&approvalrequest.Reconciler{
346+
Client: mgr.GetClient(),
347+
}).SetupWithManagerForApprovalRequest(mgr); err != nil {
348+
klog.ErrorS(err, "Unable to set up approvalRequest controller")
349+
return err
350+
}
351+
}
331352
}
332353

333354
// Set up the work generator

examples/fleet_v1beta1_membercluster.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ apiVersion: cluster.kubernetes-fleet.io/v1beta1
22
kind: MemberCluster
33
metadata:
44
name: kind-cluster-1
5+
labels:
6+
environment: staging
7+
kubernetes-fleet.io/cluster-name: kind-cluster-1
58
spec:
69
identity:
710
name: fleet-member-agent-cluster-1

examples/stagedupdaterun/clusterStagedUpdateRun.yaml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@ spec:
66
placementName: example-placement
77
resourceSnapshotIndex: "0"
88
stagedRolloutStrategyName: example-strategy
9-
status:
10-
policySnapshotIndexUsed: "0"
11-
policyObservedClusterCount: 3
12-
appliedStrategy:
13-
type: Immediate
14-
stagedUpdateStrategySnapshot:
15-
stages:
16-
- name: stage1
17-
labelSelector:
18-
matchLabels:
19-
environment: production
20-
sortingLabelKey: priority
21-
afterStageTasks:
22-
- type: TimedWait
23-
waitTime: 1h
24-
stagesStatus:
25-
- stageName: stage1
26-
clusters:
27-
- clusterName: cluster1
28-
conditions:
29-
- type: Started
30-
status: "True"
31-
startTime: "2023-10-01T00:00:00Z"
32-
endTime: "2023-10-01T01:00:00Z"
33-
conditions:
34-
- type: Progressing
35-
status: "True"
36-
conditions:
37-
- type: Initialized
38-
status: "True"
39-
- type: Progressing
40-
status: "True"
41-
- type: Succeeded
42-
status: "False"
9+
# status:
10+
# policySnapshotIndexUsed: "0"
11+
# policyObservedClusterCount: 3
12+
# appliedStrategy:
13+
# type: Immediate
14+
# stagedUpdateStrategySnapshot:
15+
# stages:
16+
# - name: stage1
17+
# labelSelector:
18+
# matchLabels:
19+
# environment: production
20+
# sortingLabelKey: priority
21+
# afterStageTasks:
22+
# - type: TimedWait
23+
# waitTime: 1h
24+
# stagesStatus:
25+
# - stageName: stage1
26+
# clusters:
27+
# - clusterName: cluster1
28+
# conditions:
29+
# - type: Started
30+
# status: "True"
31+
# startTime: "2023-10-01T00:00:00Z"
32+
# endTime: "2023-10-01T01:00:00Z"
33+
# conditions:
34+
# - type: Progressing
35+
# status: "True"
36+
# conditions:
37+
# - type: Initialized
38+
# status: "True"
39+
# - type: Progressing
40+
# status: "True"
41+
# - type: Succeeded
42+
# status: "False"

examples/stagedupdaterun/example-crp.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ spec:
66
resourceSelectors:
77
- group: ""
88
kind: Namespace
9-
name: test-namespace
9+
name: test-ns
1010
version: v1
1111
policy:
1212
placementType: PickAll
13-
tolerations:
14-
- key: gpu-workload
15-
operator: Exists
13+
# tolerations:
14+
# - key: gpu-workload
15+
# operator: Exists
1616
strategy:
1717
type: External

examples/stagedupdaterun/updateStrategy.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ spec:
88
labelSelector:
99
matchLabels:
1010
environment: staging
11-
afterStageTasks:
12-
- type: TimedWait
13-
waitTime: 1h
14-
- name: canary
15-
labelSelector:
16-
matchLabels:
17-
environment: canary
18-
sortingLabelKey: name
19-
afterStageTasks:
20-
- type: Approval
21-
- name: production
22-
labelSelector:
23-
matchLabels:
24-
environment: production
25-
sortingLabelKey: order
2611
afterStageTasks:
2712
- type: Approval
28-
- type: TimedWait
29-
waitTime: 1h
13+
# waitTime: 1h
14+
# - name: canary
15+
# labelSelector:
16+
# matchLabels:
17+
# environment: canary
18+
# sortingLabelKey: name
19+
# afterStageTasks:
20+
# - type: Approval
21+
# - name: production
22+
# labelSelector:
23+
# matchLabels:
24+
# environment: production
25+
# sortingLabelKey: order
26+
# afterStageTasks:
27+
# - type: Approval
28+
# - type: TimedWait
29+
# waitTime: 1h

0 commit comments

Comments
 (0)