Giter Club home page Giter Club logo

k8s-devbox's Introduction

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:

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

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

./install.sh home [email protected]: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:

./install.sh host

or

USE_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:

./install.sh vagrant [email protected]:YOUR_GITHUB_USERNAME/kubernetes

(specify your kubernetes fork)

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

USE_VIRTUALBOX=1 ./install.sh vagrant [email protected]: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

vagrant ssh

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

./install.sh remote HOSTNAME [email protected]:YOUR_GITHUB_USERNAME/kubernetes

The same goes for the local machine:

./install.sh local [email protected]: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:

cdk

Chdir to Kubernetes source directory.

dind-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.

dind-down

Stop DIND cluster.

vagrant-up

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

vagrant-down

Bring down the vagrant cluster.

list_e2e

List available e2e tests

e2e [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.

local-up

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

use-dind

Switch to using DIND cluster that's currently active.

use-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.

use-vagrant

Switch to 'vagrant' provider.

update-kubelet

Update kubelet on vagrant-based nodes.

testit [pkg] [regex]

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

testit pkg/api/validation TestValidateEvent
devhelp

Display help on devbox commands.

"Native" k8s commands

The following commands may be useful for Kubernetes development:

make

Build Kubernetes binaries.

make quick-release

Build k8s release for use with kube-up.

make 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:

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

k8s-devbox's People

Contributors

ivan4th avatar jellonek avatar jonboulle avatar mihgen avatar pigmej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

k8s-devbox's Issues

./install.sh host requires sudo password (even if it is disabled)

I have disabled sudo password confirmation for my user; at the same time cluster provisioning command requires it:

idv@intel-nuc:~/k8s-devbox⟫ ./install.sh host 
SUDO password: 

Please, fix this behaviour.

PS. Running the same command under root user requires sudo password as well:

root@intel-nuc:~/k8s-devbox# ./install.sh host
SUDO password: 

The role 'joshualund.golang' was not found (Vagrant-Virtualbox installation)

Deployment attempt (with Vagrant-virtualbox) fails with the following error:

root@intel-nuc:~/k8s-devbox# ./install.sh host
SUDO password: 
ERROR! the role 'joshualund.golang' was not found in /home/idv/k8s-devbox/provisioning/roles:/home/idv/k8s-devbox/provisioning:/home/idv/k8s-devbox/provisioning/roles

The error appears to have been in '/home/idv/k8s-devbox/provisioning/playbook.yml': line 13, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  roles:
    - role: joshualund.golang
      ^ here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.