• This repository has been archived on 30/Apr/2019
  • Stars
    star
    597
  • Rank 74,979 (Top 2 %)
  • Language
    Shell
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes cluster (for testing purposes) made easy with Vagrant and CoreOS.

kubernetes-vagrant-coreos-cluster

Turnkey Kubernetes cluster setup with Vagrant 2.1.1+ and CoreOS.

If you're lazy, or in a hurry, jump to the TL;DR section.

Pre-requisites

MacOS X

On MacOS X (and assuming you have homebrew already installed) run

brew install wget

Windows

  • The vagrant-winnfsd plugin will be installed in order to enable NFS shares.
  • The project will run some bash script under the VirtualMachines. These scripts line ending need to be in LF. Git for windows set core.autocrlf true by default at the installation time. When you clone this project repository, this parameter (set to true) ask git to change all line ending to CRLF. This behavior need to be changed before cloning the repository (or after for each files by hand). We recommand to turn this to off by running git config --global core.autocrlf false and git config --global core.eol lf before cloning. Then, after cloning, do not forget to turn the behavior back if you want to run other windows projects: git config --global core.autocrlf true and git config --global core.eol crlf.

Deploy Kubernetes

Current Vagrantfile will bootstrap one VM with everything needed to become a Kubernetes master and, by default, a couple VMs with everything needed to become Kubernetes worker nodes. You can change the number of worker nodes and/or the Kubernetes version by setting environment variables NODES and KUBERNETES_VERSION, respectively. You can find more details below.

vagrant up

Linux or MacOS host

Kubernetes cluster is ready. Use kubectl to manage it.

Windows host

On Windows systems, kubectl is installed on the master node, in the /opt/bin directory. To manage your Kubernetes cluster, ssh into the master node and run kubectl from there.

vagrant ssh master
kubectl cluster-info

Clean-up

vagrant destroy

If you've set NODES or any other variable when deploying, please make sure you set it in vagrant destroy call above, like:

NODES=3 vagrant destroy -f

Notes about hypervisors

Virtualbox

VirtualBox is the default hypervisor, and you'll probably need to disable its DHCP server

VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

Parallels

If you are using Parallels Desktop, you need to install vagrant-parallels provider

vagrant plugin install vagrant-parallels

Then just add --provider parallels to the vagrant up invocations above.

VMware

If you are using one of the VMware hypervisors you must buy the matching provider and, depending on your case, just add either --provider vmware_fusion or --provider vmware_workstation to the vagrant up invocations above.

Private Docker Repositories

If you want to use Docker private repositories look for DOCKERCFG bellow.

Customization

Environment variables

Most aspects of your cluster setup can be customized with environment variables. Right now the available ones are:

  • HTTP_PROXY sets http proxy address.

    Defaults to $HTTP_PROXY of host machine if it exists.

    You need customing this proxy setting on VMs when you have to face gfw with tools like shadowsocks, privoxy on host machine, because Vagrantfile uses proxy setting on host machine default,this setting might be not right to VMs, it would lead to internet disconnection of VMs. If you have the problem, you can refer to https://www.linuxbabe.com/virtualbox/how-to-access-host-services-from-a-virtualbox-guest-os for customing this setting.

  • HTTPS_PROXY

    like HTTP_PROXY

  • NO_PROXY

    like HTTP_PROXY

  • NODES sets the number of nodes (workers).

    Defaults to 2.

  • CHANNEL sets the default CoreOS channel to be used in the VMs.

    Defaults to alpha.

    While by convenience, we allow an user to optionally consume CoreOS' beta or stable channels please do note that as both Kubernetes and CoreOS are quickly evolving platforms we only expect our setup to behave reliably on top of CoreOS' alpha channel. So, before submitting a bug, either in this project, or in (Kubernetes or CoreOS) make sure it (also) happens in the (default) alpha channel 😄

  • COREOS_VERSION will set the specific CoreOS release (from the given channel) to be used.

    Default is to use whatever is the latest one from the given channel.

  • SERIAL_LOGGING if set to true will allow logging from the VMs' serial console.

    Defaults to false. Only use this if you really know what you are doing.

  • MASTER_MEM sets the master node VM memory.

    Defaults to 1024 (in MB)

  • MASTER_CPUS sets the number of vCPUs to be used by the master VM.

    Defaults to 2.

  • NODE_MEM sets the worker nodes VM memory.

    Defaults to 2048 (in MB)

  • NODE_CPUS sets the number of vCPUs to be used by node VMs.

    Defaults to 2.

  • DOCKERCFG sets the location of your private docker repositories (and keys) configuration. However, this is only usable if you set USE_DOCKERCFG=true.

    Defaults to "~/.dockercfg".

    You can create/update a ~/.dockercfg file at any time by running docker login <registry>.<domain>. All nodes will get it automatically, at 'vagrant up', given any modification or update to that file.

  • DOCKER_OPTIONS sets the additional DOCKER_OPTS for docker service on both master and the nodes. Useful for adding params such as --insecure-registry.

  • KUBERNETES_VERSION defines the specific kubernetes version being used.

    Defaults to 1.10.9. Versions prior to 1.10.0 may not work with current cloud-configs and Kubernetes descriptors.

  • USE_KUBE_UI defines whether to deploy or not the Kubernetes UI

    Defaults to false.

  • AUTHORIZATION_MODE setting this to RBAC enables RBAC for the kubernetes cluster.

    Defaults to AlwaysAllow.

  • CLUSTER_CIDR defines the CIDR to be used for pod networking. This CIDR must not overlap with 10.100.0.0/16.

    Defaults to 10.244.0.0/16.

