mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #34958 from euank/local-up-guess-path
Automatic merge from submit-queue local-up: Add option to guess binary path This adds a `-O` flag which guesses the right output directory. The reason for having two flags, not one, is because bash's `getopt` doesn't let you do optional arguments easily, so having both makes the code simpler. I also removed the redundant empty check; the bash argument check meant that was never hit. cc @jayunit100 and @jbeda (arbitrary people from the git log)
This commit is contained in:
commit
19e9f7e400
@ -102,6 +102,12 @@ hack/local-up-cluster.sh
|
|||||||
This will build and start a lightweight local cluster, consisting of a master
|
This will build and start a lightweight local cluster, consisting of a master
|
||||||
and a single node. Type Control-C to shut it down.
|
and a single node. Type Control-C to shut it down.
|
||||||
|
|
||||||
|
If you've already compiled the Kubernetes components, then you can avoid rebuilding them with this script by using the `-O` flag.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./hack/local-up-cluster.sh -O
|
||||||
|
```
|
||||||
|
|
||||||
You can use the cluster/kubectl.sh script to interact with the local cluster. hack/local-up-cluster.sh will
|
You can use the cluster/kubectl.sh script to interact with the local cluster. hack/local-up-cluster.sh will
|
||||||
print the commands to run to point kubectl at the local cluster.
|
print the commands to run to point kubectl at the local cluster.
|
||||||
|
|
||||||
|
@ -71,21 +71,35 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
function usage {
|
function usage {
|
||||||
echo "This script starts a local kube cluster. "
|
echo "This script starts a local kube cluster. "
|
||||||
echo "Example 1: hack/local-up-cluster.sh -o _output/dockerized/bin/linux/amd64/ (run from docker output)"
|
echo "Example 1: hack/local-up-cluster.sh -o _output/dockerized/bin/linux/amd64/ (run from docker output)"
|
||||||
echo "Example 2: hack/local-up-cluster.sh (build a local copy of the source)"
|
echo "Example 2: hack/local-up-cluster.sh -O (auto-guess the bin path for your platform)"
|
||||||
|
echo "Example 3: hack/local-up-cluster.sh (build a local copy of the source)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function guesses where the existing cached binary build is for the `-O`
|
||||||
|
# flag
|
||||||
|
function guess_built_binary_path {
|
||||||
|
local hyperkube_path=$(kube::util::find-binary "hyperkube")
|
||||||
|
if [[ -z "${hyperkube_path}" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo -n "$(dirname "${hyperkube_path}")"
|
||||||
}
|
}
|
||||||
|
|
||||||
### Allow user to supply the source directory.
|
### Allow user to supply the source directory.
|
||||||
GO_OUT=""
|
GO_OUT=""
|
||||||
while getopts "o:" OPTION
|
while getopts "o:O" OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
o)
|
o)
|
||||||
echo "skipping build"
|
echo "skipping build"
|
||||||
echo "using source $OPTARG"
|
|
||||||
GO_OUT="$OPTARG"
|
GO_OUT="$OPTARG"
|
||||||
|
echo "using source $GO_OUT"
|
||||||
|
;;
|
||||||
|
O)
|
||||||
|
GO_OUT=$(guess_built_binary_path)
|
||||||
if [ $GO_OUT == "" ]; then
|
if [ $GO_OUT == "" ]; then
|
||||||
echo "You provided an invalid value for the build output directory."
|
echo "Could not guess the correct output directory to use."
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
|
Loading…
Reference in New Issue
Block a user