mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Merge pull request #87504 from cheftako/master
Fix issue with GCE scripts assuming Python2.
This commit is contained in:
		| @@ -1527,7 +1527,7 @@ function start-kube-proxy { | |||||||
| # $5: pod name, which should be either etcd or etcd-events | # $5: pod name, which should be either etcd or etcd-events | ||||||
| function prepare-etcd-manifest { | function prepare-etcd-manifest { | ||||||
|   local host_name=${ETCD_HOSTNAME:-$(hostname -s)} |   local host_name=${ETCD_HOSTNAME:-$(hostname -s)} | ||||||
|   local host_ip=$(python -c "import socket;print(socket.gethostbyname(\"${host_name}\"))") |   local host_ip=$(${PYTHON} -c "import socket;print(socket.gethostbyname(\"${host_name}\"))") | ||||||
|   local etcd_cluster="" |   local etcd_cluster="" | ||||||
|   local cluster_state="new" |   local cluster_state="new" | ||||||
|   local etcd_protocol="http" |   local etcd_protocol="http" | ||||||
| @@ -2713,9 +2713,14 @@ function main() { | |||||||
|  |  | ||||||
|   KUBE_HOME="/home/kubernetes" |   KUBE_HOME="/home/kubernetes" | ||||||
|   KUBE_BIN=${KUBE_HOME}/bin |   KUBE_BIN=${KUBE_HOME}/bin | ||||||
|  |   PYTHON="python" | ||||||
|   CONTAINERIZED_MOUNTER_HOME="${KUBE_HOME}/containerized_mounter" |   CONTAINERIZED_MOUNTER_HOME="${KUBE_HOME}/containerized_mounter" | ||||||
|   PV_RECYCLER_OVERRIDE_TEMPLATE="${KUBE_HOME}/kube-manifests/kubernetes/pv-recycler-template.yaml" |   PV_RECYCLER_OVERRIDE_TEMPLATE="${KUBE_HOME}/kube-manifests/kubernetes/pv-recycler-template.yaml" | ||||||
|  |  | ||||||
|  |   if [[ "$(python -V)" =~ "Python 3" ]]; then | ||||||
|  |     PYTHON="/usr/bin/python2.7" | ||||||
|  |   fi | ||||||
|  |  | ||||||
|   if [[ ! -e "${KUBE_HOME}/kube-env" ]]; then |   if [[ ! -e "${KUBE_HOME}/kube-env" ]]; then | ||||||
|     echo "The ${KUBE_HOME}/kube-env file does not exist!! Terminate cluster initialization." |     echo "The ${KUBE_HOME}/kube-env file does not exist!! Terminate cluster initialization." | ||||||
|     exit 1 |     exit 1 | ||||||
| @@ -2723,7 +2728,6 @@ function main() { | |||||||
|  |  | ||||||
|   source "${KUBE_HOME}/kube-env" |   source "${KUBE_HOME}/kube-env" | ||||||
|  |  | ||||||
|  |  | ||||||
|   if [[ -f "${KUBE_HOME}/kubelet-config.yaml" ]]; then |   if [[ -f "${KUBE_HOME}/kubelet-config.yaml" ]]; then | ||||||
|     echo "Found Kubelet config file at ${KUBE_HOME}/kubelet-config.yaml" |     echo "Found Kubelet config file at ${KUBE_HOME}/kubelet-config.yaml" | ||||||
|     KUBELET_CONFIG_FILE_ARG="--config ${KUBE_HOME}/kubelet-config.yaml" |     KUBELET_CONFIG_FILE_ARG="--config ${KUBE_HOME}/kubelet-config.yaml" | ||||||
|   | |||||||
| @@ -64,7 +64,7 @@ function download-kube-env { | |||||||
|       -o "${tmp_kube_env}" \ |       -o "${tmp_kube_env}" \ | ||||||
|       http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env |       http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env | ||||||
|     # Convert the yaml format file into a shell-style file. |     # Convert the yaml format file into a shell-style file. | ||||||
|     eval $(python -c ''' |     eval $(${PYTHON} -c ''' | ||||||
| import pipes,sys,yaml | import pipes,sys,yaml | ||||||
| for k,v in yaml.load(sys.stdin).iteritems(): | for k,v in yaml.load(sys.stdin).iteritems(): | ||||||
|   print("readonly {var}={value}".format(var = k, value = pipes.quote(str(v)))) |   print("readonly {var}={value}".format(var = k, value = pipes.quote(str(v)))) | ||||||
| @@ -103,7 +103,7 @@ function download-kube-master-certs { | |||||||
|       -o "${tmp_kube_master_certs}" \ |       -o "${tmp_kube_master_certs}" \ | ||||||
|       http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-master-certs |       http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-master-certs | ||||||
|     # Convert the yaml format file into a shell-style file. |     # Convert the yaml format file into a shell-style file. | ||||||
|     eval $(python -c ''' |     eval $(${PYTHON} -c ''' | ||||||
| import pipes,sys,yaml | import pipes,sys,yaml | ||||||
| for k,v in yaml.load(sys.stdin).iteritems(): | for k,v in yaml.load(sys.stdin).iteritems(): | ||||||
|   print("readonly {var}={value}".format(var = k, value = pipes.quote(str(v)))) |   print("readonly {var}={value}".format(var = k, value = pipes.quote(str(v)))) | ||||||
| @@ -126,7 +126,7 @@ function validate-hash { | |||||||
| # Get default service account credentials of the VM. | # Get default service account credentials of the VM. | ||||||
| GCE_METADATA_INTERNAL="http://metadata.google.internal/computeMetadata/v1/instance" | GCE_METADATA_INTERNAL="http://metadata.google.internal/computeMetadata/v1/instance" | ||||||
| function get-credentials { | function get-credentials { | ||||||
|   curl --fail --retry 5 --retry-delay 3 ${CURL_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 ${CURL_RETRY_CONNREFUSED} --silent --show-error "${GCE_METADATA_INTERNAL}/service-accounts/default/token" -H "Metadata-Flavor: Google" -s | ${PYTHON} -c \ | ||||||
|     'import sys; import json; print(json.loads(sys.stdin.read())["access_token"])' |     'import sys; import json; print(json.loads(sys.stdin.read())["access_token"])' | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -471,6 +471,11 @@ set-broken-motd | |||||||
|  |  | ||||||
| KUBE_HOME="/home/kubernetes" | KUBE_HOME="/home/kubernetes" | ||||||
| KUBE_BIN="${KUBE_HOME}/bin" | KUBE_BIN="${KUBE_HOME}/bin" | ||||||
|  | PYTHON="python" | ||||||
|  |  | ||||||
|  | if [[ "$(python -V)" =~ "Python 3" ]]; then | ||||||
|  |   PYTHON="/usr/bin/python2.7" | ||||||
|  | fi | ||||||
|  |  | ||||||
| # download and source kube-env | # download and source kube-env | ||||||
| download-kube-env | download-kube-env | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot