-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
126 lines (107 loc) · 2.2 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
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
115
116
117
118
119
120
121
122
123
124
125
terraform {
required_providers {
kind = {
source = "kyma-incubator/kind"
version = "0.0.9"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.5.0"
}
null = {
source = "hashicorp/null"
version = "3.1.0"
}
}
required_version = ">= 1.0.0"
}
provider "kind" {
}
provider "kubernetes" {
config_path = pathexpand(var.kind_cluster_config_path)
}
resource "kind_cluster" "default" {
name = var.kind_cluster_name
kubeconfig_path = pathexpand(var.kind_cluster_config_path)
wait_for_ready = true
kind_config {
kind = "Cluster"
api_version = "kind.x-k8s.io/v1alpha4"
node {
role = "control-plane"
kubeadm_config_patches = [
"kind: InitConfiguration\nnodeRegistration:\n kubeletExtraArgs:\n node-labels: \"ingress-ready=true\"\n"
]
}
node {
role = "worker"
extra_port_mappings {
container_port = 30000
host_port = 8066
}
}
}
}
resource "kubernetes_deployment" "meudeployment" {
depends_on = [kind_cluster.default]
metadata {
name = "terraform-example-2"
labels = {
app = "giropops"
}
}
spec {
replicas = 3
selector {
match_labels = {
app = "giropops"
}
}
template {
metadata {
labels = {
app = "giropops"
}
}
spec {
container {
image = "camillamartins/docker-linuxtips:1.0"
name = "docker-linuxtips"
resources {
limits = {
cpu = "1"
memory = "512Mi"
}
requests = {
cpu = "0.1"
memory = "64Mi"
}
}
port {
container_port = 8080
}
}
}
}
}
}
resource "kubernetes_service" "service" {
depends_on = [kind_cluster.default]
metadata {
name = "giropops"
}
spec {
selector = {
app = "giropops"
}
session_affinity = "ClientIP"
port {
port = 8080
protocol = "TCP"
name = "http"
target_port = 8080
node_port = 30000
}
type = "NodePort"
}
}