Skip to content

Commit

Permalink
Add README and move TF under hack dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen Almog committed Sep 18, 2018
1 parent 2fff462 commit 7034500
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 469 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
*.tfstate
*.tfstate.*

# Terraform plan file
*.tfplan.*

# Auto-generated manifests
tfManifests/
18 changes: 18 additions & 0 deletions hack/aws-provision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Your AWS user account
export TF_VAR_aws_user=$(aws iam get-user | jq --raw-output '.User.UserName')

export TF_VAR_cluster_domain="aos-cloud.eu"
export TF_VAR_cluster_name=$(whoami)
export TF_VAR_cluster_namespace="dev-${TF_VAR_cluster_name}"

export TF_IN_AUTOMATION="true"

cd ./prebuild
echo "*** starting terraform"

terraform init -input=false
if [ $? == "0" ]; then
terraform plan -input=false -out=tfplan.out && terraform apply -input=false -auto-approve tfplan.out
fi
19 changes: 19 additions & 0 deletions hack/prebuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Building a dev environment using terraform
This directory holds the recipes required in order to deploy a working AWS dev environment using [terraform](https://www.terraform.io/downloads.html).

## Deployment Instructions
1. Download terraform from the link above and place it into your `$PATH`.
2. The following environment variables need to be set:
1. `TF_VAR_aws_user` your AWS username (`aws iam get-user | jq --raw-output '.User.UserName'`)
2. `TF_VAR_cluster_domain` The Route53 domain name to be used for the cluster.
3. `TF_VAR_cluster_name` (self explanatory...)
4. `TF_VAR_cluster_namespace`: the namespace to deploy the cluster components to (suggestion: `dev-${TF_VAR_cluster_name}`)

4. Run terraform:
```
> terraform init
> terraform plan
> terraform apply
```

To destroy the environment, simply run `terraform destroy`.
9 changes: 6 additions & 3 deletions prebuild/main.tf → hack/prebuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data "aws_region" "current" {}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "${var.vpc_name}"
name = "vpc-${var.cluster_name}"
cidr = "${var.vpc_cidr}"
azs = "${data.aws_availability_zones.azs.names}"
public_subnets = "${var.vpc_public_networks}"
Expand All @@ -25,15 +25,16 @@ module "vpc" {
single_nat_gateway = true

tags = {
Owner = "user"
Owner = "${var.aws_user}"
Environment = "dev"
}

vpc_tags = {
Name = "${var.vpc_name}"
Name = "vpc-${var.cluster_name}"
}
}

/*
# Generate Manifest Dir
resource "template_dir" "manifests" {
source_dir = "${path.module}/resources"
Expand All @@ -57,3 +58,5 @@ resource "template_dir" "manifests" {
ssh_key_name = "${var.sshKey}"
}
}
*/

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ resource "aws_security_group_rule" "deault_egress" {
cidr_blocks = ["0.0.0.0/0"]
}

resource "aws_security_group_rule" "default_ingress_ssh" {
resource "aws_security_group_rule" "default_ingress" {
type = "ingress"
security_group_id = "${aws_security_group.cluster_default.id}"

protocol = "tcp"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
from_port = 22
to_port = 22
}
40 changes: 19 additions & 21 deletions prebuild/variables.tf → hack/prebuild/variables.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
variable "sshKey" {
// Your aws account user name
variable "aws_user" {
type = "string"
}

variable "cluster_domain" {
type = "string"
}

variable "container_images" {
description = "Container images to use"
type = "map"

default = {
aws_machine_controller = "quay.io/kalmog/aws-machine-controller:0.0.1"
cluster_apiserver = "gcr.io/k8s-cluster-api/cluster-apiserver:0.0.6"
controller_manager = "gcr.io/k8s-cluster-api/controller-manager:0.0.7"
etcd = "k8s.gcr.io/etcd:3.1.12"
}
type = "string"
}

variable "cluster_namespace" {
type = "string"
type = "string"
}

variable "cluster_name" {
type = "string"
type = "string"
}

variable "aws_region" {
Expand All @@ -36,11 +25,6 @@ variable "vpc_cidr" {
default = "10.0.0.0/16"
}

variable "vpc_name" {
type = "string"
default = "test"
}

variable "vpc_public_networks" {
default = [
"10.0.101.0/24",
Expand All @@ -56,3 +40,17 @@ variable "vpc_private_networks" {
"10.0.3.0/24",
]
}

// only needed if we want to dynamically generate
// the manifests
variable "container_images" {
description = "Container images to use"
type = "map"

default = {
aws_machine_controller = "openshift/origin-aws-machine-controllers"
cluster_apiserver = "gcr.io/k8s-cluster-api/cluster-apiserver:0.0.6"
controller_manager = "gcr.io/k8s-cluster-api/controller-manager:0.0.7"
etcd = "k8s.gcr.io/etcd:3.1.12"
}
}
14 changes: 0 additions & 14 deletions prebuild/resources/addons.yaml

This file was deleted.

220 changes: 0 additions & 220 deletions prebuild/resources/cluster-api-server.yaml

This file was deleted.

Loading

0 comments on commit 7034500

Please sign in to comment.