Coder Social home page Coder Social logo

pinterb / kubeadm-gce-tf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jbeda/kubeadm-gce-tf

0.0 2.0 0.0 24 KB

A simple Terraform config for launching a Kubernetes cluster on GCE using kubeadm

License: Apache License 2.0

HCL 63.94% Shell 36.06%

kubeadm-gce-tf's Introduction

kubeadm-gce-tf

This is a proof of concept (not supported for production deployments) that uses terraform to launch a set of machines on GCE. It then uses kubeadm to automatically boostrap a Kubernetes cluster. Simple networking is provided via a combination of routing configuration on GCE and using CNI to manage a bridge.

Instructions

  1. Download and install Terraform

  2. Sign up for an account (project) on Google Cloud Platform. There is a free trial.

  3. Install and initialize the gcloud CLI from the Cloud SDK

  4. Configure a service account for terraform to use.

SA_EMAIL=$(gcloud iam service-accounts --format='value(email)' create k8s-terraform)
gcloud iam service-accounts keys create account.json --iam-account=$SA_EMAIL
PROJECT=$(gcloud config list core/project --format='value(core.project)')
gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$SA_EMAIL --role roles/editor
  1. Configure terraform modules
terraform get
  1. Configure terraform variables
  • Start with the provided template:

    cp terraform.tfvars.sample terraform.tfvars
  • Generate a token:

    python -c 'import random; print "%0x.%0x" % (random.SystemRandom().getrandbits(3*8), random.SystemRandom().getrandbits(8*8))'
  • Open terraform.tfvars in an editor and fill in the blanks

  1. Run terraform plan to see what it is thinking of doing. By default it'll boot 4 n1-standard-1 machines. 1 master and 3 nodes.

  2. Run terraform apply to actually launch stuff.

  3. Run terraform destroy to tear everything down.

Using the cluster

The API server will be running an unsecured endpoint on port 8080 on the master node (only on localhost).

SSH in to master

You can easily just ssh in to the cluster and run kubectl there. That is probably easiest.

workstation$ gcloud compute ssh --zone=us-west1-a kube-master
kube-master$ kubectl get nodes
NAME          STATUS    AGE
kube-master   Ready     1h
kube-node-0   Ready     1h
kube-node-1   Ready     1h
kube-node-2   Ready     1h

SSH tunnel to master

You can easily create an SSH tunnel to that machine and use your local kubectl. kubectl should have been installed for you by the Google Cloud SDK.

# Launch the SSH tunnel in the background
gcloud compute ssh --zone=us-west1-a kube-master -- -L 8080:127.0.0.1:8080 -N &

# Set up and activate a "localhost" context for kubectl
kubectl config set-cluster localhost --server=127.0.0.1:8080 --insecure-skip-tls-verify
kubectl config set-context localhost --cluster=localhost
kubectl config use-context localhost
kubectl get nodes

Authenticate to master over Internet

TODO: Document how to copy /etc/kubernetes/admin.conf down from kube-master and modify/merge it in to local kubectl config. Also need to open up port in GCE firewall.

kubeadm-gce-tf's People

Contributors

griggheo avatar jbeda avatar lukemarsden avatar

Watchers

 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.