mirror of https://github.com/k3s-io/k3s
Initial add of an environment variable for the kubernetes master.
parent
d53c56dd29
commit
4d6a783e5f
|
@ -112,7 +112,10 @@ cd kubernetes
|
|||
hack/local-up-cluster.sh
|
||||
```
|
||||
|
||||
This will build and start a lightweight local cluster, consisting of a master and a single minion. Type Control-C to shut it down. While it's running, you can use `hack/localcfg.sh` in place of `cluster/kubecfg.sh` to talk to it.
|
||||
This will build and start a lightweight local cluster, consisting of a master and a single minion. Type Control-C to shut it down.
|
||||
|
||||
If you are running both a remote kubernetes cluster and the local cluster, you can determine which you talk to using the ```KUBERNETES_MASTER``` environment variable.
|
||||
|
||||
|
||||
## Where to go next?
|
||||
[Detailed example application](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/guestbook/guestbook.md)
|
||||
|
|
|
@ -26,4 +26,15 @@ fi
|
|||
|
||||
detect-master > /dev/null
|
||||
|
||||
$CLOUDCFG -h https://${KUBE_MASTER_IP} $@
|
||||
# detect-master returns this if there is no master found.
|
||||
if [ "$KUBE_MASTER_IP" == "external-ip" ]; then
|
||||
KUBE_MASTER_IP=""
|
||||
fi
|
||||
|
||||
if [ "$KUBERNETES_MASTER" == "" ]; then
|
||||
if [ "${KUBE_MASTER_IP}" != "" ]; then
|
||||
$CLOUDCFG -h https://${KUBE_MASTER_IP} $@
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
$CLOUDCFG $@
|
||||
|
|
|
@ -102,7 +102,15 @@ func main() {
|
|||
}
|
||||
|
||||
secure := true
|
||||
parsedUrl, err := url.Parse(*httpServer)
|
||||
var masterServer string
|
||||
if len(*httpServer) > 0 {
|
||||
masterServer = *httpServer
|
||||
} else if len(os.Getenv("KUBERNETES_MASTER")) > 0 {
|
||||
masterServer = os.Getenv("KUBERNETES_MASTER")
|
||||
} else {
|
||||
masterServer = "http://localhost:8080"
|
||||
}
|
||||
parsedUrl, err := url.Parse(masterServer)
|
||||
if err != nil {
|
||||
glog.Fatalf("Unable to parse %v as a URL\n", err)
|
||||
}
|
||||
|
@ -120,7 +128,7 @@ func main() {
|
|||
|
||||
if *proxy {
|
||||
glog.Info("Starting to serve on localhost:8001")
|
||||
server := kubecfg.NewProxyServer(*www, *httpServer, auth)
|
||||
server := kubecfg.NewProxyServer(*www, masterServer, auth)
|
||||
glog.Fatal(server.Serve())
|
||||
}
|
||||
|
||||
|
@ -130,14 +138,16 @@ func main() {
|
|||
}
|
||||
method := flag.Arg(0)
|
||||
|
||||
matchFound := executeAPIRequest(method, auth) || executeControllerRequest(method, auth)
|
||||
client := kube_client.New(masterServer, auth)
|
||||
|
||||
matchFound := executeAPIRequest(method, client) || executeControllerRequest(method, client)
|
||||
if matchFound == false {
|
||||
glog.Fatalf("Unknown command %s", method)
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to execute an API request
|
||||
func executeAPIRequest(method string, auth *kube_client.AuthInfo) bool {
|
||||
func executeAPIRequest(method string, s *kube_client.Client) bool {
|
||||
parseStorage := func() string {
|
||||
if len(flag.Args()) != 2 {
|
||||
glog.Fatal("usage: kubecfg [OPTIONS] get|list|create|update|delete <url>")
|
||||
|
@ -159,7 +169,6 @@ func executeAPIRequest(method string, auth *kube_client.AuthInfo) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
s := kube_client.New(*httpServer, auth)
|
||||
r := s.Verb(verb).
|
||||
Path(parseStorage()).
|
||||
ParseSelector(*selector)
|
||||
|
@ -190,7 +199,7 @@ func executeAPIRequest(method string, auth *kube_client.AuthInfo) bool {
|
|||
}
|
||||
|
||||
// Attempts to execute a replicationController request
|
||||
func executeControllerRequest(method string, auth *kube_client.AuthInfo) bool {
|
||||
func executeControllerRequest(method string, c *kube_client.Client) bool {
|
||||
parseController := func() string {
|
||||
if len(flag.Args()) != 2 {
|
||||
glog.Fatal("usage: kubecfg [OPTIONS] stop|rm|rollingupdate <controller>")
|
||||
|
@ -198,8 +207,6 @@ func executeControllerRequest(method string, auth *kube_client.AuthInfo) bool {
|
|||
return flag.Arg(1)
|
||||
}
|
||||
|
||||
c := kube_client.New(*httpServer, auth)
|
||||
|
||||
var err error
|
||||
switch method {
|
||||
case "stop":
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This file is exactly like kubecfg.sh, but it talks to a local master
|
||||
# (which you're assumed to be running with local-up-cluster.sh).
|
||||
|
||||
CLOUDCFG=$(dirname $0)/../output/go/kubecfg
|
||||
if [ ! -x $CLOUDCFG ]; then
|
||||
echo "Could not find kubecfg binary. Run hack/build-go.sh to build it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 8080 is the default port for the master
|
||||
$CLOUDCFG -h http://localhost:8080 $@
|
Loading…
Reference in New Issue