github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/getting-started-guides/locally.md (about) 1 <!-- BEGIN MUNGE: UNVERSIONED_WARNING --> 2 3 <!-- BEGIN STRIP_FOR_RELEASE --> 4 5 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 6 width="25" height="25"> 7 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 8 width="25" height="25"> 9 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 10 width="25" height="25"> 11 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 12 width="25" height="25"> 13 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 14 width="25" height="25"> 15 16 <h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2> 17 18 If you are using a released version of Kubernetes, you should 19 refer to the docs that go with that version. 20 21 <strong> 22 The latest 1.0.x release of this document can be found 23 [here](http://releases.k8s.io/release-1.0/docs/getting-started-guides/locally.md). 24 25 Documentation for other releases can be found at 26 [releases.k8s.io](http://releases.k8s.io). 27 </strong> 28 -- 29 30 <!-- END STRIP_FOR_RELEASE --> 31 32 <!-- END MUNGE: UNVERSIONED_WARNING --> 33 Getting started locally 34 ----------------------- 35 36 **Table of Contents** 37 38 - [Requirements](#requirements) 39 - [Linux](#linux) 40 - [Docker](#docker) 41 - [etcd](#etcd) 42 - [go](#go) 43 - [Starting the cluster](#starting-the-cluster) 44 - [Running a container](#running-a-container) 45 - [Running a user defined pod](#running-a-user-defined-pod) 46 - [Troubleshooting](#troubleshooting) 47 - [I cannot reach service IPs on the network.](#i-cannot-reach-service-ips-on-the-network) 48 - [I cannot create a replication controller with replica size greater than 1! What gives?](#i-cannot-create-a-replication-controller-with-replica-size-greater-than-1--what-gives) 49 - [I changed Kubernetes code, how do I run it?](#i-changed-kubernetes-code-how-do-i-run-it) 50 - [kubectl claims to start a container but `get pods` and `docker ps` don't show it.](#kubectl-claims-to-start-a-container-but-get-pods-and-docker-ps-dont-show-it) 51 - [The pods fail to connect to the services by host names](#the-pods-fail-to-connect-to-the-services-by-host-names) 52 53 ### Requirements 54 55 #### Linux 56 57 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) 58 59 #### Docker 60 61 At least [Docker](https://docs.docker.com/installation/#installation) 62 1.3+. Ensure the Docker daemon is running and can be contacted (try `docker 63 ps`). Some of the Kubernetes components need to run as root, which normally 64 works fine with docker. 65 66 #### etcd 67 68 You need an [etcd](https://github.com/coreos/etcd/releases) in your path, please make sure it is installed and in your ``$PATH``. 69 70 #### go 71 72 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``. 73 74 ### Starting the cluster 75 76 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): 77 78 ```sh 79 cd kubernetes 80 hack/local-up-cluster.sh 81 ``` 82 83 This will build and start a lightweight local cluster, consisting of a master 84 and a single node. Type Control-C to shut it down. 85 86 You can use the cluster/kubectl.sh script to interact with the local cluster. hack/local-up-cluster.sh will 87 print the commands to run to point kubectl at the local cluster. 88 89 90 ### Running a container 91 92 Your cluster is running, and you want to start running containers! 93 94 You can now use any of the cluster/kubectl.sh commands to interact with your local setup. 95 96 ```sh 97 cluster/kubectl.sh get pods 98 cluster/kubectl.sh get services 99 cluster/kubectl.sh get replicationcontrollers 100 cluster/kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80 101 102 103 ## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal 104 sudo docker images 105 ## you should see it pulling the nginx image, once the above command returns it 106 sudo docker ps 107 ## you should see your container running! 108 exit 109 ## end wait 110 111 ## introspect Kubernetes! 112 cluster/kubectl.sh get pods 113 cluster/kubectl.sh get services 114 cluster/kubectl.sh get replicationcontrollers 115 ``` 116 117 118 ### Running a user defined pod 119 120 Note the difference between a [container](../user-guide/containers.md) 121 and a [pod](../user-guide/pods.md). Since you only asked for the former, Kubernetes will create a wrapper pod for you. 122 However you cannot 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`). 123 124 You can control the specifications of a pod via a user defined manifest, and reach nginx through your browser on the port specified therein: 125 126 ```sh 127 cluster/kubectl.sh create -f docs/user-guide/pod.yaml 128 ``` 129 130 Congratulations! 131 132 ### Troubleshooting 133 134 #### I cannot reach service IPs on the network. 135 136 Some firewall software that uses iptables may not interact well with 137 kubernetes. If you have trouble around networking, try disabling any 138 firewall or other iptables-using systems, first. Also, you can check 139 if SELinux is blocking anything by running a command such as `journalctl --since yesterday | grep avc`. 140 141 By default the IP range for service cluster IPs is 10.0.*.* - depending on your 142 docker installation, this may conflict with IPs for containers. If you find 143 containers running with IPs in this range, edit hack/local-cluster-up.sh and 144 change the service-cluster-ip-range flag to something else. 145 146 #### I cannot create a replication controller with replica size greater than 1! What gives? 147 148 You are running a single node 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. 149 150 #### I changed Kubernetes code, how do I run it? 151 152 ```sh 153 cd kubernetes 154 hack/build-go.sh 155 hack/local-up-cluster.sh 156 ``` 157 158 #### kubectl claims to start a container but `get pods` and `docker ps` don't show it. 159 160 One or more of the KUbernetes daemons might've crashed. Tail the logs of each in /tmp. 161 162 #### The pods fail to connect to the services by host names 163 164 The local-up-cluster.sh script doesn't start a DNS service. Similar situation can be found [here](http://issue.k8s.io/6667). You can start a manually. Related documents can be found [here](../../cluster/addons/dns/#how-do-i-configure-it) 165 166 167 <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> 168 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/locally.md?pixel)]() 169 <!-- END MUNGE: GENERATED_ANALYTICS -->