Mirantis/k8s-devbox

Name: k8s-devbox

Owner: Mirantis Inc.

Description: Reproducible Kubernetes development environment

Created: 2016-08-31 16:21:37.0

Updated: 2017-07-13 22:54:10.0

Pushed: 2017-05-09 22:26:23.0

Homepage:

Size: 63

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Kubernetes Development Environment

k8s-devbox provides a reproducible development environment for working on Kubernetes project.

It's currently tested on Ubuntu Xenial (x86_64) and Mac OS X 10.11.

For easy creation of local k8s clusters k8s-devbox uses kubernetes-dind-cluster tool written by Dr. Stefan Schimanski.

Demo - Mac OS X, installation using home method, DIND cluster: asciicast

Demo - Linux, installation using vagrant method, local and DIND clusters, conformance tests: asciicast

Installation

First, clone k8s-devbox repository:

clone https://github.com/mirantis/k8s-devbox.git
8s-devbox

To install the devbox in user's home directory without creating any VMs or changing configuration of the host machine, use

stall.sh home git@github.com:YOUR_GITHUB_USERNAME/kubernetes

You'll need to have Docker installed on your machine for this to work. home mode is supported on Linux and Mac OS X, but unfortunately as of now it only supports bash (zsh support is planned).

For other installation modes you need to have Ansible

= 2.1.0 installed on your machine. For Mac OS X, you'll also need to install Vagrant and VirtualBox.

In case of VM-based installation on Ubuntu, use the following command to prepare the host:

stall.sh host

or

VIRTUALBOX=1 ./install.sh host

to force the use of VirtualBox event if vagrant-libvirt plugin is installed. You may need to relogin after that.

To install using Vagrant:

stall.sh vagrant git@github.com:YOUR_GITHUB_USERNAME/kubernetes

(specify your kubernetes fork)

If you want to force use of VirtualBox for the wrapper VM on Linux, use

VIRTUALBOX=1 ./install.sh vagrant git@github.com:YOUR_GITHUB_USERNAME/kubernetes

But note that VirtualBox doesn't support nested virtualization and you will not be able to use kube-up inside your VM.

After installation, you may log into the box via

ant ssh

You can also provision a remote machine to become a k8s dev environment, but this parts needs some testing:

stall.sh remote HOSTNAME git@github.com:YOUR_GITHUB_USERNAME/kubernetes

The same goes for the local machine:

stall.sh local git@github.com:YOUR_GITHUB_USERNAME/kubernetes

You can prepend USE_VIRTUALBOX=1 to ./install.sh remote ... or ./install.sh local ... to use VirtualBox instead of libvirt for vagrant-up.

Do not invoke any of these commands as root, because they need to use your user account.

Usage

The following shortcuts are provided in the shell:


Chdir to Kubernetes source directory.

-up [quick] [N]

Bring up N-node DIND (Docker-in-Docker) cluster. quick mode can be used to start DIND cluster without rebuilding Docker images it uses. N (number of nodes) defaults to 2.

-down

Stop DIND cluster.

ant-up

Bring up a 2-node vagrant based cluster and switches to vagrant provider.

ant-down

Bring down the vagrant cluster.

_e2e

List available e2e tests

[focus]

Run e2e test(s). You can specify a filter as regular expression. If no filter (focus) is specified, the same set of e2e tests as in upstream CI is used. Note that you need to do make quick-release and start the cluster via either local-up or kube-up before you can run e2e tests. Be advised that running e2e tests against local-up cluster may be unreliable.

l-up

Bring up a local cluster using hack/local-up-cluster.sh with DNS support. You may want to use this command inside screen.

dind

Switch to using DIND cluster that's currently active.

local

Switch to 'local' provider (use with local-up). You may need to do this in every terminal session you're using to work with the local cluster.

vagrant

Switch to 'vagrant' provider.

te-kubelet

Update kubelet on vagrant-based nodes.

it [pkg] [regex]

Run unit test(s). pkg (package) and regex can be used to specify which tests to run, e.g.

it pkg/api/validation TestValidateEvent

elp

Display help on devbox commands.

“Native” k8s commands

The following commands may be useful for Kubernetes development:


Build Kubernetes binaries.

 quick-release

Build k8s release for use with kube-up.

 test

Run unit tests.

Additional notes

There must be no symlinks in the path to Kubernetes source directory as this will cause e2e test scripts to fail.

If you started kube-up without doing fix-influxdb first and e2e tests refuse to run, you can fix your vagrant cluster using following commands:


ant ssh master -- sudo rm -rf /etc/kubernetes/addons/cluster-monitoring
ctl delete --now --namespace=kube-system pod monitoring-influxdb-grafana-v3-0

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.