Skip to content

Commit 434a896

Browse files
committed
deploy: fix kustomize issue when using sidecar files for rbac.yaml
Using kustomize to add labels to a sidecar's local rbac.yaml file failed because although the file existed already, referencing it via an absolute path was rejected by kustomize: error: accumulating resources: accumulation err='accumulating resources from '/home/prow/go/src/github.com/kubernetes-csi/external-resizer/deploy/kubernetes/rbac.yaml': security; file '/home/prow/go/src/github.com/kubernetes-csi/external-resizer/deploy/kubernetes/rbac.yaml' is not in or below '/tmp/tmp.ehRnbHpnLX'': new root '/home/prow/go/src/github.com/kubernetes-csi/external-resizer/deploy/kubernetes/rbac.yaml' cannot be absolute
1 parent 94fe681 commit 434a896

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

deploy/kubernetes-distributed/deploy.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ for component in CSI_PROVISIONER; do
148148
# we need to add the files locally in temp folder and using kustomize adding labels it will be applied
149149
if [[ "${current}" =~ ^http:// ]] || [[ "${current}" =~ ^https:// ]]; then
150150
run curl "${current}" --output "${TEMP_DIR}"/rbac.yaml --silent --location
151-
current=./rbac.yaml
151+
else
152+
# Even for local files we need to copy because kustomize only supports files inside
153+
# the root of a kustomization.
154+
cp "${current}" "${TEMP_DIR}"/rbac.yaml
152155
fi
153156

154157
cat <<- EOF > "${TEMP_DIR}"/kustomization.yaml
@@ -160,7 +163,7 @@ commonLabels:
160163
app.kubernetes.io/part-of: csi-driver-host-path
161164
162165
resources:
163-
- ${current}
166+
- ./rbac.yaml
164167
EOF
165168

166169
run kubectl apply --kustomize "${TEMP_DIR}"

deploy/util/deploy-hostpath.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ for component in CSI_PROVISIONER CSI_ATTACHER CSI_SNAPSHOTTER CSI_RESIZER CSI_EX
185185
# we need to add the files locally in temp folder and using kustomize adding labels it will be applied
186186
if [[ "${current}" =~ ^http:// ]] || [[ "${current}" =~ ^https:// ]]; then
187187
run curl "${current}" --output "${TEMP_DIR}"/rbac.yaml --silent --location
188-
current=./rbac.yaml
188+
else
189+
# Even for local files we need to copy because kustomize only supports files inside
190+
# the root of a kustomization.
191+
cp "${current}" "${TEMP_DIR}"/rbac.yaml
189192
fi
190193

191194
cat <<- EOF > "${TEMP_DIR}"/kustomization.yaml
@@ -197,7 +200,7 @@ commonLabels:
197200
app.kubernetes.io/part-of: csi-driver-host-path
198201
199202
resources:
200-
- ${current}
203+
- ./rbac.yaml
201204
EOF
202205

203206
run kubectl apply --kustomize "${TEMP_DIR}"

0 commit comments

Comments
 (0)