Giter Club home page Giter Club logo

managed-cluster's Introduction

Creating a cluster

Architecture

Architecture

Bootstrap from base repository

Clone this repo and give it a meaningful name:

$ git clone [email protected]:getupcloud/managed-cluster.git managed-cluster-evilcorp
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^

$ cd managed-cluster-evilcorp

Bootstrap an initial config for a new cluster named production:

$ ./managed-cluster create

All cluster configs will be stored inside the directory structure ./clusters/${CLUSTER_NAME}/${CLUSTER_TYPE}.

Start installer container

We are now ready to create our cluster. Let's start the installer container.

$ ./managed-cluster start

There are two volumes mapped from local host into container's filesystem:

  • ./clusters/${CLUSTER_NAME}/${CLUSTER_TYPE} -> /cluster
  • ./ -> /repo

A new /cluster/terraform.tfvars will be generated in case none is found. You will be asked to fill in non-default values. After that, if you need to update/change values from terraform.tfvars simply run terraform-edit or vim /cluster/terraform.tfvars.

In order to re-generate terraform.tfvars, run terraform-setup -f. Any manually-edited values in this file will be lost.

Apply terraform

We can now create our cluster using terraform. Run this to init, verify, apply and check the new cluster:

$ terraform-apply

After terraform finishes, you will be asked to create a github repo and push this repo into it.

Flux will be installed and configured to sync from ${GITHUB_REPO}/clusters/${CLUSTER_NAME}/${CLUSTER_TYPE}/manifests/cluster/kustomization.yaml.

Updating the cluster

In order to update any config, simply terraform-edit and then terraform-apply.

You are free to edit/add/remove anything from /cluster (or clusters/${CLUSTER_NAME}/${CLUSTER_TYPE} if you are outside of the container).

Workflow

This is the complete workflow (created in https://asciiflow.com)

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                   │
│                                                                                                                                   │
│          ##################                               ##################                                                      │
│          # CREATE CLUSTER #                               # UPDATE CLUSTER #                                                      │
│          ##################                               ##################                                                      │
│                  │                                                │                                                               │
│                  │                                                │                                                               │
│                  │                                                │                                                               │
│                  ▼                                                ▼                                                               │
│      ┌────────────────────────┐                      ┌──────────────────────────┐                                                 │
│      │ managed-cluster create │                      │ git clone $remote-origin │                                                 │
│      └───────────┬────────────┘                      └────────────┬─────────────┘                                                 │
│                  │                                                │                                                               │
│                  │                                                │                                                               │
│                  ▼                                                │                                                               │
│      ┌───────────────────────┐                                    ▼                                                               │
│      │ managed-cluster start │◄────────────┐       ┌──────────────────────────────┐*                                              │
│      └───────────┬───────────┘             │       │ managed-cluster remote-setup │                                               │
│                  │                         │       └──────────────┬───────────────┘                                               │
│                  │                         │                      │                                                               │
│   ┌──────────────┼───────────────┐         │                      │                                                               │
│   │ container    │               │         │                      │                         ┌─────────────────────────┐           │
│   │              ▼               │         │                      ▼                      ┌──┤ git pull origin         │           │
│   │     ┌─────────────────┐*     │         │         ┌───────────────────────────┐       │  └─────────────────────────┘           │
│   │     │ terraform-setup │      │         │         │ managed-cluster repo-pull │◄──────┤                                        │
│   │     └────────┬────────┘      │         │         └────────────┬──────────────┘       │  ┌────────────────────────────┐        │
│   │              │               │         │                      │                      └──┤ git fetch upstream         │        │
│   │              │               │         │                      │                         └────────────────────────────┘        │
│   │              │               │         │                      │                                                               │
│   │              ▼               │         │                      │                                                               │
│   │     ┌────────────────┐       │         │                      │                            ┌────────────────────────────┐     │
│   │     │ terraform-edit │       │         │                      ▼                         ┌──┤ git fetch upstream         │     │
│   │     └────────┬───────┘       │         │           ┌────────────────────────┐           │  └────────────────────────────┘     │
│   │              │               │         │           │ managed-cluster update │◄──────────┤                                     │
│   │              │               │         │           └──────────┬─────────────┘           │  ┌───────────────────────┐          │
│   │              │               │         │                      │                         └──┤ git merge $latest-tag │          │
│   │              ▼               │         │                      │                            └───────────────────────┘          │
│   │     ┌──────────────────┐     │         │                      │                                                               │
│   │     │ terraform-apply  │     │         │                      │                                                               │
│   │     └──────────────────┘     │         │                      │                                                               │
│   │                              │         │                      │                        ┌──────────────────────────────┐       │
│   └──────────────────────────────┘         │                      ▼                     ┌──┤ rsync templates/ -> /cluster │       │
│                                            │       ┌───────────────────────────────┐    │  └──────────────────────────────┘       │
│                                            └───────┤ managed-cluster sync-template │◄───┤                                         │
│                                                    └───────────────────────────────┘    │  ┌────────────────────────────────────┐ │
│                                                                                         └──┤ rsync templates/$type/ -> /cluster │ │
│                                                                                            └────────────────────────────────────┘ │
│ * required only once                                                                                                              │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

managed-cluster's People

Contributors

adonaicosta avatar caruccio avatar lanaymc avatar mmmarceleza avatar rafaelperoco 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.