Giter Site home page Giter Site logo

diannaowa / multi-master-kubernetes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exoscale/multi-master-kubernetes

0.0 3.0 0.0 1.01 MB

Multi-master Kubernetes cluster on Exoscale

Home Page: https://www.exoscale.ch/syslog/2016/10/12/multi-master-kubernetes/

Shell 0.06% Python 99.94%

multi-master-kubernetes's Introduction

Multi-master Kubernetes

This Ansible playbook helps you setup a multi-master Kubernetes cluster on Exoscale.

Getting started

Put the api-key and api-secret for your account into the cloudstack.ini file. Alternatively you can also use the CLOUDSTACK_KEY and CLOUDSTACK_SECRET environment variables. If you do, make sure to remove key and secret from the ini file.

You can get your key and secret here: https://portal.exoscale.ch/account/profile/api

To bootstrap your cluster, install the requirements via pip and put kubectl in your path. Then run the playbook.

Warning: Ansible doesn't play nice in a Virtualenv on systems with Selinux. To fix this, make sure you have python-selinux bindings installed and include system packages in your virtualenv.

# only required when selinux is enabled
sudo dnf install libselinux-python

virtualenv --system-site-packages .venv
source .venv/bin/activate

# install the requirements
pip install -r requirements.txt

# run the Ansible playbook
ansible-playbook cluster-bootstrap.yml

Tip: The cluster-bootstrap playbook is safe to re-run at any time to make sure your cluster is configured correctly.

Bootstrapping the cluster takes a few minutes. When the playbook finishes, you can see the cluster nodes come up using:

kubectl get nodes -w

Add more worker nodes

If you want to add more workers simply run the worker-add playbook. Specify the desired number of worker nodes. The default cluster has 3 worker nodes. Below command adds 2 more for a total of 5.

ansible-playbook -e desired_num_worker_nodes=5 worker-add.yml

Update Kubernetes

The cluster-upgrade playbook takes care of one by one updating Kubernetes on each of the nodes and restarting services as required. The upgrade does lead to a short unavailability of the apiserver due to the restart of the etcd members. Member restarts take a couple of retries before they succeed, this is caused by ports still being in use.

ansible-playbook cluster-upgrade.yml

Architecture

The initial cluster consists of 3 master nodes and 3 worker nodes. Master nodes are pets, worker nodes are cattle. All nodes run CoreOS.

Master nodes run:

  • infra-etcd2: Etcd2 cluster used for Flanneld overlay networking and Locksmithd
  • flanneld: for the container overlay network
  • locksmithd: to orchestrate automatic updates
  • dockerd
  • kubelet
  • kubernetes-etcd2: Etcd2 cluster used for Kubernetes
  • kube-apiserver
  • kube-scheduler
  • kube-controller-manager
  • kube-proxy

Worker nodes run:

  • flanneld: for the container overlay network
  • locksmithd: to orchestrate automatic updates
  • dockerd
  • kubelet
  • kube-proxy
  • haproxy
  • and your containers of course

Flanneld, Locksmithd, Docker, infra-etcd2 and the kubelet are started using Systemd. All other components most notably kubernetes-etcd2 and kube-* are started by the kubelet.

CoreOS is configured to do automatic updates. Locksmith is configured to make sure only one of the six cluster nodes reboots at the same time. It is also configured to ensure a maintenance window for master nodes between 4 and 5am and for worker nodes between 5 and 6am daily. Automatic updates only include the OS components that are part of CoreOS.

Ingress

Cluster bootstrap includes the nginx-ingress-controller to make services available externally using ingress resources.

Haproxy on each worker node listens on 0.0.0.0:80 and 0.0.0.0:443 and forwards TCP traffic to the ingress controller service.

Simply setup a wildcard DNS entry to point to the IPs of your worker nodes.

Kube-lego is supported by the nginx-ingress-controller but is not automatically installed.

Security

Master and worker nodes each have their own security-groups and only open the required ports between nodes within the same group or between nodes of the other group respectively.

All nodes allow external SSH access. (Required for Ansible unless you use a bastion host.)

On top of the firewall rules enforced by the security groups, all components are configured to communicate via TLS using certificates.

The required certificate authorities and certificates are generated using cfssl automatically.

Known issues / limitations

Kubectl

kubectl is configured to talk to the first master node via IP. If the first master node is unavailable, you need to update your kubectl config to talk to another master node or bring the master node back up. You can of course setup DNS A records for each one of your nodes and use a DNS name instead of the IP in your config.

multi-master-kubernetes's People

Contributors

pst avatar

Watchers

James Cloos avatar liuzhenwei avatar  avatar

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.