-
Notifications
You must be signed in to change notification settings - Fork 0
/
bimmer.tf
146 lines (122 loc) · 3.17 KB
/
bimmer.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
resource "kubernetes_deployment_v1" "bimmerexporter" {
metadata {
name = "bimmerexporter"
labels = {
test = "bimmerexporter"
}
}
spec {
replicas = 1
selector {
match_labels = {
test = "bimmerexporter"
}
}
template {
metadata {
labels = {
test = "bimmerexporter"
}
}
spec {
container {
# This image build is public and is the same as the Docker file you find in this repo (if you do not trust it you can build the Dockerfile)
image = "fnzv/bimmerexporter"
name = "bimmerexporter"
# Those ENV vars are passed externally
env {
name = "EMAIL"
value = var.bmw_email
}
env {
name = "PASS"
value = var.bmw_pass
}
lifecycle {
post_start {
exec {
command = [
"/bin/bash",
"-c",
"bimmerconnected fingerprint $EMAIL $PASS rest_of_world && cp /root/vehicle_fingerprint/*/bmw-eadrax-vcs_v4_vehicles_state_WBA0FINGERPRINT01.json /app/bmw.json"
]
}
}
}
}
}
}
}
}
resource "kubernetes_ingress_v1" "bimmerexporter" {
metadata {
name = "bimmerexporter"
}
spec {
rule {
host = "bimmerexporter.youringress.local"
http {
path {
path = "/"
path_type = "ImplementationSpecific"
backend {
service {
name = "bimmerexporter"
port {
number = 1337
}
}
}
}
}
}
}
}
resource "kubernetes_service" "bimmerexporter" {
metadata {
name = "bimmerexporter"
}
spec {
selector = {
"test" = "bimmerexporter"
}
type = "ClusterIP"
port {
port = 1337
protocol = "TCP"
target_port = "1337"
}
}
}
resource "kubernetes_role" "deployment_restart_bimmerexporter" {
metadata {
name = "deployment-restart-bimmerexporter"
}
rule {
api_groups = ["apps", "extensions"]
resources = ["deployments"]
resource_names= ["bimmerexporter"]
verbs = ["get", "patch", "list", "watch"]
}
}
resource "kubernetes_service_account" "deployment_restart_bimmerexporter_sa" {
metadata {
name = "deployment-restart-bimmerexporter"
}
}
resource "kubernetes_role_binding_v1" "deployment_restart_bimmerexport_rb2" {
metadata {
name = "deployment-restart-bimmerexporter"
namespace = "default"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "Role"
name = "deployment-restart-bimmerexporter"
}
subject {
kind = "ServiceAccount"
name = "deployment-restart-bimmerexporter"
namespace = "default"
}
}