-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: generate a separate NFS CSI RBAC manifest
Because the NFS CSI driver is optional and rarely deployed, make RBAC for this driver an optional example that is generated by the helm chart. Signed-off-by: Blaine Gardner <[email protected]>
- Loading branch information
Showing
7 changed files
with
159 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
set -xeEuo pipefail | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
pushd "$SCRIPT_DIR" &>/dev/stderr | ||
|
||
NFS_RBAC_YAML_FILE="$SCRIPT_DIR/../../deploy/examples/csi/nfs/rbac.yaml" | ||
|
||
tmpdir="$(mktemp -d)" | ||
WITHOUT_FILE="${tmpdir}"/without-nfs.yaml # intermediate file of yaml that doesn't include NFS RBAC | ||
WITH_FILE="${tmpdir}"/with-nfs.yaml # intermediate file of yaml that includes previous plus NFS RBAC | ||
|
||
./get-helm-rbac.sh > "$WITHOUT_FILE" | ||
|
||
export ADDITIONAL_HELM_CLI_OPTIONS="--set csi.nfs.enabled=true" | ||
./get-helm-rbac.sh > "$WITH_FILE" | ||
|
||
rm -f "$NFS_RBAC_YAML_FILE" | ||
cat nfs-rbac.yaml.header >> "$NFS_RBAC_YAML_FILE" | ||
./keep-added.sh "$WITHOUT_FILE" "$WITH_FILE" >> "$NFS_RBAC_YAML_FILE" | ||
|
||
rm -rf "$tmpdir" | ||
popd &>/dev/stderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
set -eEuo pipefail | ||
|
||
DROP_FILE="$1" | ||
KEEP_FILE="$2" | ||
|
||
# WRITES TO STDOUT | ||
# DEBUGS TO STDERR | ||
|
||
: ${YQ:=yq} | ||
|
||
if [[ "$($YQ --version)" != "yq (https://github.com/mikefarah/yq/) version 4."* ]]; then | ||
echo "yq must be version 4.x" | ||
exit 1 | ||
fi | ||
|
||
# | ||
# Create a file for each resource present in the drop set | ||
# | ||
drop_dir="$(mktemp -d)" | ||
pushd "${drop_dir}" &>/dev/stderr | ||
|
||
$YQ eval --split-exp '.kind + " " + .metadata.name + " "' "$DROP_FILE" # split into files by <kind> <name> .yaml | ||
# outputting the filenames with spaces after kind and name keeps the same sorting from before | ||
|
||
popd &>/dev/stderr | ||
|
||
# | ||
# Create a file for each resource present in the keep set | ||
# | ||
keep_dir="$(mktemp -d)" | ||
pushd "${keep_dir}" &>/dev/stderr | ||
|
||
$YQ eval --split-exp '.kind + " " + .metadata.name + " "' "$KEEP_FILE" # split into files by <kind> <name> .yaml | ||
# outputting the filenames with spaces after kind and name keeps the same sorting from before | ||
|
||
popd &>/dev/stderr | ||
|
||
# | ||
# In the keep set, remove every file that also exists in the drop set | ||
# | ||
pushd "${drop_dir}" &>/dev/stderr | ||
|
||
find . -type f -name '*.yml' -exec rm "${keep_dir}"/{} \; | ||
|
||
popd &>/dev/stderr | ||
|
||
# | ||
# Combine the kept files back into one yaml | ||
# | ||
RBAC_FILES=() | ||
while read -r line; do | ||
RBAC_FILES+=("$line") | ||
done < <(find "${keep_dir}"/. -type f -name '*.yml' | sort) | ||
|
||
# use keep-rbac-yaml.sh at the end to strip out only the RBAC, and sort and format it as we want | ||
$YQ eval-all '.' "${RBAC_FILES[@]}" | ./keep-rbac-yaml.sh | ||
|
||
rm -rf "${drop_dir}" | ||
rm -rf "${keep_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#################################################################################################### | ||
# These RBAC resources are required to allow Rook to run the NFS export CSI driver components. | ||
#################################################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#################################################################################################### | ||
# These RBAC resources are required to allow Rook to run the NFS export CSI driver components. | ||
#################################################################################################### | ||
--- | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: ceph-nfs-external-provisioner-runner | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["persistentvolumes"] | ||
verbs: ["get", "list", "watch", "create", "delete"] | ||
- apiGroups: [""] | ||
resources: ["persistentvolumeclaims"] | ||
verbs: ["get", "list", "watch", "update"] | ||
- apiGroups: ["storage.k8s.io"] | ||
resources: ["storageclasses"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: [""] | ||
resources: ["events"] | ||
verbs: ["get", "list", "watch", "create", "update", "patch"] | ||
- apiGroups: ["storage.k8s.io"] | ||
resources: ["csinodes"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: [""] | ||
resources: ["nodes"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["coordination.k8s.io"] | ||
resources: ["leases"] | ||
verbs: ["get", "list", "watch", "create", "update", "patch"] | ||
- apiGroups: [""] | ||
resources: ["secrets"] | ||
verbs: ["get"] | ||
--- | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: ceph-nfs-csi-provisioner-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: rook-csi-nfs-provisioner-sa | ||
namespace: rook-ceph # namespace:operator | ||
roleRef: | ||
kind: ClusterRole | ||
name: ceph-nfs-external-provisioner-runner | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
# Service account for the NFS CSI driver | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: rook-csi-nfs-plugin-sa | ||
namespace: rook-ceph # namespace:operator | ||
# imagePullSecrets: | ||
# - name: my-registry-secret | ||
--- | ||
# Service account for the NFS CSI provisioner | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: rook-csi-nfs-provisioner-sa | ||
namespace: rook-ceph # namespace:operator | ||
# imagePullSecrets: | ||
# - name: my-registry-secret |