mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #101722 from bobbypage/python3
Revert "Revert "cluster: Use python3 everywhere""
This commit is contained in:
commit
445efbd612
@ -1781,7 +1781,7 @@ function start-kube-proxy {
|
||||
# $5: pod name, which should be either etcd or etcd-events
|
||||
function prepare-etcd-manifest {
|
||||
local host_name=${ETCD_HOSTNAME:-$(hostname -s)}
|
||||
local -r host_ip=$(${PYTHON} -c "import socket;print(socket.gethostbyname(\"${host_name}\"))")
|
||||
local -r host_ip=$(python3 -c "import socket;print(socket.gethostbyname(\"${host_name}\"))")
|
||||
local etcd_cluster=""
|
||||
local cluster_state="new"
|
||||
local etcd_protocol="http"
|
||||
@ -3288,24 +3288,6 @@ function main() {
|
||||
CONTAINERIZED_MOUNTER_HOME="${KUBE_HOME}/containerized_mounter"
|
||||
PV_RECYCLER_OVERRIDE_TEMPLATE="${KUBE_HOME}/kube-manifests/kubernetes/pv-recycler-template.yaml"
|
||||
|
||||
log-start 'SetPythonVersion'
|
||||
if [[ "$(python -V 2>&1)" =~ "Python 2" ]]; then
|
||||
# found python2, just use that
|
||||
PYTHON="python"
|
||||
elif [[ -f "/usr/bin/python2.7" ]]; then
|
||||
# System python not defaulted to python 2 but using 2.7 during migration
|
||||
PYTHON="/usr/bin/python2.7"
|
||||
else
|
||||
# No python2 either by default, let's see if we can find python3
|
||||
PYTHON="python3"
|
||||
if ! command -v ${PYTHON} >/dev/null 2>&1; then
|
||||
echo "ERROR Python not found. Aborting."
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
echo "Version : $(${PYTHON} -V 2>&1)"
|
||||
log-end 'SetPythonVersion'
|
||||
|
||||
log-start 'SourceKubeEnv'
|
||||
if [[ ! -e "${KUBE_HOME}/kube-env" ]]; then
|
||||
echo "The ${KUBE_HOME}/kube-env file does not exist!! Terminate cluster initialization."
|
||||
|
@ -87,13 +87,9 @@ function download-kube-env {
|
||||
-o "${tmp_kube_env}" \
|
||||
http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env
|
||||
# Convert the yaml format file into a shell-style file.
|
||||
eval "$(${PYTHON} -c '''
|
||||
eval "$(python3 -c '''
|
||||
import pipes,sys,yaml
|
||||
# check version of python and call methods appropriate for that version
|
||||
if sys.version_info[0] < 3:
|
||||
items = yaml.load(sys.stdin).iteritems()
|
||||
else:
|
||||
items = yaml.load(sys.stdin, Loader=yaml.BaseLoader).items()
|
||||
items = yaml.load(sys.stdin, Loader=yaml.BaseLoader).items()
|
||||
for k, v in items:
|
||||
print("readonly {var}={value}".format(var=k, value=pipes.quote(str(v))))
|
||||
''' < "${tmp_kube_env}" > "${KUBE_HOME}/kube-env")"
|
||||
@ -131,13 +127,9 @@ function download-kube-master-certs {
|
||||
-o "${tmp_kube_master_certs}" \
|
||||
http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-master-certs
|
||||
# Convert the yaml format file into a shell-style file.
|
||||
eval "$(${PYTHON} -c '''
|
||||
eval "$(python3 -c '''
|
||||
import pipes,sys,yaml
|
||||
# check version of python and call methods appropriate for that version
|
||||
if sys.version_info[0] < 3:
|
||||
items = yaml.load(sys.stdin).iteritems()
|
||||
else:
|
||||
items = yaml.load(sys.stdin, Loader=yaml.BaseLoader).items()
|
||||
items = yaml.load(sys.stdin, Loader=yaml.BaseLoader).items()
|
||||
for k, v in items:
|
||||
print("readonly {var}={value}".format(var=k, value=pipes.quote(str(v))))
|
||||
''' < "${tmp_kube_master_certs}" > "${KUBE_HOME}/kube-master-certs")"
|
||||
@ -160,7 +152,7 @@ function validate-hash {
|
||||
# Get default service account credentials of the VM.
|
||||
GCE_METADATA_INTERNAL="http://metadata.google.internal/computeMetadata/v1/instance"
|
||||
function get-credentials {
|
||||
curl --fail --retry 5 --retry-delay 3 --retry-connrefused --silent --show-error "${GCE_METADATA_INTERNAL}/service-accounts/default/token" -H "Metadata-Flavor: Google" -s | ${PYTHON} -c \
|
||||
curl --fail --retry 5 --retry-delay 3 --retry-connrefused --silent --show-error "${GCE_METADATA_INTERNAL}/service-accounts/default/token" -H "Metadata-Flavor: Google" -s | python3 -c \
|
||||
'import sys; import json; print(json.loads(sys.stdin.read())["access_token"])'
|
||||
}
|
||||
|
||||
@ -861,25 +853,6 @@ log-wrap 'SetBrokenMotd' set-broken-motd
|
||||
|
||||
KUBE_HOME="/home/kubernetes"
|
||||
KUBE_BIN="${KUBE_HOME}/bin"
|
||||
PYTHON="python"
|
||||
|
||||
log-start 'SetPythonVersion'
|
||||
if [[ "$(python -V 2>&1)" =~ "Python 2" ]]; then
|
||||
# found python2, just use that
|
||||
PYTHON="python"
|
||||
elif [[ -f "/usr/bin/python2.7" ]]; then
|
||||
# System python not defaulted to python 2 but using 2.7 during migration
|
||||
PYTHON="/usr/bin/python2.7"
|
||||
else
|
||||
# No python2 either by default, let's see if we can find python3
|
||||
PYTHON="python3"
|
||||
if ! command -v ${PYTHON} >/dev/null 2>&1; then
|
||||
echo "ERROR Python not found. Aborting."
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
echo "Version : $(${PYTHON} -V 2>&1)"
|
||||
log-end 'SetPythonVersion'
|
||||
|
||||
# download and source kube-env
|
||||
log-wrap 'DownloadKubeEnv' retry-forever 30 download-kube-env
|
||||
|
Loading…
Reference in New Issue
Block a user