2014-08-04 03:44:33 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## Getting started locally
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-11-03 09:13:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### Requirements
 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-16 09:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-09-12 04:10:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#### Linux
 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-16 09:28:49 +08: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-12 04:10:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#### Docker
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								At least [Docker ](https://docs.docker.com/installation/#installation ) 1.0.0+. 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-12 04:10:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#### etcd
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-11-03 09:13:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You need an [etcd ](https://github.com/coreos/etcd/releases/tag/v0.4.6 ) in your path, please make sure it is installed and in your ``$PATH``.
							 
						 
					
						
							
								
									
										
										
										
											2014-09-12 04:10:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### Starting the cluster
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-04 03:44:33 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								In a separate tab of your terminal, run:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cd kubernetes
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								sudo hack/local-up-cluster.sh
							 
						 
					
						
							
								
									
										
										
										
											2014-08-04 03:44:33 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08: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-04 03:44:33 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-11 23:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You can use the cluster/kubecfg.sh script to interact with the local cluster.
							 
						 
					
						
							
								
									
										
										
										
											2014-11-17 06:41:27 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You must set the KUBERNETES_PROVIDER and KUBERNETES_MASTER environment variables to let other programs
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								know how to reach your master.
							 
						 
					
						
							
								
									
										
										
										
											2014-08-11 23:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2014-11-17 06:41:27 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								export KUBERNETES_PROVIDER=local
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								export KUBERNETES_MASTER=http://localhost:8080
							 
						 
					
						
							
								
									
										
										
										
											2014-08-11 23:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### 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.
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-08-11 23:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								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
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-13 11:09:20 +08: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 23:49:04 +08: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 09:28:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```