-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
64 lines (54 loc) · 1.23 KB
/
main.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
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
# Configure the DigitalOcean Provider
provider "digitalocean" {
token = var.do_token
}
# Create a new Web Droplet in the nyc2 region
resource "digitalocean_droplet" "jenkins" {
image = "ubuntu-22-04-x64"
name = "jenkins"
region = var.region
size = "s-2vcpu-2gb"
ssh_keys = [data.digitalocean_ssh_key.ssh_key.id]
}
# ssh
data "digitalocean_ssh_key" "ssh_key" {
name = var.ssh_key_name
}
# Create cluster Kubernetes
resource "digitalocean_kubernetes_cluster" "k8s" {
name = "k8s"
region = var.region
# Grab the latest version slug from `doctl kubernetes options versions`
version = "1.24.4-do.0"
node_pool {
name = "default-worker"
size = "s-2vcpu-2gb"
node_count = 2
}
}
# Declarate Variable
variable "do_token" {
default = ""
}
variable "ssh_key_name" {
default = ""
}
variable "region" {
default = ""
}
# Saida
output "jenkins_ip" {
value = digitalocean_droplet.jenkins.ipv4_address
}
resource "local_file" "kube_config" {
content = digitalocean_kubernetes_cluster.k8s.kube_config.0.raw_config
filename = "kube_config.yaml"
}