Skip to content

Commit

Permalink
Merge pull request #937 from jlojosnegros/must-gather_podinfo_rbac
Browse files Browse the repository at this point in the history
must-gather:podinfo: Add RBAC elements to list pods
  • Loading branch information
openshift-merge-robot committed Aug 19, 2022
2 parents 500868f + ed616e4 commit d8b6678
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions must-gather/collection-scripts/gather_nodes
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ mkdir -p ${NODES_PATH}
NAMESPACE_MANIFEST="/etc/node-gather/namespace.yaml"
SERVICEACCOUNT_MANIFEST="/etc/node-gather/serviceaccount.yaml"
DAEMONSET_MANIFEST="/etc/node-gather/daemonset.yaml"
CLUSTER_ROLE_MANIFEST="/etc/node-gather/clusterrole.yaml"
CLUSTER_ROLE_BINDING_MANIFEST="/etc/node-gather/clusterrolebinding.yaml"
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
# Once you start the pod, the Kubernetes will set the pod hostname to the name of the pod
# https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-hostname-and-subdomain-fields
Expand All @@ -38,6 +40,8 @@ sed -i -e "s#MUST_GATHER_IMAGE#$MUST_GATHER_IMAGE#" $DAEMONSET_MANIFEST
oc create -f $NAMESPACE_MANIFEST
oc create -f $SERVICEACCOUNT_MANIFEST
oc adm policy add-scc-to-user privileged -n perf-node-gather -z perf-node-gather
oc create -f $CLUSTER_ROLE_MANIFEST
oc create -f $CLUSTER_ROLE_BINDING_MANIFEST
oc create -f $DAEMONSET_MANIFEST

COUNTER=0
Expand Down Expand Up @@ -88,5 +92,7 @@ done
wait "${ADM_PIDS[@]}"

oc delete -f $DAEMONSET_MANIFEST
oc delete -f $CLUSTER_ROLE_BINDING_MANIFEST
oc delete -f $CLUSTER_ROLE_MANIFEST
oc delete -f $SERVICEACCOUNT_MANIFEST
oc delete -f $NAMESPACE_MANIFEST
9 changes: 9 additions & 0 deletions must-gather/node-gather/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: perf-node-gather-pods-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get","list"]

13 changes: 13 additions & 0 deletions must-gather/node-gather/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: perf-node-gather-pods-reader
subjects:
- kind: ServiceAccount
name: perf-node-gather
namespace: perf-node-gather
apiGroup: ""
roleRef:
kind: ClusterRole
name: perf-node-gather-pods-reader
apiGroup: rbac.authorization.k8s.io

0 comments on commit d8b6678

Please sign in to comment.