GithubHelp home page GithubHelp logo

kubestack's Introduction

Kubestack

Provision a Kubernetes cluster with Packer and Terraform on Google Compute Engine.

Status

Ready for testing. Over the next couple of weeks the repo should be generic enough for reuse with complete documentation.

Prep

The Packer and Terraform configs assume your authentication JSON file is stored under /etc/kubestack-account.json

Packer Images

Immutable infrastructure is the future. Instead of using cloud-init to provision machines at boot we'll create a custom image using Packer.

Run the packer commands below will create the following image:

kubestack-0-17-1-v20150606

Create the Kubestack Base Image

cd packer
packer build -var-file=settings.json kubestack.json

Terraform

Terraform will be used to declare and provision a Kubernetes cluster.

Prep

Generate an etcd discovery token:

curl https://discovery.etcd.io/new?size=3
https://discovery.etcd.io/465df9c06a9d589...

Edit terraform/terraform.tfvars. Add the required values:

discovery_url = "https://discovery.etcd.io/465df9c06a9d589..."
project = "kubestack"
sshkey_metadata = "core: ssh-rsa AAAAB3NzaC1yc2EA..."

Example tokens.csv

04b6d6bfe5bexample82db624, kelseyhightower, kelseyhightower
  • Ensure your local ssh-agent is running and your ssh key has been added. This step is required by the terraform provisioner.
ssh-add ~/.ssh/id_rsa

Provision the Kubernetes Cluster

cd terraform
terraform plan
terraform apply

If you run into the follow error try changing the GCE zone and try again.

The zone 'projects/kubestack/zones/us-central1-a' does not have enough resources available to fulfill the request.
terraform destroy

Get a list of GCE zones.

gcloud compute zones list
NAME           REGION       STATUS NEXT_MAINTENANCE TURNDOWN_DATE
asia-east1-c   asia-east1   UP
asia-east1-a   asia-east1   UP
asia-east1-b   asia-east1   UP
europe-west1-c europe-west1 UP
europe-west1-b europe-west1 UP
europe-west1-d europe-west1 UP
us-central1-a  us-central1  UP
us-central1-b  us-central1  UP
us-central1-c  us-central1  UP
us-central1-f  us-central1  UP

Edit terraform.tfvars

zone = "us-central1-b"

Be sure to generate a new etcd discovery token:

curl https://discovery.etcd.io/new?size=3
https://discovery.etcd.io/2e5df9c06a9d590...

Edit terraform.tfvars

discovery_url = "https://discovery.etcd.io/2e5df9c06a9d590..."

Try again.

terraform apply

Resize the number of worker nodes

Edit terraform/terraform.tfvars. Set worker_count to the desired value:

worker_count = 3

Apply the changes:

terraform plan
terraform apply
Apply complete! Resources: 10 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

Outputs:

  kubernetes-api-server = https://203.0.113.158:6443

Next Steps

Configure kubectl

Replace $kubernetes-api-server with the terraform output. Replace $token and $user with the info from terraform/secrets/tokens.csv.

kubectl config set-cluster kubestack --insecure-skip-tls-verify=true --server=$kubernetes-api-server
kubectl config set-credentials kelseyhightower --token='$token'
kubectl config set-context kubestack --cluster=kubestack --user=$user
kubectl config use-context kubestack
kubectl config view
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: $kubernetes-api-server
  name: kubestack
contexts:
- context:
    cluster: kubestack
    user: $user
  name: kubestack
current-context: kubestack
kind: Config
preferences: {}
users:
- name: $user
  user:
    token: $token

Register the worker nodes

Nodes will be named based on the following convention:

${cluster_name}-kube${count}.c.${project}.internal

Edit testing-kube0.c.kubestack.internal.json

{
  "kind": "Node",
  "apiVersion": "v1beta3",
  "metadata": {
    "name": "testing-kube0.c.kubestack.internal"
  },
  "spec": {
    "externalID": "testing-kube0.c.kubestack.internal"
  }
}
kubectl create -f testing-kube0.c.kubestack.internal.json

kubestack's People

Contributors

bakins avatar kelseyhightower avatar rimusz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubestack's Issues

kubestack systemd units update

Can we also update systemd units without rebuilding image?
As destroying servers just for that is not a good idea I think :)

change where kubestack-account.json file gets stored

@kelseyhightower I would advise to change /etc/kubestack-account.json to ~/kubestack/kubestack-account.json to store the file.

It is much easier to find and clean things up, no needs to put under main system /etc folder.

If you are happy with my suggestion, I can make all necessary changes and issue the PR for that.

kubestack binaries update

How the kubestack binaries (etcd, fleetd, ect) are going to be updated?

We do not want to build a new image with Packer :)

Then we need to restart all units including k8s ones.

Missing kubestack.tar.gz

Hi @kelseyhightower, it looks like this http://storage.googleapis.com/kubestack/kubestack-0.17.1.tar.gz is missing, can I get it from other repo?

➜  packer git:(packer_fixs) ✗ wget -O kubestack.tar.gz http://storage.googleapis.com/kubestack/kubestack-0.17.1.tar.gz 
--2016-09-01 16:21:44--  http://storage.googleapis.com/kubestack/kubestack-0.17.1.tar.gz
Resolving storage.googleapis.com (storage.googleapis.com)... 64.233.190.128, 2800:3f0:4003:c01::80
Connecting to storage.googleapis.com (storage.googleapis.com)|64.233.190.128|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-09-01 16:21:45 ERROR 404: Not Found.

bootstrap mixed GCE and bare-metal cluster

@kelseyhightower would be nice to bootstrap master/ some nodes on GCE and some bare metal nodes too.

Any good ideas how to connect bare-metal worker / nodes back to GCE etcd cluster and k8s master?

It worked well for me with weave network, but might be you have some better ideas.

coreos update

are CoreOS updates enabled?

Can the CoreUpdate be used?

provision master and node between different zones

Would be good to provision master and node between different zones,
as to use one zone for the whole cluster is not a good idea.

For testing purposes it is fine, but people will start running production clusters :)

fleet and metadata support

is any way to add metadata via packer?
so that could be handy to split in three groups (maybe separate image per server group):

  1. etcd clusters machines
  2. k8s master/s
  3. nodes
    As right now I see only one easy way using fleet global units to do upgrades for
    systemd units, kubestack binaries and k8s version upgrade

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.