Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
9b6aec5e
Commit
9b6aec5e
authored
Dec 22, 2014
by
roberthbailey
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3092 from zmerlynn/gke-kubectl-path
GKE: Adjust the PATH to the right kubectl for gcloud
parents
95d4da98
e71798df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
19 deletions
+36
-19
kubectl.sh
cluster/kubectl.sh
+36
-19
No files found.
cluster/kubectl.sh
View file @
9b6aec5e
...
@@ -22,6 +22,12 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
...
@@ -22,6 +22,12 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source
"
${
KUBE_ROOT
}
/cluster/kube-env.sh"
source
"
${
KUBE_ROOT
}
/cluster/kube-env.sh"
source
"
${
KUBE_ROOT
}
/cluster/
${
KUBERNETES_PROVIDER
}
/util.sh"
source
"
${
KUBE_ROOT
}
/cluster/
${
KUBERNETES_PROVIDER
}
/util.sh"
# Get the absolute path of the directory component of a file, i.e. the
# absolute path of the dirname of $1.
get_absolute_dirname
()
{
echo
"
$(
cd
"
$(
dirname
"
$1
"
)
"
&&
pwd
)
"
}
# Detect the OS name/arch so that we can find our binary
# Detect the OS name/arch so that we can find our binary
case
"
$(
uname
-s
)
"
in
case
"
$(
uname
-s
)
"
in
Darwin
)
Darwin
)
...
@@ -58,33 +64,44 @@ case "$(uname -m)" in
...
@@ -58,33 +64,44 @@ case "$(uname -m)" in
;;
;;
esac
esac
# Gather up the list of likely places and use ls to find the latest one.
# If KUBECTL_PATH isn't set, gather up the list of likely places and use ls
locations
=(
# to find the latest one.
"
${
KUBE_ROOT
}
/_output/dockerized/bin/
${
host_os
}
/
${
host_arch
}
/kubectl"
if
[[
-z
"
${
KUBECTL_PATH
:-}
"
]]
;
then
"
${
KUBE_ROOT
}
/_output/local/bin/
${
host_os
}
/
${
host_arch
}
/kubectl"
locations
=(
"
${
KUBE_ROOT
}
/platforms/
${
host_os
}
/
${
host_arch
}
/kubectl"
"
${
KUBE_ROOT
}
/_output/dockerized/bin/
${
host_os
}
/
${
host_arch
}
/kubectl"
"
${
HOME
}
/google-cloud-sdk/bin/kubectl"
"
${
KUBE_ROOT
}
/_output/local/bin/
${
host_os
}
/
${
host_arch
}
/kubectl"
)
"
${
KUBE_ROOT
}
/platforms/
${
host_os
}
/
${
host_arch
}
/kubectl"
kubectl
=
$(
(
ls
-t
"
${
locations
[@]
}
"
2>/dev/null
||
true
)
|
head
-1
)
)
kubectl
=
$(
(
ls
-t
"
${
locations
[@]
}
"
2>/dev/null
||
true
)
|
head
-1
)
if
[[
!
-x
"
$kubectl
"
]]
;
then
if
[[
!
-x
"
$kubectl
"
]]
;
then
{
echo
"It looks as if you don't have a compiled kubectl binary"
echo
echo
"If you are running from a clone of the git repo, please run"
echo
"'./build/run.sh hack/build-cross.sh'. Note that this requires having"
echo
"Docker installed."
echo
echo
"If you are running from a binary release tarball, something is wrong. "
echo
"Look at http://kubernetes.io/ for information on how to contact the "
echo
"development team for help."
}
>
&2
exit
1
fi
elif
[[
!
-x
"
${
KUBECTL_PATH
}
"
]]
;
then
{
{
echo
"It looks as if you don't have a compiled kubectl binary."
echo
"KUBECTL_PATH enviroment variable set to '
${
KUBECTL_PATH
}
', but "
echo
echo
"this doesn't seem to be a valid executable."
echo
"If you are running from a clone of the git repo, please run"
echo
"'./build/run.sh hack/build-cross.sh'. Note that this requires having"
echo
"Docker installed."
echo
echo
"If you are running from a binary release tarball, something is wrong. "
echo
"Look at http://kubernetes.io/ for information on how to contact the "
echo
"development team for help."
}
>
&2
}
>
&2
exit
1
exit
1
fi
fi
kubectl
=
"
${
KUBECTL_PATH
:-${
kubectl
}}
"
# While GKE requires the kubectl binary, it's actually called through gcloud.
# While GKE requires the kubectl binary, it's actually called through
# gcloud. But we need to adjust the PATH so gcloud gets the right one.
if
[[
"
$KUBERNETES_PROVIDER
"
==
"gke"
]]
;
then
if
[[
"
$KUBERNETES_PROVIDER
"
==
"gke"
]]
;
then
detect-project &> /dev/null
detect-project &> /dev/null
export
PATH
=
$(
get_absolute_dirname
$kubectl
)
:
$PATH
kubectl
=
"
${
GCLOUD
}
"
kubectl
=
"
${
GCLOUD
}
"
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment