Giter Club home page Giter Club logo

kops-terraform-example's Introduction

Kubernetes cluster in AWS using kops and Terraform

Requirements

Deploy the environment

  1. Create a backend.tf file from backend.tf.example and fill the missing values.
cp backend.tf.example backend.tf
  1. Create a config file for your environment by copying config/env.tfvars.example and fill the missing values
cp config/env.tfvars.example <env_name>.tfvars
  1. Execute terraform init, if successful your output should look like this
Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
  1. Execute terraform plan -var-file=config/env.tfvars
Plan: 27 to add, 1 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

Releasing state lock. This may take a few moments...
  1. Execute terraform apply -var-file=config/env.tfvars and answer yes when prompted.
Apply complete! Resources: 27 added, 0 changed, 0 destroyed.
Releasing state lock. This may take a few moments...
  1. Once terraform is done you can check the state of the cluster with:
export KOPS_STATE_STORE=s3://<kops_state_bucket> # Get this values from config/<env_name>.tfvars
kops export kubecfg --admin --name <name>.<hosted_zone>
kops validate cluster
  1. After kops reports your cluster as valid you can start running kubectl commands:
Using cluster from kubectl context: <name>.<hosted_zone>

Validating cluster <name>.<hosted_zone>

INSTANCE GROUPS
NAME			ROLE	MACHINETYPE	MIN	MAX	SUBNETS
agent			Node	t3.medium	1	2	PrivateSubnet-0,PrivateSubnet-1,PrivateSubnet-2
master-us-west-2a	Master	t3.medium	1	1	PrivateSubnet-0
master-us-west-2b	Master	t3.medium	1	1	PrivateSubnet-1
master-us-west-2c	Master	t3.medium	1	1	PrivateSubnet-2

NODE STATUS
NAME						ROLE	READY
ip-10-2-2-68.us-west-2.compute.internal		master	True
ip-10-2-3-217.us-west-2.compute.internal	master	True
ip-10-2-3-218.us-west-2.compute.internal	node	True
ip-10-2-4-251.us-west-2.compute.internal	master	True

Your cluster <name>.<hosted_zone> is ready
  1. For example kubectl get nodes should output something like this:
NAME                                       STATUS   ROLES    AGE   VERSION
ip-10-2-2-68.us-west-2.compute.internal    Ready    master   5m    v1.11.9
ip-10-2-3-217.us-west-2.compute.internal   Ready    master   5m    v1.11.9
ip-10-2-3-218.us-west-2.compute.internal   Ready    node     4m    v1.11.9
ip-10-2-4-251.us-west-2.compute.internal   Ready    master   5m    v1.11.9
  1. To destroy the environment simply run terraform destroy -var-file=config/env.tfvars and answer yes when prompted.
  2. To manually destroy the cluster run kops delete cluster <name>.<hosted_zone> --yes

kops-terraform-example's People

Contributors

carlosrodf 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.