Skip to content

Commit

Permalink
Merge pull request #743 from stlaz/privileged_ns_roles
Browse files Browse the repository at this point in the history
add roles for the new privileged namespaces PSa syncer controller
  • Loading branch information
openshift-merge-robot committed Aug 14, 2023
2 parents 5f49f59 + c2bf60f commit d95b0c2
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 3 deletions.
@@ -0,0 +1,24 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- ""
resourceNames:
- default
- kube-system
- kube-public
resources:
- namespaces
verbs:
- patch
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
subjects:
- kind: ServiceAccount
name: privileged-namespaces-psa-label-syncer
namespace: openshift-infra
@@ -0,0 +1,24 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
rules:
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- ""
resourceNames:
- default
- kube-system
- kube-public
resources:
- namespaces
verbs:
- patch
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:openshift:controller:privileged-namespaces-psa-label-syncer
subjects:
- kind: ServiceAccount
name: privileged-namespaces-psa-label-syncer
namespace: openshift-infra
11 changes: 8 additions & 3 deletions pkg/cmd/render/render_test.go
Expand Up @@ -3,7 +3,6 @@ package render
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -83,7 +82,7 @@ func runRender(args ...string) (*cobra.Command, error) {
}

func setupAssetOutputDir(testName string) (teardown func(), outputDir string, err error) {
outputDir, err = ioutil.TempDir("", testName)
outputDir, err = os.MkdirTemp("", testName)
if err != nil {
return nil, "", err
}
Expand Down Expand Up @@ -167,6 +166,8 @@ func TestRenderCommand(t *testing.T) {
"manifests/manifests/00_openshift-kube-controller-manager-ns.yaml",
"manifests/manifests/00_openshift-kube-controller-manager-operator-ns.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/secret-csr-signer-signer.yaml",
"manifests/manifests/secret-initial-kube-controller-manager-service-account-private-key.yaml",
Expand Down Expand Up @@ -246,6 +247,8 @@ func TestRenderCommand(t *testing.T) {
"manifests/manifests/00_openshift-kube-controller-manager-operator-ns.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/secret-csr-signer-signer.yaml",
"manifests/manifests/secret-initial-kube-controller-manager-service-account-private-key.yaml",
},
Expand Down Expand Up @@ -310,6 +313,8 @@ func TestRenderCommand(t *testing.T) {
"manifests/manifests/00_openshift-kube-controller-manager-operator-ns.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrole.yaml",
"manifests/manifests/00_podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrolebinding.yaml",
"manifests/manifests/secret-csr-signer-signer.yaml",
"manifests/manifests/secret-initial-kube-controller-manager-service-account-private-key.yaml",
},
Expand Down Expand Up @@ -412,7 +417,7 @@ func TestRenderCommand(t *testing.T) {
t.Errorf("file %q: %v", f, err)
}
if file, ok := test.expectedContents[f]; ok {
data, err := ioutil.ReadFile(p)
data, err := os.ReadFile(p)
if err != nil {
t.Errorf("error reading file %s: %v", p, err)
continue
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/starter.go
Expand Up @@ -124,6 +124,8 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
"assets/kube-controller-manager/namespace-security-allocation-controller-clusterrolebinding.yaml",
"assets/kube-controller-manager/podsecurity-admission-label-syncer-controller-clusterrole.yaml",
"assets/kube-controller-manager/podsecurity-admission-label-syncer-controller-clusterrolebinding.yaml",
"assets/kube-controller-manager/podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrole.yaml",
"assets/kube-controller-manager/podsecurity-admission-label-privileged-namespaces-syncer-controller-clusterrolebinding.yaml",
"assets/kube-controller-manager/namespace-openshift-infra.yaml",
"assets/kube-controller-manager/svc.yaml",
"assets/kube-controller-manager/sa.yaml",
Expand Down

0 comments on commit d95b0c2

Please sign in to comment.