github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/getting-started-guides/juju.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/juju.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 34 Getting started with Juju 35 ------------------------- 36 37 [Juju](https://jujucharms.com/docs/stable/about-juju) makes it easy to deploy 38 Kubernetes by provisioning, installing and configuring all the systems in 39 the cluster. Once deployed the cluster can easily scale up with one command 40 to increase the cluster size. 41 42 43 **Table of Contents** 44 45 - [Prerequisites](#prerequisites) 46 - [On Ubuntu](#on-ubuntu) 47 - [With Docker](#with-docker) 48 - [Launch Kubernetes cluster](#launch-kubernetes-cluster) 49 - [Exploring the cluster](#exploring-the-cluster) 50 - [Run some containers!](#run-some-containers) 51 - [Scale out cluster](#scale-out-cluster) 52 - [Launch the "k8petstore" example app](#launch-the-k8petstore-example-app) 53 - [Tear down cluster](#tear-down-cluster) 54 - [More Info](#more-info) 55 - [Cloud compatibility](#cloud-compatibility) 56 57 58 ## Prerequisites 59 60 > Note: If you're running kube-up, on Ubuntu - all of the dependencies 61 > will be handled for you. You may safely skip to the section: 62 > [Launch Kubernetes Cluster](#launch-kubernetes-cluster) 63 64 ### On Ubuntu 65 66 [Install the Juju client](https://jujucharms.com/get-started) on your 67 local Ubuntu system: 68 69 sudo add-apt-repository ppa:juju/stable 70 sudo apt-get update 71 sudo apt-get install juju-core juju-quickstart 72 73 74 ### With Docker 75 76 If you are not using Ubuntu or prefer the isolation of Docker, you may 77 run the following: 78 79 mkdir ~/.juju 80 sudo docker run -v ~/.juju:/home/ubuntu/.juju -ti jujusolutions/jujubox:latest 81 82 At this point from either path you will have access to the `juju 83 quickstart` command. 84 85 To set up the credentials for your chosen cloud run: 86 87 juju quickstart --constraints="mem=3.75G" -i 88 89 > The `constraints` flag is optional, it changes the size of virtual machines 90 > that Juju will generate when it requests a new machine. Larger machines 91 > will run faster but cost more money than smaller machines. 92 93 Follow the dialogue and choose `save` and `use`. Quickstart will now 94 bootstrap the juju root node and setup the juju web based user 95 interface. 96 97 98 ## Launch Kubernetes cluster 99 100 You will need to export the `KUBERNETES_PROVIDER` environment variable before 101 bringing up the cluster. 102 103 export KUBERNETES_PROVIDER=juju 104 cluster/kube-up.sh 105 106 If this is your first time running the `kube-up.sh` script, it will install 107 the required dependencies to get started with Juju, additionally it will 108 launch a curses based configuration utility allowing you to select your cloud 109 provider and enter the proper access credentials. 110 111 Next it will deploy the kubernetes master, etcd, 2 nodes with flannel based 112 Software Defined Networking (SDN) so containers on different hosts can 113 communicate with each other. 114 115 116 ## Exploring the cluster 117 118 The `juju status` command provides information about each unit in the cluster: 119 120 $ juju status --format=oneline 121 - docker/0: 52.4.92.78 (started) 122 - flannel-docker/0: 52.4.92.78 (started) 123 - kubernetes/0: 52.4.92.78 (started) 124 - docker/1: 52.6.104.142 (started) 125 - flannel-docker/1: 52.6.104.142 (started) 126 - kubernetes/1: 52.6.104.142 (started) 127 - etcd/0: 52.5.216.210 (started) 4001/tcp 128 - juju-gui/0: 52.5.205.174 (started) 80/tcp, 443/tcp 129 - kubernetes-master/0: 52.6.19.238 (started) 8080/tcp 130 131 You can use `juju ssh` to access any of the units: 132 133 juju ssh kubernetes-master/0 134 135 136 ## Run some containers! 137 138 `kubectl` is available on the Kubernetes master node. We'll ssh in to 139 launch some containers, but one could use `kubectl` locally by setting 140 `KUBERNETES_MASTER` to point at the ip address of "kubernetes-master/0". 141 142 No pods will be available before starting a container: 143 144 kubectl get pods 145 NAME READY STATUS RESTARTS AGE 146 147 kubectl get replicationcontrollers 148 CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS 149 150 We'll follow the aws-coreos example. Create a pod manifest: `pod.json` 151 152 ```json 153 { 154 "apiVersion": "v1", 155 "kind": "Pod", 156 "metadata": { 157 "name": "hello", 158 "labels": { 159 "name": "hello", 160 "environment": "testing" 161 } 162 }, 163 "spec": { 164 "containers": [{ 165 "name": "hello", 166 "image": "quay.io/kelseyhightower/hello", 167 "ports": [{ 168 "containerPort": 80, 169 "hostPort": 80 170 }] 171 }] 172 } 173 } 174 ``` 175 176 Create the pod with kubectl: 177 178 kubectl create -f pod.json 179 180 181 Get info on the pod: 182 183 kubectl get pods 184 185 186 To test the hello app, we need to locate which node is hosting 187 the container. Better tooling for using Juju to introspect container 188 is in the works but we can use `juju run` and `juju status` to find 189 our hello app. 190 191 Exit out of our ssh session and run: 192 193 juju run --unit kubernetes/0 "docker ps -n=1" 194 ... 195 juju run --unit kubernetes/1 "docker ps -n=1" 196 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 197 02beb61339d8 quay.io/kelseyhightower/hello:latest /hello About an hour ago Up About an hour k8s_hello.... 198 199 200 We see "kubernetes/1" has our container, we can open port 80: 201 202 juju run --unit kubernetes/1 "open-port 80" 203 juju expose kubernetes 204 sudo apt-get install curl 205 curl $(juju status --format=oneline kubernetes/1 | cut -d' ' -f3) 206 207 Finally delete the pod: 208 209 juju ssh kubernetes-master/0 210 kubectl delete pods hello 211 212 213 ## Scale out cluster 214 215 We can add node units like so: 216 217 juju add-unit docker # creates unit docker/2, kubernetes/2, docker-flannel/2 218 219 ## Launch the "k8petstore" example app 220 221 The [k8petstore example](../../examples/k8petstore/) is available as a 222 [juju action](https://jujucharms.com/docs/devel/actions). 223 224 juju action do kubernetes-master/0 225 226 > Note: this example includes curl statements to exercise the app, which 227 > automatically generates "petstore" transactions written to redis, and allows 228 > you to visualize the throughput in your browser. 229 230 ## Tear down cluster 231 232 ./kube-down.sh 233 234 or destroy your current Juju environment (using the `juju env` command): 235 236 juju destroy-environment --force `juju env` 237 238 239 ## More Info 240 241 The Kubernetes charms and bundles can be found in the `kubernetes` project on 242 github.com: 243 244 - [Bundle Repository](http://releases.k8s.io/HEAD/cluster/juju/bundles) 245 * [Kubernetes master charm](../../cluster/juju/charms/trusty/kubernetes-master/) 246 * [Kubernetes node charm](../../cluster/juju/charms/trusty/kubernetes/) 247 - [More about Juju](https://jujucharms.com) 248 249 250 ### Cloud compatibility 251 252 Juju runs natively against a variety of public cloud providers. Juju currently 253 works with [Amazon Web Service](https://jujucharms.com/docs/stable/config-aws), 254 [Windows Azure](https://jujucharms.com/docs/stable/config-azure), 255 [DigitalOcean](https://jujucharms.com/docs/stable/config-digitalocean), 256 [Google Compute Engine](https://jujucharms.com/docs/stable/config-gce), 257 [HP Public Cloud](https://jujucharms.com/docs/stable/config-hpcloud), 258 [Joyent](https://jujucharms.com/docs/stable/config-joyent), 259 [LXC](https://jujucharms.com/docs/stable/config-LXC), any 260 [OpenStack](https://jujucharms.com/docs/stable/config-openstack) deployment, 261 [Vagrant](https://jujucharms.com/docs/stable/config-vagrant), and 262 [Vmware vSphere](https://jujucharms.com/docs/stable/config-vmware). 263 264 If you do not see your favorite cloud provider listed many clouds can be 265 configured for [manual provisioning](https://jujucharms.com/docs/stable/config-manual). 266 267 The Kubernetes bundle has been tested on GCE and AWS and found to work with 268 version 1.0.0. 269 270 271 <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> 272 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/juju.md?pixel)]() 273 <!-- END MUNGE: GENERATED_ANALYTICS -->