2014-08-03 19:44:33 +00:00
## Getting started locally
2014-11-03 01:13:43 +00:00
### Requirements
2014-08-16 01:28:49 +00:00
2014-09-11 20:10:49 +00:00
#### Linux
2014-08-16 01:28:49 +00:00
Not running Linux? Consider running Linux in a local virtual machine with [Vagrant ](vagrant.md ), or on a cloud provider like [Google Compute Engine ](gce.md )
2014-09-11 20:10:49 +00:00
#### Docker
2015-02-12 22:05:26 +00:00
At least [Docker ](https://docs.docker.com/installation/#installation )
1.3+. Ensure the Docker daemon is running and can be contacted (try `docker
ps`). Some of the kubernetes components need to run as root, which normally
works fine with docker.
2014-09-11 20:10:49 +00:00
#### etcd
2015-02-14 08:48:16 +00:00
You need an [etcd ](https://github.com/coreos/etcd/releases ) in your path, please make sure it is installed and in your ``$PATH``.
2014-09-11 20:10:49 +00:00
2014-11-25 15:53:51 +00:00
#### go
2015-03-08 12:21:13 +00:00
You need [go ](https://golang.org/doc/install ) at least 1.3+ in your path, please make sure it is installed and in your ``$PATH``.
2014-11-25 15:53:51 +00:00
2014-09-11 20:10:49 +00:00
### Starting the cluster
2015-02-10 22:46:22 +00:00
In a separate tab of your terminal, run the following (since one needs sudo access to start/stop kubernetes daemons, it is easier to run the entire script as root):
2014-08-03 19:44:33 +00:00
```
cd kubernetes
2014-12-22 13:59:06 +00:00
hack/local-up-cluster.sh
2014-08-03 19:44:33 +00:00
```
2014-10-13 03:09:20 +00:00
This will build and start a lightweight local cluster, consisting of a master
and a single minion. Type Control-C to shut it down.
2014-08-03 19:44:33 +00:00
2015-02-12 23:04:00 +00:00
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.
2014-08-11 15:49:04 +00:00
### Running a container
Your cluster is running, and you want to start running containers!
2015-02-05 07:06:03 +00:00
You can now use any of the cluster/kubectl.sh commands to interact with your local setup.
2014-10-13 03:09:20 +00:00
2014-08-11 15:49:04 +00:00
```
2014-12-04 22:56:40 +00:00
cluster/kubectl.sh get pods
cluster/kubectl.sh get services
cluster/kubectl.sh get replicationControllers
2015-04-16 16:11:47 +00:00
cluster/kubectl.sh run-container my-nginx --image=nginx --replicas=2 --port=80
2014-08-11 15:49:04 +00:00
## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal
sudo docker images
2015-04-16 16:11:47 +00:00
## you should see it pulling the nginx image, once the above command returns it
2014-08-11 15:49:04 +00:00
sudo docker ps
## you should see your container running!
exit
## end wait
## introspect kubernetes!
2014-12-04 22:56:40 +00:00
cluster/kubectl.sh get pods
cluster/kubectl.sh get services
cluster/kubectl.sh get replicationControllers
2014-08-11 15:49:04 +00:00
```
2015-02-10 22:46:22 +00:00
### Running a user defined pod
2015-04-23 23:36:27 +00:00
Note the difference between a [container ](http://docs.k8s.io/containers.md )
and a [pod ](http://docs.k8s.io/pods.md ). Since you only asked for the former, kubernetes will create a wrapper pod for you.
2015-02-10 22:46:22 +00:00
However you can't view the nginx start page on localhost. To verify that nginx is running you need to run `curl` within the docker container (try `docker exec` ).
You can control the specifications of a pod via a user defined manifest, and reach nginx through your browser on the port specified therein:
```
2015-05-10 15:21:33 +00:00
cluster/kubectl.sh create -f examples/pod.yaml
2015-02-10 22:46:22 +00:00
```
2014-08-11 15:49:04 +00:00
Congratulations!
### Troubleshooting
2014-10-13 03:09:20 +00:00
#### I can't reach service IPs on the network.
Some firewall software that uses iptables may not interact well with
kubernetes. If you're having trouble around networking, try disabling any
firewall or other iptables-using systems, first.
By default the IP range for service portals is 10.0.*.* - depending on your
docker installation, this may conflict with IPs for containers. If you find
containers running with IPs in this range, edit hack/local-cluster-up.sh and
change the portal_net flag to something else.
2014-08-11 15:49:04 +00:00
#### 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
2014-08-16 01:28:49 +00:00
```
2015-02-10 22:46:22 +00:00
#### kubectl claims to start a container but `get pods` and `docker ps` don't show it.
One or more of the kubernetes daemons might've crashed. Tail the logs of each in /tmp.
2015-04-12 06:40:52 +00:00
#### The pods fail to connect to the services by host names
The local-up-cluster.sh script doesn't start a DNS service. Similar situation can be found [here ](https://github.com/GoogleCloudPlatform/kubernetes/issues/6667 ). You can start a manually. Related documents can be found [here ](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/cluster/addons/dns#how-do-i-configure-it )
2015-05-14 22:12:45 +00:00
[![Analytics ](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/locally.md?pixel )]()