Skip to content

Commit

Permalink
peerpodconfig-ctrl: Add missing rbac rules
Browse files Browse the repository at this point in the history
RBAC for daemonset was missing

Signed-off-by: Pradipta Banerjee <[email protected]>
  • Loading branch information
bpradipt committed Oct 16, 2023
1 parent fba34f5 commit d1f6f9b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
20 changes: 20 additions & 0 deletions peerpodconfig-ctrl/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ rules:
- patch
- update
- watch
- apiGroups:
- apps
resourceNames:
- peerpodconfig-ctrl-caa-daemon
resources:
- daemonsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- daemonsets/finalizers
verbs:
- update
- apiGroups:
- confidentialcontainers.org
resources:
Expand Down
11 changes: 7 additions & 4 deletions peerpodconfig-ctrl/controllers/peerpodconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
DefaultCloudApiAdaptorImage = "quay.io/confidential-containers/cloud-api-adaptor"
defaultNodeSelectorLabel = "node.kubernetes.io/worker"
defaultPeerPodsLimitPerNode = "1"
// cloud-api-adaptor (CAA) daemonset name
caaDsName = "peerpodconfig-ctrl-caa-daemon"
)

// PeerPodConfigReconciler reconciles a PeerPodConfig object
Expand All @@ -67,6 +69,8 @@ type PeerPodConfigReconciler struct {
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=create;get;update;list;watch
//+kubebuilder:rbac:groups="",resources=secrets,verbs=create;get;update;list;watch
//+kubebuilder:rbac:groups="";machineconfiguration.openshift.io,resources=nodes;machineconfigs;machineconfigpools;containerruntimeconfigs;pods;services;services/finalizers;endpoints;persistentvolumeclaims;events;configmaps;secrets,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=apps,resources=daemonsets,resourceNames=peerpodconfig-ctrl-caa-daemon,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=apps,resources=daemonsets/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down Expand Up @@ -136,9 +140,8 @@ func (r *PeerPodConfigReconciler) createCaaDaemonset() *appsv1.DaemonSet {
nodeSelector = map[string]string{defaultNodeSelectorLabel: ""}
)

dsName := "peerpodconfig-ctrl-caa-daemon"
dsLabelSelectors := map[string]string{
"name": dsName,
"name": caaDsName,
}

if r.peerPodConfig.Spec.NodeSelector != nil {
Expand All @@ -157,7 +160,7 @@ func (r *PeerPodConfigReconciler) createCaaDaemonset() *appsv1.DaemonSet {
Kind: "DaemonSet",
},
ObjectMeta: metav1.ObjectMeta{
Name: dsName,
Name: caaDsName,
Namespace: os.Getenv("PEERPODS_NAMESPACE"),
},
Spec: appsv1.DaemonSetSpec{
Expand All @@ -183,7 +186,7 @@ func (r *PeerPodConfigReconciler) createCaaDaemonset() *appsv1.DaemonSet {
HostNetwork: true,
Containers: []corev1.Container{
{
Name: "cc-runtime-install-pod",
Name: "caa-pod",
Image: imageString,
ImagePullPolicy: "Always",
SecurityContext: &corev1.SecurityContext{
Expand Down

0 comments on commit d1f6f9b

Please sign in to comment.