mirror of https://github.com/k3s-io/k3s
Merge pull request #44590 from ihmccreery/rotate-username
Automatic merge from submit-queue (batch tested with PRs 44590, 44969, 45325, 45208, 44714) Enable basic auth username rotation for GCI When changing basic auth creds, just delete the whole file, in order to be able to rotate username in addition to password.pull/6/head
commit
d7f72dcc44
|
@ -233,6 +233,7 @@ ENABLE_LEGACY_ABAC="${ENABLE_LEGACY_ABAC:-true}" # true, false
|
|||
# Kernel panic upon soft lockup issue
|
||||
SOFTLOCKUP_PANIC="${SOFTLOCKUP_PANIC:-false}" # true, false
|
||||
|
||||
# Indicates if the values (eg. kube password) in metadata should be treated as
|
||||
# canonical, and therefore disk copies ought to be recreated/clobbered.
|
||||
# Indicates if the values (i.e. KUBE_USER and KUBE_PASSWORD for basic
|
||||
# authentication) in metadata should be treated as canonical, and therefore disk
|
||||
# copies ought to be recreated/clobbered.
|
||||
METADATA_CLOBBERS_CONFIG=${METADATA_CLOBBERS_CONFIG:-false}
|
||||
|
|
|
@ -182,11 +182,11 @@ function mount-master-pd {
|
|||
chgrp -R etcd "${mount_point}/var/etcd"
|
||||
}
|
||||
|
||||
# replace_prefixed_line ensures:
|
||||
# append_or_replace_prefixed_line ensures:
|
||||
# 1. the specified file exists
|
||||
# 2. existing lines with the specified ${prefix} are removed
|
||||
# 3. a new line with the specified ${prefix}${suffix} is appended
|
||||
function replace_prefixed_line {
|
||||
function append_or_replace_prefixed_line {
|
||||
local -r file="${1:-}"
|
||||
local -r prefix="${2:-}"
|
||||
local -r suffix="${3:-}"
|
||||
|
@ -287,30 +287,32 @@ function create-master-auth {
|
|||
local -r basic_auth_csv="${auth_dir}/basic_auth.csv"
|
||||
if [[ -n "${KUBE_PASSWORD:-}" && -n "${KUBE_USER:-}" ]]; then
|
||||
if [[ -e "${basic_auth_csv}" && "${METADATA_CLOBBERS_CONFIG:-false}" == "true" ]]; then
|
||||
sed -i "/,${KUBE_USER},admin,system:masters$/d" "${basic_auth_csv}"
|
||||
# The following is for the legacy form of the password line.
|
||||
sed -i "/,${KUBE_USER},admin$/d" "${basic_auth_csv}"
|
||||
# If METADATA_CLOBBERS_CONFIG is true, we want to rewrite the file
|
||||
# completely, because if we're changing KUBE_USER and KUBE_PASSWORD, we
|
||||
# have nothing to match on. The file is replaced just below with
|
||||
# append_or_replace_prefixed_line.
|
||||
rm "${basic_auth_csv}"
|
||||
fi
|
||||
replace_prefixed_line "${basic_auth_csv}" "${KUBE_PASSWORD},${KUBE_USER}," "admin,system:masters"
|
||||
append_or_replace_prefixed_line "${basic_auth_csv}" "${KUBE_PASSWORD},${KUBE_USER}," "admin,system:masters"
|
||||
fi
|
||||
local -r known_tokens_csv="${auth_dir}/known_tokens.csv"
|
||||
if [[ -n "${KUBE_BEARER_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${KUBE_BEARER_TOKEN}," "admin,admin,system:masters"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_BEARER_TOKEN}," "admin,admin,system:masters"
|
||||
fi
|
||||
if [[ -n "${KUBE_CONTROLLER_MANAGER_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${KUBE_CONTROLLER_MANAGER_TOKEN}," "system:kube-controller-manager,uid:system:kube-controller-manager"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_CONTROLLER_MANAGER_TOKEN}," "system:kube-controller-manager,uid:system:kube-controller-manager"
|
||||
fi
|
||||
if [[ -n "${KUBE_SCHEDULER_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${KUBE_SCHEDULER_TOKEN}," "system:kube-scheduler,uid:system:kube-scheduler"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_SCHEDULER_TOKEN}," "system:kube-scheduler,uid:system:kube-scheduler"
|
||||
fi
|
||||
if [[ -n "${KUBELET_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${KUBELET_TOKEN}," "kubelet,uid:kubelet,system:nodes"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBELET_TOKEN}," "kubelet,uid:kubelet,system:nodes"
|
||||
fi
|
||||
if [[ -n "${KUBE_PROXY_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${KUBE_PROXY_TOKEN}," "system:kube-proxy,uid:kube_proxy"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${KUBE_PROXY_TOKEN}," "system:kube-proxy,uid:kube_proxy"
|
||||
fi
|
||||
if [[ -n "${NODE_PROBLEM_DETECTOR_TOKEN:-}" ]]; then
|
||||
replace_prefixed_line "${known_tokens_csv}" "${NODE_PROBLEM_DETECTOR_TOKEN}," "system:node-problem-detector,uid:node-problem-detector"
|
||||
append_or_replace_prefixed_line "${known_tokens_csv}" "${NODE_PROBLEM_DETECTOR_TOKEN}," "system:node-problem-detector,uid:node-problem-detector"
|
||||
fi
|
||||
local use_cloud_config="false"
|
||||
cat <<EOF >/etc/gce.conf
|
||||
|
|
|
@ -43,6 +43,7 @@ ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-standalone}"
|
|||
|
||||
KUBE_DELETE_NETWORK=${KUBE_DELETE_NETWORK:-false}
|
||||
|
||||
# Indicates if the values (eg. kube password) in metadata should be treated as
|
||||
# canonical, and therefore disk copies ought to be recreated/clobbered.
|
||||
# Indicates if the values (i.e. KUBE_USER and KUBE_PASSWORD for basic
|
||||
# authentication) in metadata should be treated as canonical, and therefore disk
|
||||
# copies ought to be recreated/clobbered.
|
||||
METADATA_CLOBBERS_CONFIG=true
|
||||
|
|
Loading…
Reference in New Issue