Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickstart #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ virtualenv -p python3 $HOME/kubeyard-venv
pip install kubeyard
echo '. $HOME/kubeyard-venv/bin/activate' >> $HOME/.bashrc
```

## Quickstart

See [./docs/quickstart.md](https://github.com/socialwifi/kubeyard/blob/master/docs/quickstart.md)
80 changes: 80 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Quickstart

We will setup a simple django app using kubeyard built-in template.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this document into quickstart_django.md or I would write down here that apart django there are other possibilities like flask.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not django specific quickstart docs. Django is only app, but we want to explain how to setup kubeyard environment.


**IMPORTANT:** Kubeyard uses docker as "VM" driver, so many containers will be created on your host to create minikube cluster.

## Requirements:

- docker - [install guide](https://docs.docker.com/install/linux/docker-ce/ubuntu/) and [setup guide](https://docs.docker.com/install/linux/linux-postinstall/)
- minikube - [install guide](https://kubernetes.io/docs/tasks/tools/install-minikube/#linux)
- kubectl - [install guide](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-binary-using-curl)

## Optional requirements:

- some kind of virtual environment for kubeyard (recommended)

## Setup guide

First, we need to setup kubeyard:

```bash
pip install kubeyard
kubeyard # you can see available commands
kubeyard install-bash-completion # optional, gives you bash completion for kubeyard
kubeyard setup --development
kubeyard install-global-secrets
```

It may take about 10 minutes (or even more - it depends on your internet
connection - minikube needs to download docker images for the k8s cluster)
to setup cluster. Next run will be significantly faster.

_If you have a problem with minikube setup, please check if all ports required are available (1-32767)._

Now, we are ready to setup project from the template!

```bash
mkdir simple_django
cd simple_django/
kubeyard init --template django
```

Kubeyard will ask you about some project details. You can leave default values for now.
Now you can see the project structure:

- **config**
- kubeyard.yml - project-level configuration file for kubeyard
- kubernetes/
- deploy/ - all definition files used to deploy application on cluster
- development_overrides/ - files that overrides values from deploy/ directory. Used only in `development` mode
- dev_secrets/ - development secrets files. Used only in `development` mode
- **docker** - all files that will be in docker image such as:
- Dockerfile - dockerfile based on python package image (many `ON BUILD` automagic).
- requirements/ - all (compiled) requirements. In our example only python requirements.
- source - application sources
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any django-specific directories/files layout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All app files are located inside source directory, we don't care about framework directories layout

- **scripts** - empty directory, used to override or add project-specific commands to kubeyard (we don't do that in quickstart guide)


Ok, lets build project image:
```bash
kubeyard build
```
Kubeyard can automatically build images and add a tag. For the development environment, it will be `:dev`.

We can run test inside image:
```bash
kubeyard test
```

If everything is fine, we can do the most important part - application deployment.

```bash
kubeyard deploy
```

You will be asked for sudo password.
Kubeyard needs it to configure /etc/hosts and make your service accessible via domain.

Now your first application is deployed on k8s cluster! You can access it using
http://simple-django.testing