So, in order to start, say, a Kubernetes cluster with 3 worker nodes, 4GB of RAM and 4 vCPUs per node one just would run:

NODE_MEM=4096 NODE_CPUS=4 NODES=3 vagrant up

or with Kubernetes UI:

NODE_MEM=4096 NODE_CPUS=4 NODES=3 USE_KUBE_UI=true vagrant up

Please do note that if you were using non default settings to startup your cluster you must also use those exact settings when invoking vagrant {up,ssh,status,destroy} to communicate with any of the nodes in the cluster as otherwise things may not behave as you'd expect.

Synced Folders

You can automatically mount in your guest VMs, at startup, an arbitrary number of local folders in your host machine by populating accordingly the synced_folders.yaml file in your Vagrantfile directory. For each folder you which to mount the allowed syntax is...

# the 'id' of this mount point. needs to be unique.
- name: foobar
# the host source directory to share with the guest(s).
  source: /foo
# the path to mount ${source} above on guest(s)
  destination: /bar
# the mount type. only NFS makes sense as, presently, we are not shipping
# hypervisor specific guest tools. defaults to `true`.
  nfs: true
# additional options to pass to the mount command on the guest(s)
# if not set the Vagrant NFS defaults will be used.
  mount_options: 'nolock,vers=3,udp,noatime'
# if the mount is enabled or disabled by default. default is `true`.
  disabled: false

ATTENTION: Don't remove /vagrant entry.

TL;DR

vagrant up

This will start one master and two worker nodes, download Kubernetes binaries start all needed services. A Docker mirror cache will be provisioned in the master, to speed up container provisioning. This can take some time depending on your Internet connection speed.

Please do note that, at any time, you can change the number of worker nodes by setting the NODES value in subsequent vagrant up invocations.

Usage

Congratulations! You're now ready to use your Kubernetes cluster.

If you just want to test something simple, start with [Kubernetes examples] (https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/).

