Skip to content

Commit

Permalink
example fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arti-shalb committed Oct 24, 2023
1 parent 64f38f0 commit fb6db72
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 54 deletions.
32 changes: 32 additions & 0 deletions examples/simple/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
data "aws_availability_zones" "available" {}
data "aws_caller_identity" "current" {}

locals {
name = "k3s-test"
region = "eu-central-1"
vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)
tags = {
Example = local.name
}
master_node_labels = ["node-type=master"]
awsprofile = "cluster-dev"
master_instance_type = "t3.medium"
master_root_volume_size = 50
domain = "k3s-test.cluster.dev"
k3s_version = "1.25.11+k3s1"
s3_bucket = "cluster-dev-k3s"
key_name = "arti-key"
worker_node_groups = []
extra_api_args = {
oidc-issuer-url = "https://example.com/my"
oidc-username-claim = "email"
oidc-groups-claim = "groups"
oidc-client-id = "login"
allow-privileged = "true"
}
extra_args = [
"--disable traefik"
]

}
50 changes: 39 additions & 11 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,44 @@
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "4.0.2"
one_nat_gateway_per_az = false
create_egress_only_igw = true
azs = local.azs
name = local.name
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_support = true
enable_dns_hostnames = true
enable_vpn_gateway = true
create_database_subnet_group = true
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)]
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 48)]
cidr = local.vpc_cidr
public_subnet_tags = {
"kubernetes.io/cluster/k3s-demo-boston" = "owned"
"kubernetes.io/role/lb" = 1
}
private_subnet_tags = {
"kubernetes.io/cluster/k3s-demo-boston" = "owned"
"kubernetes.io/role/internal-lb" = 1
}
map_public_ip_on_launch = true
}


module "k3s" {
source = "../../"
master_instance_type = var.master_instance_type
master_root_volume_size = var.master_root_volume_size
master_node_labels = var.master_node_labels
cluster_name = var.cluster_name
region = var.region
key_name = var.key_name
k3s_version = var.k3s_version
public_subnets = ["subnet-6696651a"]
s3_bucket = var.s3_bucket
domain = var.domain
worker_node_groups = var.worker_node_groups
master_instance_type = local.master_instance_type
master_root_volume_size = local.master_root_volume_size
master_node_labels = local.master_node_labels
cluster_name = local.name
region = local.region
key_name = local.key_name
k3s_version = local.k3s_version
public_subnets = module.vpc.private_subnets
s3_bucket = local.s3_bucket
domain = local.domain
worker_node_groups = local.worker_node_groups
}

output "kub_config" {
Expand Down
5 changes: 1 addition & 4 deletions examples/simple/provider.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
provider "aws" {
region = var.region
profile = var.awsprofile
shared_credentials_file = "$HOME/.aws/credentials"
version = "~> 3.0"
region = local.region
}
24 changes: 0 additions & 24 deletions examples/simple/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
awsprofile = "cluster-dev"
azs = ["eu-central-1a", "eu-central-1b"]
region = "eu-central-1"
master_instance_type = "t3.medium"
master_root_volume_size = 50
master_node_labels = ["node-type=master"]
domain = "k3s-test.cluster.dev"
k3s_version = "1.19.3+k3s1"
s3_bucket = "cluster-dev-k3s"
cluster_name = "k3s-test"
key_name = "arti-key"
worker_node_groups = []

extra_api_args = {
oidc-issuer-url = "https://example.com/my"
oidc-username-claim = "email"
oidc-groups-claim = "groups"
oidc-client-id = "login"
allow-privileged = "true"
}

extra_args = [
"--disable traefik"
]
30 changes: 15 additions & 15 deletions examples/simple/variables.tf
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
variable awsprofile {
variable "awsprofile" {
type = string
default = "default"
description = "The aws credential profile alias in ~/.aws/credentials"
}

variable azs {
type = list
variable "azs" {
type = list(any)
description = "Availability Zones to deploy cluster"
}

variable region {
variable "region" {
type = string
description = "The AWS region."
}

variable master_instance_type {
variable "master_instance_type" {
type = string
}

variable k3s_version {
variable "k3s_version" {
type = string
description = "k3s version"
}

variable data_volume_size {
variable "data_volume_size" {
type = string
default = "50"
description = "Instances data volume size in Gb"
}

variable key_name {
variable "key_name" {
type = string
}

variable s3_bucket {
variable "s3_bucket" {
type = string
}

variable domain {
variable "domain" {
type = string
}

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

variable worker_node_groups {
variable "worker_node_groups" {
description = "A list of worker groups configs. See description in comments"
type = any
}

variable master_node_labels {
type = list
variable "master_node_labels" {
type = list(any)
}

variable master_root_volume_size {
variable "master_root_volume_size" {
type = number
}

0 comments on commit fb6db72

Please sign in to comment.