From 29d556a03a89d25cc09df7921415aed56456f0c0 Mon Sep 17 00:00:00 2001 From: Tim Allclair Date: Thu, 9 Nov 2017 19:34:36 -0800 Subject: [PATCH] Source PodSecurityPolicies from addon subdir --- cluster/gce/gci/configure-helper.sh | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index c7259b8f526..ace02f224ae 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -1705,14 +1705,35 @@ function start-cluster-autoscaler { fi } -# A helper function for copying addon manifests and set dir/files -# permissions. +# A helper function for setting up addon manifests. # # $1: addon category under /etc/kubernetes # $2: manifest source dir +# $3: (optional) auxilary manifest source dir function setup-addon-manifests { - local -r src_dir="${KUBE_HOME}/kube-manifests/kubernetes/gci-trusty/$2" + local -r src_dir="${KUBE_HOME}/kube-manifests/kubernetes/gci-trusty" local -r dst_dir="/etc/kubernetes/$1/$2" + + copy-manifests "${src_dir}/$2" "${dst_dir}" + + # If the PodSecurityPolicy admission controller is enabled, + # set up the corresponding addon policies. + if [[ "${ENABLE_POD_SECURITY_POLICY:-}" == "true" ]]; then + local -r psp_dir="${src_dir}/${3:-$2}/podsecuritypolicies" + if [[ -d "${psp_dir}" ]]; then + copy-manifests "${psp_dir}" "${dst_dir}" + fi + fi +} + +# A helper function for copying manifests and setting dir/files +# permissions. +# +# $1: absolute source dir +# $2: absolute destination dir +function copy-manifests { + local -r src_dir="$1" + local -r dst_dir="$2" if [[ ! -d "${dst_dir}" ]]; then mkdir -p "${dst_dir}" fi @@ -1783,7 +1804,7 @@ function start-kube-addons { fi if [[ "${ENABLE_POD_SECURITY_POLICY:-}" == "true" ]]; then - setup-addon-manifests "addons" "podsecuritypolicies" + setup-addon-manifests "addons" "podsecuritypolicies" fi # Set up manifests of other addons. @@ -1892,7 +1913,7 @@ EOF fi if [[ "${ENABLE_NODE_PROBLEM_DETECTOR:-}" == "standalone" ]]; then # Setup role binding for standalone node problem detector. - setup-addon-manifests "addons" "node-problem-detector/standalone" + setup-addon-manifests "addons" "node-problem-detector/standalone" "node-problem-detector" fi if echo "${ADMISSION_CONTROL:-}" | grep -q "LimitRanger"; then setup-addon-manifests "admission-controls" "limit-range"