For a more elaborate scenario [here] (https://github.com/pires/kubernetes-elasticsearch-cluster) you'll find all you need to get a scalable Elasticsearch cluster on top of Kubernetes in no time.

Troubleshooting

Vagrant displays a warning message when running!

Vagrant 2.1 integrated support for triggers as a core functionality. However, this change is not compatible with the vagrant-triggers community plugin we were and still are using. Since we require this plugin, Vagrant will show the following warning:

WARNING: Vagrant has detected the `vagrant-triggers` plugin. This plugin conflicts
with the internal triggers implementation. Please uninstall the `vagrant-triggers`
plugin and run the command again if you wish to use the core trigger feature. To
uninstall the plugin, run the command shown below:

  vagrant plugin uninstall vagrant-triggers

Note that the community plugin `vagrant-triggers` and the core trigger feature
in Vagrant do not have compatible syntax.

To disable this warning, set the environment variable `VAGRANT_USE_VAGRANT_TRIGGERS`.

This warning is harmless and only means that we are using the community plugin instead of the core functionality. To disable it, set the VAGRANT_USE_VAGRANT_TRIGGERS environment variable to false before running vagrant:

$ VAGRANT_USE_VAGRANT_TRIGGERS=false NODES=2 vagrant up

I'm getting errors while waiting for Kubernetes master to become ready on a MacOS host!

If you see something like this in the log:

==> master: Waiting for Kubernetes master to become ready...
error: unable to load file "temp/dns-controller.yaml": unable to connect to a server to handle "replicationcontrollers": couldn't read version from server: Get https://10.245.1.2/api: dial tcp 10.245.1.2:443: i/o timeout
error: no objects passed to create

You probably have a pre-existing Kubernetes config file on your system at ~/.kube/config. Delete or move that file and try again.

I'm getting errors while waiting for mounting to /vagrant on a CentOS 7 host!

If you see something like this in the log:

mount.nfs: Connection timed out.

It might be caused by firewall, you can check if firewall is active with 'systemctl status firewalld', if yes, you can use 'systemctl stop firewalld' simply.

Kubernetes Dashboard asks for either a Kubeconfig or token!

This behavior is expected in latest versions of the Kubernetes Dashboard, since different people may need to use the Kubernetes Dashboard with different permissions. Since we deploy a service account with administrative privileges you should just click Skip. Everything will work as expected.

Licensing

This work is open source, and is licensed under the Apache License, Version 2.0.

More Repositories

1

kubernetes-elasticsearch-cluster

Elasticsearch cluster on top of Kubernetes made easy.
1,510
star
2

android-obd-reader

Android OBD-II Reader application that uses pure OBD-II PID's Java API.
Java
808
star
3

obd-java-api

OBD-II Java API
Java
597
star
4

go-proxyproto

A Go library implementation of the PROXY protocol, versions 1 and 2.
Go
488
star
5

docker-elasticsearch-kubernetes

Ready to use Elasticsearch + Kubernetes discovery plug-in Docker image.
Dockerfile
224
star
6

kubernetes-nats-cluster

NATS cluster on top of Kubernetes made easy.
Go
168
star
7

docker-elasticsearch

Dockerfile for a base Elasticsearch image to be extended by others (allow to install plug-ins, change configuration, etc.)
Shell
161
star
8

kubernetes-elk-cluster

ELK (Elasticsearch + Logstash + Kibana) cluster on top of Kubernetes made easy.
Dockerfile
148
star
9

spring-boot-shiro-orientdb

A simple REST API built with Spring Boot and OrientDB (Object API) datastore, secured with Apache Shiro (distributed session storage powered by Hazelcast).
Java
98
star
10

obd-server

Webapp responsible for storing OBD (Android OBD Reader) readings.
Java
69
star
11

hibernate-postgres-jsonb

A working implementation of JSONB support on a Java + Hibernate application.
Java
63
star
12

hazelcast-kubernetes

Hazelcast clustering for Kubernetes made easy.
Dockerfile
49
star
13

simple-shiro-web-app

A simple proof-of-concept of Shiro authentication with JDBC Realm and MySQL.
CSS
36
star
14

nomad-vagrant-coreos-cluster

Nomad cluster (for testing purposes) made easy with Vagrant and CoreOS.
Shell
35
star
15

docker-jre

Lean JRE 8 Docker container
Dockerfile
24
star
16

hazelcast-kubernetes-bootstrapper

Hazelcast cluster discovery mechanism for Kubernetes.
Java
22
star
17

rethinkdb-coreos-cluster

RethinkDB clustering made easy with CoreOS, etcd2 and Docker
Shell
21
star
18

netty-tcnative-alpine

Build netty-tcnative native binaries for Alpine Linux.
Dockerfile
20
star
19

kubernetes-squid

Squid proxy for Kubernetes
15
star
20

apache-ignite-discovery-kubernetes

Apache Ignite discovery for Kubernetes.
Java
10
star
21

nats-coreos-cluster

NATS clustering made easy with CoreOS and etcd.
Shell
10
star
22

docker-logstash

Dockerfile for a base Logstash image to be extended by others (allow to install plug-ins, change configuration, etc.)
10
star
23

nats-sniffer

A simple sniffer for NATS, the cloud native messaging system. https://nats.io
Go
10
star
24

consul-lb-gce

A smart Google Cloud Engine load-balancer manager for Consul backed services.
Go
10
star
25

simple-jersey-rest-app

A simple proof-of-concept of RESTful web service implemented with Jersey and Glassfish.
Java
10
star
26

alpine-linux-build

Docker image of Alpine Linux with many compilers needed to build code that's meant to run on Alpine Linux.
9
star
27

fabric8-persistence-hibernate

Fabric8 + E-OSGi JPA 2.1 managed persistence (Aries + Hibernate 4.3.x) + REST service demonstration code.
Java
9
star
28

docker-elasticsearch-aws

Ready to use Elasticsearch + AWS plug-in Docker image.
Dockerfile
9
star
29

simple-jpa-hibernate-guice-desktop-app

A simple proof-of-concept of a desktop Java application with database access using JPA, Hibernate and Guice.
Java
9
star
30

fabric8-cxf-shiro

OSGi-enabled authentication & authorization service, powered by Apache Shiro and Hazelcast cluster. Goes really well with Fabric8 or JBoss Fuse for auto-scaling.
Java
8
star
31

docker-haproxy-ssl

5
star
32

docker-apache-ignite

Lean (310MB) Apache Ignite docker image.
5
star
33

docker-hbase-standalone

Simple HBase standalone container image.
4
star
34

pgskail

PostgreSQL high-availability made easy.
Go
4
star
35

docker-logstash-forwarder

logstash-forwarder minimal Docker container image
Shell
4
star
36

docker-elasticsearch-curator

Lean Elasticsearch Curator container image, based on Alpine Linux 3.7 and Python 3.
Dockerfile
4
star
37

docker-squid

Run Squid on a Docker container. The main purpose of this it to use it as Docker registry cache.
Shell
4
star
38

docker-apollomq

Docker image for Apache ActiveMQ Apollo broker.
3
star
39

dojo-go-consul

A repo for my experiments with Consul and Go.
Go
3
star
40

go-dojo-scalability-protocols

Go experiment with [Scalability Protocols](http://bravenewgeek.com/a-look-at-nanomsg-and-scalability-protocols/).
Go
3
star
41

sherlock

Message-driven, NoSQL-powered auditing framework
Java
3
star
42

fabric8-cxf-dosgi-demo-blueprint

Simple Fabric8-oriented CXF + DOSGi demonstration code.
Java
2
star
43

springboot-stomp-ws-jms-integration

Example of integration between two apps and one frontend with STOMP over WebSocket and JMS.
JavaScript
2
star
44

configo

TOML-based, strong-typed, environment-oriented, a la fullstack configuration for Go applications.
Go
2
star
45

kubernetes-operator-dev

Dockerfile
2
star
46

go-dojo-rectangles

Go experiments with rectangles.
Go
2
star
47

fabric8-amq-example

Fabric8 ActiveMQ (JMS) example with Pax-Exam integration-tests
Java
2
star
48

opensignals-android

BITalino OpenSignals application for Android plattform.
Java
2
star
49

netty-socketio-osgi-example

Netty-SocketIO OSGi example
Java
2
star
50

replicatorg-mavenized

Mavenized version of ReplicatorG project
Java
1
star
51

metricas

A pipeline for metrics acquisition and storage.
Go
1
star
52

simple-hibernate-kundera-cassandra-polyglot-app

Simple polyglot proof-of-concept with Hibernate (PostgreSQL) and Kundera (Cassandra) support.
Java
1
star
53

fabric8-osgi-aspectj

Fabric8 example with OSGi and AspectJ (AOP) aspects woven in compile-time.
Java
1
star
54

simple-kundera-embedded-cassandra-app

A simple proof-of-concept of a Java application with embedded Cassandra integration, using Kundera and Guice.
Java
1
star