diff --git a/cluster/kube-env.sh b/cluster/kube-env.sh index 17d09fb67647c..9339f290a21d1 100644 --- a/cluster/kube-env.sh +++ b/cluster/kube-env.sh @@ -18,6 +18,6 @@ # You can override the default provider by exporting the KUBERNETES_PROVIDER # variable in your bashrc # -# The valid values: 'gce', 'azure' and 'vagrant' +# The valid values: 'gce', 'azure', 'vagrant', 'local' KUBERNETES_PROVIDER=${KUBERNETES_PROVIDER:-gce} diff --git a/cluster/kubecfg.sh b/cluster/kubecfg.sh index 8e70e92f818c2..225c3632351aa 100755 --- a/cluster/kubecfg.sh +++ b/cluster/kubecfg.sh @@ -27,15 +27,4 @@ fi detect-master > /dev/null -# 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 $@ diff --git a/cluster/local/config-default.sh b/cluster/local/config-default.sh new file mode 100644 index 0000000000000..2ac9205400197 --- /dev/null +++ b/cluster/local/config-default.sh @@ -0,0 +1,29 @@ +#!/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. + +## Contains configuration values for interacting with the Vagrant cluster + +# NUMBER OF MINIONS IN THE CLUSTER +NUM_MINIONS=1 + +# IP LOCATIONS FOR INTERACTING WITH THE MASTER +export KUBE_MASTER_IP="127.0.0.1" +export KUBERNETES_MASTER="http://127.0.0.1:8080" + +# IP LOCATIONS FOR INTERACTING WITH THE MINIONS +for (( i=0; i <${NUM_MINIONS}; i++)) do + KUBE_MINION_IP_ADDRESSES[$i]="127.0.0.1" +done diff --git a/cluster/local/util.sh b/cluster/local/util.sh new file mode 100644 index 0000000000000..b967fef5e0ca9 --- /dev/null +++ b/cluster/local/util.sh @@ -0,0 +1,69 @@ +#!/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. + +# A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts. + +source $(dirname ${BASH_SOURCE})/${KUBE_CONFIG_FILE-"config-default.sh"} + +function detect-master () { + echo "KUBE_MASTER_IP: $KUBE_MASTER_IP" + echo "KUBE_MASTER: $KUBE_MASTER" +} + +# Get minion IP addresses and store in KUBE_MINION_IP_ADDRESSES[] +function detect-minions { + echo "Minions already detected" +} + +# Verify prereqs on host machine +function verify-prereqs { + for x in go; do + if [ "$(which $x)" == "" ]; then + echo "Can't find $x in PATH, please fix and retry." + exit 1 + fi + done +} + +# Instantiate a kubernetes cluster +function kube-up { + echo "Not applicable" +} + +# Delete a kubernetes cluster +function kube-down { + echo "Not applicable" +} + +# Update a kubernetes cluster with latest source +function kube-push { + echo "Not applicable" +} + +# Execute prior to running tests to build a release if required for env +function test-build-release { + echo "Not applicable" +} + +# Execute prior to running tests to initialize required structure +function test-setup { + echo "Not applicable" +} + +# Execute after running tests to perform any required clean-up +function test-teardown { + echo "Not applicable" +} diff --git a/docs/getting-started-guides/locally.md b/docs/getting-started-guides/locally.md index 709d47eeb85b1..d1e21a4b5d265 100644 --- a/docs/getting-started-guides/locally.md +++ b/docs/getting-started-guides/locally.md @@ -9,4 +9,54 @@ 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. -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. +You can use the cluster/kubecfg.sh script to interact with the local cluster. + +``` +cd kubernetes +modify cluster/kube-env.sh: + KUBERNETES_PROVIDER="local" + +cluster/kubecfg.sh => interact with the local cluster +``` + +### Running a container + +Your cluster is running, and you want to start running containers! + +You can now use any of the cluster/kubecfg.sh commands to interact with your local setup. +``` +cluster/kubecfg.sh list /pods +cluster/kubecfg.sh list /services +cluster/kubecfg.sh list /replicationControllers +cluster/kubecfg.sh -p 8080:80 run dockerfile/nginx 1 myNginx + + +## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal + sudo docker images + ## you should see it pulling the dockerfile/nginx image, once the above command returns it + sudo docker ps + ## you should see your container running! + exit +## end wait + +## introspect kubernetes! +cluster/kubecfg.sh list /pods +cluster/kubecfg.sh list /services +cluster/kubecfg.sh list /replicationControllers +``` + +Congratulations! + +### Troubleshooting + +#### I cannot create a replication controller with replica size greater than 1! What gives? + +You are running a single minion setup. This has the limitation of only supporting a single replica of a given pod. If you are interested in running with larger replica sizes, we encourage you to try the local vagrant setup or one of the cloud providers. + +#### I changed Kubernetes code, how do I run it? + +``` +cd kubernetes +hack/build-go.sh +hack/local-up-cluster.sh +``` \ No newline at end of file