2016-02-24 21:47:57 +00:00
|
|
|
---
|
|
|
|
---
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
[Juju](https://jujucharms.com/docs/2.0/about-juju) encapsulates the
|
|
|
|
operational knowledge of provisioning, installing, and securing a Kubernetes
|
|
|
|
cluster into one step. Juju allows you to consistently deploy a cluster on
|
|
|
|
different cloud providers with a consistent repeatable open source operations.
|
|
|
|
Once deployed the cluster can easily scale up with one command to increase the
|
|
|
|
cluster size.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-03-29 21:17:36 +00:00
|
|
|
The Juju Kubernetes work is curated by a very small group of community members.
|
|
|
|
Let us know how we are doing. If you find any problems please open an
|
|
|
|
[issue at the kubernetes project](https://github.com/kubernetes/kubernetes/issues)
|
|
|
|
and tag the issue with "juju" so we can find them.
|
|
|
|
|
|
|
|
|
2016-02-26 11:54:48 +00:00
|
|
|
* TOC
|
2016-03-07 02:29:06 +00:00
|
|
|
{:toc}
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
> Note: If you're running kube-up, on Ubuntu - all of the dependencies
|
|
|
|
> will be handled for you. You may safely skip to the section:
|
2016-03-30 13:38:23 +00:00
|
|
|
> [Launch a Kubernetes Cluster](#launch-a-kubernetes-cluster)
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
### On Ubuntu
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
[Install the Juju client](https://jujucharms.com/docs/2.0/getting-started-general)
|
2016-03-29 14:54:35 +00:00
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
> This documentation focuses on the Juju 2.0 release which will be
|
|
|
|
> promoted to stable during the April 2016 release cycle.
|
2016-03-29 14:54:35 +00:00
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
To paraphrase, on your local Ubuntu system:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-03-29 14:54:35 +00:00
|
|
|
sudo add-apt-repository ppa:juju/devel
|
2016-03-07 02:29:06 +00:00
|
|
|
sudo apt-get update
|
2016-07-27 22:55:34 +00:00
|
|
|
sudo apt-get install juju
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-03-29 14:54:35 +00:00
|
|
|
If you are using another distro/platform - please consult the
|
2016-07-27 22:55:34 +00:00
|
|
|
[getting started guide](https://jujucharms.com/docs/2.0/getting-started-general)
|
|
|
|
to install the Juju dependencies for your platform.
|
2016-03-29 14:54:35 +00:00
|
|
|
|
2016-03-07 02:29:06 +00:00
|
|
|
### With Docker
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
If you prefer the isolation of Docker, you can run the Juju client in a
|
|
|
|
container. Create a local directory to store the Juju configuration, then
|
|
|
|
volume mount the container:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
mkdir -p $HOME/.local/share/juju
|
|
|
|
docker run --rm -ti \
|
|
|
|
-v $HOME/.local/share/juju:/home/ubuntu/.local/share/juju \
|
|
|
|
jujusolutions/charmbox:devel
|
|
|
|
```
|
2016-03-29 16:12:14 +00:00
|
|
|
|
2016-03-29 14:54:35 +00:00
|
|
|
> While this is a common target, the charmbox flavors of images are
|
2016-03-30 13:38:23 +00:00
|
|
|
> unofficial, and should be treated as experimental. If you encounter any issues
|
2016-03-29 14:54:35 +00:00
|
|
|
> turning up the Kubernetes cluster with charmbox, please file a bug on the
|
2016-03-30 13:38:23 +00:00
|
|
|
> [charmbox issue tracker](https://github.com/juju-solutions/charmbox/issues).
|
2016-03-29 14:54:35 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
### Configure Juju to your favorite cloud provider
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-03-29 21:17:36 +00:00
|
|
|
At this point you have access to the Juju client. Before you can deploy a
|
2016-07-27 22:55:34 +00:00
|
|
|
cluster you have to configure Juju with the
|
|
|
|
[cloud credentials](https://jujucharms.com/docs/2.0/credentials) for each
|
|
|
|
cloud provider you would like to use.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Juju [supports a wide variety of public clouds](#cloud-compatibility) to set
|
2016-03-29 21:17:36 +00:00
|
|
|
up the credentials for your chosen cloud see the
|
2016-07-27 22:55:34 +00:00
|
|
|
[cloud setup page](https://jujucharms.com/docs/devel/getting-started-general#2.-choose-a-cloud).
|
2016-03-29 16:12:14 +00:00
|
|
|
|
|
|
|
After configuration is complete test your setup with a `juju bootstrap`
|
2016-07-27 22:55:34 +00:00
|
|
|
command: `juju bootstrap $controllername $cloudtype` you are ready to launch
|
|
|
|
the Kubernetes cluster.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
## Launch a Kubernetes cluster
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
You can deploy a Kubernetes cluster with Juju from the `kubernetes` directory of
|
|
|
|
the [kubernetes github project](https://github.com/kubernetes/kubernetes.git).
|
|
|
|
Clone the repository on your local system. Export the `KUBERNETES_PROVIDER`
|
|
|
|
environment variable before bringing up the cluster.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-07-27 22:55:34 +00:00
|
|
|
cd kubernetes
|
2016-03-07 02:29:06 +00:00
|
|
|
export KUBERNETES_PROVIDER=juju
|
2016-02-26 11:54:48 +00:00
|
|
|
cluster/kube-up.sh
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-03-29 14:54:35 +00:00
|
|
|
If this is your first time running the `kube-up.sh` script, it will attempt to
|
|
|
|
install the required dependencies to get started with Juju.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
The script will deploy two nodes of kubernetes, 1 unit of etcd, and network
|
2016-03-30 13:38:23 +00:00
|
|
|
the units so containers on different hosts can communicate with each other.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
## Exploring the cluster
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
The `juju status` command provides information about each unit in the cluster:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-03-29 16:12:14 +00:00
|
|
|
$ juju status
|
2016-07-27 22:55:34 +00:00
|
|
|
MODEL CONTROLLER CLOUD/REGION VERSION
|
|
|
|
default windows azure/centralus 2.0-beta13
|
|
|
|
|
|
|
|
APP VERSION STATUS EXPOSED ORIGIN CHARM REV OS
|
|
|
|
etcd active false jujucharms etcd 3 ubuntu
|
|
|
|
kubernetes active true jujucharms kubernetes 5 ubuntu
|
|
|
|
|
|
|
|
RELATION PROVIDES CONSUMES TYPE
|
|
|
|
cluster etcd etcd peer
|
|
|
|
etcd etcd kubernetes regular
|
|
|
|
certificates kubernetes kubernetes peer
|
|
|
|
|
|
|
|
UNIT WORKLOAD AGENT MACHINE PORTS PUBLIC-ADDRESS MESSAGE
|
|
|
|
etcd/0 active idle 0 2379/tcp 13.67.217.11 (leader) cluster is healthy
|
|
|
|
kubernetes/0 active idle 1 8088/tcp 13.67.219.76 Kubernetes running.
|
|
|
|
kubernetes/1 active idle 2 6443/tcp 13.67.219.182 (master) Kubernetes running.
|
|
|
|
|
|
|
|
MACHINE STATE DNS INS-ID SERIES AZ
|
|
|
|
0 started 13.67.217.11 machine-0 trusty
|
|
|
|
1 started 13.67.219.76 machine-1 trusty
|
|
|
|
2 started 13.67.219.182 machine-2 trusty
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-03-29 14:54:35 +00:00
|
|
|
## Run some containers!
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
The `kubectl` file, and the TLS certificates along with the configuration are
|
|
|
|
all available on the Kubernetes master unit. Fetch the kubectl package so you
|
2016-03-29 16:12:14 +00:00
|
|
|
can run commands on the new Kuberntetes cluster.
|
2016-03-29 14:54:35 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Use the `juju status` command to figure out which unit is the master. In the
|
|
|
|
example above the "kubernetes/1" unit is the master. Use the `juju scp`
|
|
|
|
command to copy the file from the unit:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-03-29 14:54:35 +00:00
|
|
|
juju scp kubernetes/1:kubectl_package.tar.gz .
|
|
|
|
tar xvfz kubectl_package.tar.gz
|
2016-07-27 22:55:34 +00:00
|
|
|
./kubectl --kubeconfig kubeconfig get pods
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-03-29 16:12:14 +00:00
|
|
|
If you are not on a Linux amd64 host system, you will need to find or build a
|
|
|
|
kubectl binary package for your architecture.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Copy the `kubeconfig` file to the home directory so you don't have to specify
|
|
|
|
it on the command line each time. The default location is
|
|
|
|
`${HOME}/.kube/config`.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
No pods will be available before starting a container:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
kubectl get pods
|
|
|
|
NAME READY STATUSRESTARTS AGE
|
|
|
|
|
|
|
|
kubectl get replicationcontrollers
|
2016-02-26 11:54:48 +00:00
|
|
|
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
We'll follow the aws-coreos example. Create a pod manifest: `pod.json`
|
|
|
|
|
2016-02-26 11:54:48 +00:00
|
|
|
```json
|
2016-03-07 02:29:06 +00:00
|
|
|
{
|
|
|
|
"apiVersion": "v1",
|
|
|
|
"kind": "Pod",
|
|
|
|
"metadata": {
|
|
|
|
"name": "hello",
|
|
|
|
"labels": {
|
|
|
|
"name": "hello",
|
|
|
|
"environment": "testing"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"spec": {
|
|
|
|
"containers": [{
|
|
|
|
"name": "hello",
|
|
|
|
"image": "quay.io/kelseyhightower/hello",
|
|
|
|
"ports": [{
|
|
|
|
"containerPort": 80,
|
|
|
|
"hostPort": 80
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
Create the pod with kubectl:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
kubectl create -f pod.json
|
|
|
|
```
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
Get info on the pod:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
kubectl get pods
|
|
|
|
```
|
|
|
|
|
|
|
|
To test the hello app, we need to locate which node is hosting
|
2016-03-29 16:12:14 +00:00
|
|
|
the container. We can use `juju run` and `juju status` commands to find
|
2016-03-07 02:29:06 +00:00
|
|
|
our hello app.
|
|
|
|
|
|
|
|
Exit out of our ssh session and run:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
juju run --unit kubernetes/0 "docker ps -n=1"
|
|
|
|
...
|
|
|
|
juju run --unit kubernetes/1 "docker ps -n=1"
|
|
|
|
CONTAINER IDIMAGE COMMAND CREATED STATUS PORTS NAMES
|
|
|
|
02beb61339d8quay.io/kelseyhightower/hello:latest /hello About an hour ago Up About an hourk8s_hello....
|
|
|
|
```
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
We see "kubernetes/1" has our container, expose the kubernetes charm and open
|
|
|
|
port 80:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
juju run --unit kubernetes/1 "open-port 80"
|
|
|
|
juju expose kubernetes
|
|
|
|
sudo apt-get install curl
|
|
|
|
curl $(juju status --format=oneline kubernetes/1 | cut -d' ' -f3)
|
|
|
|
```
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
Finally delete the pod:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-03-29 14:54:35 +00:00
|
|
|
juju ssh kubernetes/0
|
2016-03-07 02:29:06 +00:00
|
|
|
kubectl delete pods hello
|
|
|
|
```
|
2016-07-27 22:55:34 +00:00
|
|
|
|
2016-03-29 21:17:36 +00:00
|
|
|
## Scale up cluster
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
Want larger Kubernetes nodes? It is easy to request different sizes of cloud
|
2016-03-29 21:17:36 +00:00
|
|
|
resources from Juju by using **constraints**. You can increase the amount of
|
|
|
|
CPU or memory (RAM) in any of the systems requested by Juju. This allows you
|
2016-03-30 13:38:23 +00:00
|
|
|
to fine tune th Kubernetes cluster to fit your workload. Use flags on the
|
|
|
|
bootstrap command or as a separate `juju constraints` command. Look to the
|
2016-07-27 22:55:34 +00:00
|
|
|
[Juju documentation for machine](https://jujucharms.com/docs/2.0/charms-constraints)
|
2016-03-30 13:38:23 +00:00
|
|
|
details.
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
## Scale out cluster
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Need more workers? Juju makes it easy to add units of a charm:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
|
|
|
```shell
|
2016-03-29 14:54:35 +00:00
|
|
|
juju add-unit kubernetes
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-03-30 13:38:23 +00:00
|
|
|
Or multiple units at one time:
|
2016-03-29 16:12:14 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
juju add-unit -n3 kubernetes
|
|
|
|
```
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
You can also scale the etcd charm for more fault tolerant key/value storage:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
juju add-unit -n2 etcd
|
|
|
|
```
|
|
|
|
|
2016-03-07 02:29:06 +00:00
|
|
|
## Tear down cluster
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
We recommend that you use the `kube-down.sh` script when you are done using
|
2016-03-29 16:12:14 +00:00
|
|
|
the cluster, as it properly brings down the cloud and removes some of the
|
|
|
|
build directories.
|
|
|
|
|
2016-03-07 02:29:06 +00:00
|
|
|
```shell
|
2016-07-27 22:55:34 +00:00
|
|
|
./cluster/kube-down.sh
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Alternately if you want stop the servers you can destroy the Juju model or the
|
|
|
|
controller. Use the `juju switch` command to get the current controller name:
|
2016-02-26 11:54:48 +00:00
|
|
|
|
2016-03-07 02:29:06 +00:00
|
|
|
```shell
|
2016-07-27 22:55:34 +00:00
|
|
|
juju switch
|
|
|
|
juju destroy-controller $controllername
|
2016-03-07 02:29:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## More Info
|
|
|
|
|
2016-03-29 16:28:14 +00:00
|
|
|
Juju works with charms and bundles to deploy solutions. The code that stands up
|
|
|
|
a Kubernetes cluster is done in the charm code. The charm is built from using
|
|
|
|
a layered approach to keep the code smaller and more focused on the operations
|
|
|
|
of Kubernetes.
|
|
|
|
|
|
|
|
The Kubernetes layer and bundles can be found in the `kubernetes`
|
2016-03-30 13:38:23 +00:00
|
|
|
project on github.com:
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-03-29 16:28:14 +00:00
|
|
|
- [Bundle location](https://github.com/kubernetes/kubernetes/tree/master/cluster/juju/bundles)
|
|
|
|
- [Kubernetes charm layer location](https://github.com/kubernetes/kubernetes/tree/master/cluster/juju/layers/kubernetes)
|
2016-03-07 02:29:06 +00:00
|
|
|
- [More about Juju](https://jujucharms.com)
|
|
|
|
|
|
|
|
|
|
|
|
### Cloud compatibility
|
|
|
|
|
2016-07-27 22:55:34 +00:00
|
|
|
Juju is cloud agnostic and gives you a consistent experience across different
|
|
|
|
cloud providers. Juju supports a variety of public cloud providers: [Amazon Web Service](https://jujucharms.com/docs/2.0/help-aws),
|
|
|
|
[Microsoft Azure](https://jujucharms.com/docs/2.0/help-azure),
|
|
|
|
[Google Compute Engine](https://jujucharms.com/docs/2.0/help-google),
|
|
|
|
[Joyent](https://jujucharms.com/docs/2.0/help-joyent),
|
|
|
|
[Rackspace](https://jujucharms.com/docs/2.0/help-rackspace), any
|
|
|
|
[OpenStack cloud](https://jujucharms.com/docs/2.0/clouds#specifying-additional-clouds),
|
|
|
|
and
|
|
|
|
[Vmware vSphere](https://jujucharms.com/docs/2.0/config-vmware).
|
2016-03-07 02:29:06 +00:00
|
|
|
|
2016-03-29 16:28:14 +00:00
|
|
|
If you do not see your favorite cloud provider listed many clouds with ssh
|
|
|
|
access can be configured for
|
2016-07-27 22:55:34 +00:00
|
|
|
[manual provisioning](https://jujucharms.com/docs/2.0/clouds-manual).
|
|
|
|
|
|
|
|
There are three special types of clouds: MAAS, LXD and Manual.
|
|
|
|
|
|
|
|
- [LXD](https://jujucharms.com/docs/2.0/clouds-LXD): Is a system level
|
|
|
|
container technology that is extremely fast and less overhead than
|
|
|
|
traditional virutalization.
|
|
|
|
[LXD is a container hypervisor](http://www.ubuntu.com/cloud/lxd)
|
|
|
|
that runs on any Linux host, providing the ability to spin up system
|
|
|
|
containers on the host machine. **Note** that at this time nested
|
|
|
|
containerization of Docker inside LXD is not supported, so you can not spin
|
|
|
|
up a Kubernetes cluster on LXD. For more details on using LXD, please see the
|
|
|
|
[LXD documentation](https://jujucharms.com/docs/2.0/clouds-LXD).
|
|
|
|
|
|
|
|
- [MAAS](https://jujucharms.com/docs/2.0/clouds-maas): An acronym of Metal As
|
|
|
|
A Service, MAAS lets you treat physical servers like virtual machines in the
|
|
|
|
cloud. Rather than having to manage each server individually, MAAS turns your
|
|
|
|
bare metal into an elastic cloud-like resource. There is more information on
|
|
|
|
MAAS at the [MAAS website](http://maas.io/), and detailed instructions on
|
|
|
|
[using MAAS with Juju here](https://jujucharms.com/docs/2.0/clouds-maas).
|
|
|
|
|
|
|
|
- [Manual](https://jujucharms.com/docs/2.0/clouds-manual): There may be
|
|
|
|
occasions where you can bring up machines for Juju to use which are not part
|
|
|
|
of a recognized public cloud or do not support other protocols used by Juju.
|
|
|
|
As long as you have SSH access to these machines, you can get part of the
|
|
|
|
Juju magic and deploy applications.
|
|
|
|
|
|
|
|
To change to a different cloud you can use the `juju switch` command and set
|
|
|
|
up the credentials for that cloud provider and continue to use the `kubeup.sh`
|
|
|
|
script.
|
2016-05-22 22:23:47 +00:00
|
|
|
|
|
|
|
## Support Level
|
|
|
|
|
|
|
|
|
|
|
|
IaaS Provider | Config. Mgmt | OS | Networking | Docs | Conforms | Support Level
|
|
|
|
-------------------- | ------------ | ------ | ---------- | --------------------------------------------- | ---------| ----------------------------
|
2016-07-27 22:55:34 +00:00
|
|
|
Amazon Web Services (AWS) | Juju | Ubuntu | flannel | [docs](/docs/getting-started-guides/juju) | | [Community](https://github.com/juju-solutions/bundle-kubernetes-core) ( [@mbruzek](https://github.com/mbruzek), [@chuckbutler](https://github.com/chuckbutler) )
|
|
|
|
OpenStack | Juju | Ubuntu | flannel | [docs](/docs/getting-started-guides/juju) | | [Community](https://github.com/juju-solutions/bundle-kubernetes-core) ( [@mbruzek](https://github.com/mbruzek), [@chuckbutler](https://github.com/chuckbutler) )
|
|
|
|
Microsoft Azure | Juju | Ubuntu | flannel | [docs](/docs/getting-started-guides/juju) | | [Community](https://github.com/juju-solutions/bundle-kubernetes-core) ( [@mbruzek](https://github.com/mbruzek), [@chuckbutler](https://github.com/chuckbutler) )
|
|
|
|
Google Compute Engine (GCE) | Juju | Ubuntu | flannel | [docs](/docs/getting-started-guides/juju) | | [Community](https://github.com/juju-solutions/bundle-kubernetes-core) ( [@mbruzek](https://github.com/mbruzek), [@chuckbutler](https://github.com/chuckbutler) )
|
2016-05-22 22:23:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
For support level information on all solutions, see the [Table of solutions](/docs/getting-started-guides/#table-of-solutions) chart.
|