From fc736ec3993ff18b6380d2016060991e2c3a11f4 Mon Sep 17 00:00:00 2001 From: Thiago Brito Date: Fri, 7 Jan 2022 15:59:41 -0300 Subject: [PATCH] Fix nova-compute-ssh init to execute as runAsUser On _ssh-init.sh.tpl, despite one change the runAsUser for the nova-compute container on the securityContext, the ssh keys are always being copied into the 'nova' user's folder. This change fixes it by getting the correct user defined on the securityContext and copying the keys to its correct folder. Signed-off-by: Thiago Brito Change-Id: Ia7883dc4626a295892eb4637ef717b0b1725ac89 --- nova/templates/bin/_ssh-init.sh.tpl | 13 ++++++++----- nova/templates/daemonset-compute.yaml | 16 ++++++++++++---- nova/values.yaml | 4 +++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/nova/templates/bin/_ssh-init.sh.tpl b/nova/templates/bin/_ssh-init.sh.tpl index be2e33a4..fbd96f04 100644 --- a/nova/templates/bin/_ssh-init.sh.tpl +++ b/nova/templates/bin/_ssh-init.sh.tpl @@ -16,10 +16,13 @@ limitations under the License. set -ex -mkdir -p ~nova/.ssh -chown -R nova:nova ~nova/.ssh +export NOVA_USERNAME=$(id -u ${NOVA_USER_UID} -n) +export NOVA_USER_HOME=$(eval echo ~${NOVA_USERNAME}) -cat > ~nova/.ssh/config < ${NOVA_USER_HOME}/.ssh/config <