diff --git a/docs/getting-started-guides/coreos.md b/docs/getting-started-guides/coreos.md index 535cd21313bc3..86bdc4074d0d7 100644 --- a/docs/getting-started-guides/coreos.md +++ b/docs/getting-started-guides/coreos.md @@ -8,3 +8,4 @@ There are multiple guides on running Kubernetes with [CoreOS](http://coreos.com) * [Multi-node cluster using cloud-config and Weave on Vagrant](https://github.com/errordeveloper/weave-demos/blob/master/poseidon/README.md) * [Multi-node cluster using cloud-config and Vagrant](https://github.com/pires/kubernetes-vagrant-coreos-cluster/blob/master/README.md) * [Multi-node cluster with Vagrant and fleet units using a small OS X App](https://github.com/rimusz/coreos-osx-gui-kubernetes-cluster/blob/master/README.md) +* [Resizable multi-node cluster on Azure with Weave](coreos/azure/README.md) diff --git a/docs/getting-started-guides/coreos/azure/.gitignore b/docs/getting-started-guides/coreos/azure/.gitignore index 799dcb3f210c8..c2658d7d1b318 100644 --- a/docs/getting-started-guides/coreos/azure/.gitignore +++ b/docs/getting-started-guides/coreos/azure/.gitignore @@ -1,2 +1 @@ node_modules/ -output/* diff --git a/docs/getting-started-guides/coreos/azure/README.md b/docs/getting-started-guides/coreos/azure/README.md index 6e09e9e3d778e..3071c1d0b56b4 100644 --- a/docs/getting-started-guides/coreos/azure/README.md +++ b/docs/getting-started-guides/coreos/azure/README.md @@ -1,24 +1,20 @@ ---- -published: false -title: Weaving Kubernetes on Azure -tags: azure, coreos, kubernetes, usecase, guide, redis, php, cloud, provisioning ---- +# Kubernetes on Azure with CoreOS and [Weave](http://weave.works) ## Introduction -In this tutorial we will demonstrate how to deploy a Kubernetes cluster to Azure cloud. Weave makes networking of containers simple and secure, in a transparent, yet robust way. The focus of this tutorial is provide an out-of-the-box production-ready implementation with dedicated Kubernetes master and etcd nodes. It will also show how to scale the cluster with ease. +In this guide I will demonstrate how to deploy a Kubernetes cluster to Azure cloud. You will be using CoreOS with Weave, which implements simple and secure networking, in a transparent, yet robust way. The purpose of this guide is to provide an out-of-the-box implementation that can ultimately be taken into production with little change. It will demonstrate how to provision a dedicated Kubernetes master and etcd nodes, and show how to scale the cluster with ease. ## Let's go! -To get started, you need to checkout the code: +To get started, you need to checkout the code: ``` -git clone https://github.com/errordeveloper/weave-demos -cd weave-demos/coreos-azure +git clone https://github.com/GoogleCloudPlatform/kubernetes +cd kubernetes/docs/getting-started-guides/coreos/azure/ ``` You will need to have [Node.js installed](http://nodejs.org/download/) on you machine. If you have previously used Azure CLI, you should have it already. -You first need to install some of the dependencies with +First, you need to install some of the dependencies with ``` npm install @@ -31,9 +27,9 @@ Now, all you need to do is: ./create-kubernetes-cluster.js ``` -This script will provision a cluster suitable for production use, where there is a ring of 3 dedicated etcd nodes, Kubernetes master and 2 minions. The `kube-00` VM will be the master, your work loads are only to be deployed on the minion nodes, `kube-01` and `kube-02`. Initially, all VMs are single-core, to ensure a user of the free tier can reproduce it without paying extra. Later we will show how to add more bigger VMs. +This script will provision a cluster suitable for production use, where there is a ring of 3 dedicated etcd nodes, Kubernetes master and 2 minions. The `kube-00` VM will be the master, your work loads are only to be deployed on the minion nodes, `kube-01` and `kube-02`. Initially, all VMs are single-core, to ensure a user of the free tier can reproduce it without paying extra. I will show how to add more bigger VMs later. -![VMs in Azure](https://www.dropbox.com/s/logk4mot2gnlxgn/Screenshot%202015-02-15%2015.54.45.png?dl=1) +![VMs in Azure](initial_cluster.png) Once the creation of Azure VMs has finished, you should see the following: @@ -91,7 +87,7 @@ redis-master 10.2.1.4 master dockerfile/ ## Scaling -Two single-core minions are certainly not enough for a production system of today, and, as you can see we have one _unassigned_ pod. Let's resize the cluster by adding a couple of bigger nodes. +Two single-core minions are certainly not enough for a production system of today, and, as you can see, there is one _unassigned_ pod. Let's resize the cluster by adding a couple of bigger nodes. You will need to open another terminal window on your machine and go to the same working directory (e.g. `~/Workspace/weave-demos/coreos-azure`). @@ -127,7 +123,7 @@ kube-03 environment=production Ready kube-04 environment=production Ready ``` -We can see that two more minions joined happily. Let's resize the number of Guestbook instances we have. +You can see that two more minions joined happily. Let's resize the number of Guestbook instances now. First, double-check how many replication controllers there are: @@ -137,14 +133,14 @@ CONTROLLER CONTAINER(S) IMAGE(S) S frontendController php-redis kubernetes/example-guestbook-php-redis name=frontend 3 redisSlaveController slave brendanburns/redis-slave name=redisslave 2 ``` -As we have 4 minions, let's resize proportionally: +As there are 4 minions, let's resize proportionally: ``` core@kube-00 ~ $ kubectl resize --replicas=4 rc redisSlaveController resized core@kube-00 ~ $ kubectl resize --replicas=4 rc frontendController resized ``` -Check what we have now: +Check what you have now: ``` kubectl get rc CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS @@ -152,7 +148,7 @@ frontendController php-redis kubernetes/example-guestbook-php-redis n redisSlaveController slave brendanburns/redis-slave name=redisslave 4 ``` -You now will have more instances of front-end Guestbook apps and Redis slaves; and, if we look up all pods labled `name=frontend`, we should see one running on each node. +You now will have more instances of front-end Guestbook apps and Redis slaves; and, if you look up all pods labled `name=frontend`, you should see one running on each node. ``` core@kube-00 ~/guestbook-example $ kubectl get pods -l name=frontend @@ -165,18 +161,26 @@ ae59fa80-b679-11e4-b6f6-000d3a20a034 10.2.4.5 php-redis kubernete ## Exposing the app to the outside world -To makes sure the app is working, we should load it in the browser. For accessing the Guesbook service from the outside world, I had to create an Azure endpoint like shown on the picture below. +To makes sure the app is working, you probably want to load it in the browser. For accessing the Guesbook service from the outside world, an Azure endpoint needs to be created like shown on the picture below. + +![Creating an endpoint](external_access.png) + +You then should be able to access it from anywhere via the Azure virtual IP for `kube-01`, i.e. `http://104.40.211.194:8000/` as per screenshot. + +## Next steps + +You now have a full-blow cluster running in Azure, congrats! -![VMs in Azure](https://www.dropbox.com/s/a7gglyamb9pltqn/Screenshot%202015-02-15%2016.02.32.png?dl=1) +You should probably try deploy other [example apps](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples) or write your own ;) -I was then able to access it from anywhere via the Azure virtual IP for `kube-01`, i.e. `http://104.40.211.194:8000/`. +## Tear down... -## Destructing the VMs +If you don't wish care about the Azure bill, you can tear down the cluster. It's easy to redeploy it, as you can see. -To delete the cluster run this: ``` ./destroy-cluster.js ./output/kubernetes_8f984af944f572_deployment.yml ``` -Make sure to use the latest state file, as after resizing there is a new one. By the way, with the scripts shown, you can deploy multiple clusters, if you like :) +> Note: make sure to use the _latest state file_, as after resizing there is a new one. +By the way, with the scripts shown, you can deploy multiple clusters, if you like :) diff --git a/docs/getting-started-guides/coreos/azure/cloud_config_templates/basic-weave-cluster-template.yml b/docs/getting-started-guides/coreos/azure/cloud_config_templates/basic-weave-cluster-template.yml deleted file mode 100644 index d5440db769965..0000000000000 --- a/docs/getting-started-guides/coreos/azure/cloud_config_templates/basic-weave-cluster-template.yml +++ /dev/null @@ -1,73 +0,0 @@ -## This file is used as input to deployment script, which ammends it as needed. -## More specifically, we need to add environment files for as many nodes as we -## are going to deploy. - -coreos: - units: - - name: dhcpcd.service - enable: true - command: start - - - name: systemd-resolved.service - command: stop - - - name: 10-weave.network - runtime: false - content: | - [Match] - Type=bridge - Name=weave* - [Network] - - - name: weave.service - content: | - [Unit] - After=install-weave.service - Description=Weave Network - Documentation=http://zettio.github.io/weave/ - Requires=install-weave.service - [Service] - EnvironmentFile=/etc/weave.%H.env - ExecStartPre=/opt/bin/weave launch $WEAVE_PEERS - ExecStartPre=/opt/bin/weave launch-dns $WEAVEDNS_ADDR - ExecStart=/usr/bin/docker attach weave - Restart=on-failure - ExecStop=/opt/bin/weave stop - ExecStop=/opt/bin/weave stop-dns - - - name: install-weave.service - command: start - enable: true - content: | - [Unit] - After=network-online.target - After=docker.service - Description=Install Weave - Documentation=http://zettio.github.io/weave/ - Requires=network-online.target - Requires=docker.service - [Service] - Type=oneshot - RemainAfterExit=yes - ExecStartPre=/usr/bin/docker pull zettio/weave:latest - ExecStartPre=/usr/bin/docker pull zettio/weavedns:latest - ExecStartPre=/usr/bin/docker pull zettio/weavetools:latest - ExecStartPre=/bin/mkdir -p /opt/bin/ - ExecStartPre=/usr/bin/curl \ - --silent \ - --location \ - https://github.com/zettio/weave/releases/download/latest_release/weave \ - --output /opt/bin/weave - ExecStartPre=/usr/bin/chmod +x /opt/bin/weave - ExecStart=/bin/echo Weave Installed - - - name: weave-network.target - command: start - enable: true - content: | - [Unit] - Requires=weave.service - RefuseManualStart=no - Wants=weave.service - [Install] - WantedBy=multi-user.target diff --git a/docs/getting-started-guides/coreos/azure/create-basic-weave-cluster.js b/docs/getting-started-guides/coreos/azure/create-basic-weave-cluster.js deleted file mode 100755 index bc5dca6c413d8..0000000000000 --- a/docs/getting-started-guides/coreos/azure/create-basic-weave-cluster.js +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node - -var azure = require('./lib/azure_wrapper.js'); -var weave = require('./lib/deployment_logic/weave.js'); - -azure.create_config('weave-cluster-example', { 'core': 3 }); - -azure.run_task_queue([ - azure.queue_default_network(), - azure.queue_machines('core', 'stable', - weave.create_basic_cloud_config), -]); diff --git a/docs/getting-started-guides/coreos/azure/external_access.png b/docs/getting-started-guides/coreos/azure/external_access.png new file mode 100644 index 0000000000000..6541309b0ac87 Binary files /dev/null and b/docs/getting-started-guides/coreos/azure/external_access.png differ diff --git a/docs/getting-started-guides/coreos/azure/initial_cluster.png b/docs/getting-started-guides/coreos/azure/initial_cluster.png new file mode 100644 index 0000000000000..99646a3fd06ec Binary files /dev/null and b/docs/getting-started-guides/coreos/azure/initial_cluster.png differ diff --git a/docs/getting-started-guides/coreos/azure/lib/deployment_logic/weave.js b/docs/getting-started-guides/coreos/azure/lib/deployment_logic/weave.js deleted file mode 100644 index 9f5abb465d9a3..0000000000000 --- a/docs/getting-started-guides/coreos/azure/lib/deployment_logic/weave.js +++ /dev/null @@ -1,29 +0,0 @@ -var _ = require('underscore'); - -var util = require('../util.js'); -var cloud_config = require('../cloud_config.js'); - -var write_basic_weave_cluster_cloud_config = function (env_files) { - var input_file = './cloud_config_templates/basic-weave-cluster-template.yml'; - var output_file = util.join_output_file_path('basic-weave-cluster', 'generated.yml'); - - return cloud_config.process_template(input_file, output_file, function(data) { - data.write_files = env_files; - return data; - }); -}; - -exports.create_basic_cloud_config = function (node_count, conf) { - var elected_node = 0; - - var make_node_config = function (n) { - return cloud_config.generate_environment_file_entry_from_object(util.hostname(n), { - weavedns_addr: util.ipv4([10, 10, 1, 10+n], 24), - weave_password: conf.weave_salt, - weave_peers: n === elected_node ? "" : util.hostname(elected_node), - }); - }; - - return write_basic_weave_cluster_cloud_config(_(node_count).times(make_node_config)); -}; - diff --git a/docs/getting-started-guides/coreos/azure/output/.gitignore b/docs/getting-started-guides/coreos/azure/output/.gitignore new file mode 100644 index 0000000000000..72e8ffc0db8aa --- /dev/null +++ b/docs/getting-started-guides/coreos/azure/output/.gitignore @@ -0,0 +1 @@ +*