forked from spotinst/terraform-spotinst-ocean-aws-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocean.tf
executable file
·114 lines (108 loc) · 4.06 KB
/
ocean.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
## Create Ocean Cluster in Spot.io
resource "spotinst_ocean_aws" "ocean" {
name = var.cluster_name
controller_id = var.cluster_name
region = var.region
max_size = var.max_size
min_size = var.min_size
desired_capacity = var.desired_capacity
subnet_ids = var.subnet_ids
whitelist = var.whitelist
blacklist = var.blacklist
user_data = var.user_data !=null ? var.user_data : <<-EOF
#!/bin/bash
set -o xtrace
/etc/eks/bootstrap.sh ${var.cluster_name}
EOF
image_id = var.ami_id != null ? var.ami_id : data.aws_ami.eks_worker.id
security_groups = var.security_groups
key_name = var.key_name
iam_instance_profile = var.worker_instance_profile_arn
associate_public_ip_address = var.associate_public_ip_address
root_volume_size = var.root_volume_size
monitoring = var.monitoring
ebs_optimized = var.ebs_optimized
use_as_template_only = var.use_as_template_only
load_balancers {
arn = var.load_balancer_arn
name = var.load_balancer_name
type = var.load_balancer_type
}
## Required Tag ##
tags {
key = "kubernetes.io/cluster/${var.cluster_name}"
value = "owned"
}
# Default Provider Tags
dynamic tags {
for_each = data.aws_default_tags.default_tags.tags
content {
key = tags.key
value = tags.value
}
}
# Additional Tags
dynamic tags {
for_each = var.tags == null ? {Name = "${var.cluster_name}-ocean-cluster-node"} : var.tags
content {
key = tags.key
value = tags.value
}
}
# Strategy
fallback_to_ondemand = var.fallback_to_ondemand
utilize_reserved_instances = var.utilize_reserved_instances
draining_timeout = var.draining_timeout
grace_period = var.grace_period
spot_percentage = var.spot_percentage
instance_metadata_options {
http_tokens = var.http_tokens
http_put_response_hop_limit = var.http_put_response_hop_limit
}
# Auto Scaler Configurations
autoscaler {
autoscale_is_enabled = var.autoscale_is_enabled
autoscale_is_auto_config = var.autoscale_is_auto_config
autoscale_cooldown = var.autoscale_cooldown
auto_headroom_percentage = var.auto_headroom_percentage
autoscale_headroom {
cpu_per_unit = var.cpu_per_unit
gpu_per_unit = var.gpu_per_unit
memory_per_unit = var.memory_per_unit
num_of_units = var.num_of_unit
}
autoscale_down {
max_scale_down_percentage = var.max_scale_down_percentage
}
resource_limits {
max_vcpu = var.max_vcpu
max_memory_gib = var.max_memory_gib
}
}
# Policy when config is updated
update_policy {
should_roll = var.should_roll
roll_config {
batch_size_percentage = var.batch_size_percentage
launch_spec_ids = var.launch_spec_ids
}
}
## Scheduled Task ##
scheduled_task {
shutdown_hours {
is_enabled = var.shutdown_is_enabled
time_windows = var.shutdown_time_windows
}
tasks {
is_enabled = var.taskscheduling_is_enabled
cron_expression = var.cron_expression
task_type = var.task_type
}
}
# Prevent Capacity from changing during updates
lifecycle {
ignore_changes = [
desired_capacity
]
}
}