GithubHelp home page GithubHelp logo

dstrest / kubernetes-aws-vpc-kops-terraform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryane/kubernetes-aws-vpc-kops-terraform

0.0 1.0 0.0 9 KB

Code for Deploy Kubernetes in an Existing AWS VPC with Kops and Terraform blog post

Makefile 3.48% Go 18.51% HCL 78.01%

kubernetes-aws-vpc-kops-terraform's Introduction

kubernetes-aws-vpc-kops-terraform

Example code for the Deploy Kubernetes in an Existing AWS VPC with Kops and Terraform blog post.

tldr

terraform apply -var name=yourdomain.com

export NAME=$(terraform output cluster_name)
export KOPS_STATE_STORE=$(terraform output state_store)
export ZONES=$(terraform output -json availability_zones | jq -r '.value|join(",")')

kops create cluster \
    --master-zones $ZONES \
    --zones $ZONES \
    --topology private \
    --dns-zone $(terraform output public_zone_id) \
    --networking calico \
    --vpc $(terraform output vpc_id) \
    --target=terraform \
    --out=. \
    ${NAME}

terraform output -json | docker run --rm -i ryane/gensubnets:0.1 | pbcopy

kops edit cluster ${NAME}

# replace *subnets* section with your paste buffer (be careful to indent properly)
# save and quit editor

kops update cluster \
  --out=. \
  --target=terraform \
  ${NAME}

terraform apply -var name=yourdomain.com

using a subdomain

If you want all of your dns records to live under a subdomain in its own hosted zone, you need to setup route delegation to the new zone. After running terraform apply -var name=k8s.yourdomain.com, you can run the following commands to setup the delegation:

cat update-zone.json \
 | jq ".Changes[].ResourceRecordSet.Name=\"$(terraform output name).\"" \
 | jq ".Changes[].ResourceRecordSet.ResourceRecords=$(terraform output -json name_servers | jq '.value|[{"Value": .[]}]')" \
 > update-zone.json

aws --profile=default route53 change-resource-record-sets \
 --hosted-zone-id $(aws --profile=default route53 list-hosted-zones | jq -r '.HostedZones[] | select(.Name=="yourdomain.com.") | .Id' | sed 's/\/hostedzone\///') \
 --change-batch file://update-zone.json

Wait until your changes propagate before continuing. You are good to go when

host -a k8s.yourdomain.com

returns the correct NS records.

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.