Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ spec:
selector:
matchLabels:
k8s-app: cluster-baremetal-operator
strategy:
type: Recreate
template:
metadata:
annotations:
Expand All @@ -26,6 +28,8 @@ spec:
image: registry.ci.openshift.org/openshift:cluster-baremetal-operator
command:
- "/usr/bin/cluster-baremetal-operator"
args:
- --enable-leader-election
env:
- name: RELEASE_VERSION
value: "0.0.1-snapshot"
Expand Down
10 changes: 8 additions & 2 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ commonAnnotations:
resources:
- role.yaml
- role_binding.yaml
#- leader_election_role.yaml
#- leader_election_role_binding.yaml
# Comment the following 3 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
#- auth_proxy_service.yaml
#- auth_proxy_role.yaml
#- auth_proxy_role_binding.yaml

patchesJson6902:
- target:
group: rbac.authorization.k8s.io
version: v1
kind: Role
name: cluster-baremetal-operator
path: patches/leader_election_role.yaml
32 changes: 0 additions & 32 deletions config/rbac/leader_election_role.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions config/rbac/leader_election_role_binding.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions config/rbac/patches/leader_election_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables Lease management for leader election.
- op: add
path: /rules/-
value:
apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
19 changes: 1 addition & 18 deletions controllers/provisioning_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,25 +593,8 @@ func (r *ProvisioningReconciler) updateProvisioningMacAddresses(ctx context.Cont
// SetupWithManager configures the manager to run the controller
func (r *ProvisioningReconciler) SetupWithManager(mgr ctrl.Manager) error {
ctx := context.Background()
err := r.ensureClusterOperator()
if err != nil {
return errors.Wrap(err, "unable to set get baremetal ClusterOperator")
}

// Check the Platform Type to determine the state of the CO
enabled := IsEnabled(r.EnabledFeatures)

// If Platform is BareMetal, we could still be missing the Provisioning CR
if enabled {
baremetalConfig, err := r.readProvisioningCR(context.Background())
if err != nil || baremetalConfig == nil {
err = r.updateCOStatus(ReasonProvisioningCRNotFound, "Waiting for Provisioning CR on BareMetal Platform", "")
if err != nil {
return fmt.Errorf("unable to put %q ClusterOperator in Available state: %w", clusterOperatorName, err)
}
}
}

var err error
r.NetworkStack, err = r.networkStackFromServiceNetwork(ctx)
if err != nil {
return fmt.Errorf("unable to determine network stack from service network: %w", err)
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func main() {
}),
NewCache: cache.MultiNamespacedCacheBuilder(
[]string{controllers.ComponentNamespace, provisioning.OpenshiftConfigNamespace}),
LeaderElection: enableLeaderElection,
LeaderElection: enableLeaderElection,
LeaderElectionID: "cluster-baremetal-operator",
LeaderElectionNamespace: controllers.ComponentNamespace,
})
if err != nil {
klog.ErrorS(err, "unable to start manager")
Expand Down
12 changes: 12 additions & 0 deletions manifests/0000_31_cluster-baremetal-operator_05_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ rules:
- securitycontextconstraints
verbs:
- use
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ spec:
selector:
matchLabels:
k8s-app: cluster-baremetal-operator
strategy:
type: Recreate
template:
metadata:
annotations:
Expand All @@ -26,7 +28,9 @@ spec:
k8s-app: cluster-baremetal-operator
spec:
containers:
- command:
- args:
- --enable-leader-election
command:
- /usr/bin/cluster-baremetal-operator
env:
- name: RELEASE_VERSION
Expand Down