Coder Social home page Coder Social logo

olivierots / kubernetes-the-hard-way-terraform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drewmullen/kubernetes-the-hard-way-terraform

0.0 1.0 1.0 23 KB

๐Ÿณ Terraform-defined implementation of Kelsey Hightower's "Kubernetes The Hard Way" tutorial.

Home Page: https://www.nebulaworks.com/

License: Mozilla Public License 2.0

Shell 60.23% HCL 39.77%

kubernetes-the-hard-way-terraform's Introduction

Kubernetes The Hard Way With Terraform

Table Of Contents

Project Status

Getting Started

Contributing

Motivation

Project Status

PRE-ALPHA. Please don't use the project for any production workloads. Also, be sure to spin your cluster down if you aren't using it as it will cost you--or your company--money.

Getting Started

  1. If you don't already have one, sign up for a Google Cloud Platform account.
  2. Download the gcloud command-line tool.
  3. Create a project in GCP named k8s-the-hard-way-tf.
  4. On the command line, run: gcloud init to set up your account credentials/project details to point at the newly created project.
  5. Create a service account (IAM & admin > Service accounts > + CREATE SERVICE ACCOUNT) in the k8s-the-hard-way-tf project with Owner permissions, create/download the *.json credentials generated by the service account, and place them in a safe location on your local machine.
  6. Set your Google Application credentials using: export GOOGLE_APPLICATION_CREDENTIALS=<path-to-your-credentials-json>.
  7. Go to the certs directory, and run the create-ca.sh script, followed by the gen-certs.sh script. This will create a self-signed CA, and create/sign all of the generated certs with that CA.
  8. Go to the configs directory, and run the gen-config.sh script. This will create the encryption configuration for the new Kubernetes cluster.
  9. Add a public ssh key to your project metadata (Compute Engine > Metadata > SSH Keys) using the format <protocol> <key-blob> <[email protected]>. The virtual machines you spin up will inherit this public key and allow the remote-exec provisioners to work.
  10. Fill in the variables in variables.tf that have TODO next to them.
  11. OPTIONAL: Edit the GitHub usernames in scripts/add-ssh-keys.sh to give trusted colleagues/friends access to the machines in your Kubernetes cluster (see the Motivation section for more details).
  12. Run: terraform init to initialize Terraform.
  13. Run: terraform plan to see the planned changes that Terraform will make.
  14. Run: terraform apply to create your Kubernetes cluster. NOTE: The first terraform apply might fail because the Compute Engine API has not been used in project before. Follow the link provided in the error message (should be something like https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=0123456789) and click ENABLE. After the API is enabled, rerun terraform apply.
  15. Configure kubectl to use the new cluster by running the configure-kubectl script.
  16. Run kubectl get cs (or another related command) to test the cluster's component statuses.

Contributing

Make a PR and we'll go from there!

Motivation

This cluster was designed for the purpose of enabling effective study for the Certified Kubernetes Administrator (CKA) exam. The vision was to define a custom, from-scratch Kubernetes cluster in Terraform (using Kelsey Hightower's kubernetes-the-hard-way tutorial as a reference point--thanks Kelsey), so that you could spin up a Kubernetes cluster with access to all of its internal components--including the Control Plane--on-demand, and destroy it if the cluster became unusable, or you just want to start over. This code enabled the majority of the Cloud Engineers at Nebulaworks to effectively study for, and get their CKA through hands-on practice in a CKA-exam-like environment (see below).

How we would practice creating/using Kubernetes objects and completing tasks for the CKA:

  1. Run terraform apply to create your Kubernetes cluster.
  2. Scour the Kubernetes reference docs and try to create the objects/complete the tasks that you see.

How we would practice for things breaking in the CKA:

  1. Edit scripts/add-ssh-keys.sh to give trusted colleagues/friends access to the machines in your Kubernetes cluster.
  2. Run terraform apply to create your Kubernetes cluster.
  3. Have your trusted colleagues/friends ssh into your cluster and break things [you'll need to give them the username for your machines (run whoami), and the IP addresses of your machines (run terraform output)].
  4. Fix the things that are broken.

kubernetes-the-hard-way-terraform's People

Watchers

 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.