-
Notifications
You must be signed in to change notification settings - Fork 31
/
k8s-cronjobs.tf
88 lines (83 loc) · 2.76 KB
/
k8s-cronjobs.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
/**
* Copyright (C) 2018-2020 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "kubernetes_cron_job_v1" "apiary_inventory" {
count = (var.s3_enable_inventory && var.hms_instance_type == "k8s" && var.s3_enable_inventory_tables) ? 1 : 0
metadata {
name = "${local.instance_alias}-s3-inventory"
namespace = var.metastore_namespace
labels = {
name = "${local.instance_alias}-s3-inventory"
}
}
spec {
concurrency_policy = "Replace"
failed_jobs_history_limit = 5
schedule = var.s3_inventory_update_schedule
job_template {
metadata {}
spec {
template {
metadata {
labels = {
name = "${local.instance_alias}-s3-inventory"
}
annotations = {
"iam.amazonaws.com/role" = var.oidc_provider == "" ? aws_iam_role.apiary_s3_inventory.name : null
}
}
spec {
service_account_name = kubernetes_service_account_v1.s3_inventory[0].metadata.0.name
automount_service_account_token = true
container {
image = "${var.hms_docker_image}:${var.hms_docker_version}"
name = "${local.instance_alias}-s3-inventory"
command = ["/s3_inventory_repair.sh"]
env {
name = "AWS_REGION"
value = var.aws_region
}
env {
name = "AWS_DEFAULT_REGION"
value = var.aws_region
}
env {
name = "HIVE_DB_NAMES"
value = join(",", local.schemas_info[*]["schema_name"])
}
env {
name = "INSTANCE_NAME"
value = local.instance_alias
}
env {
name = "APIARY_RW_METASTORE_URI"
value = "thrift://${kubernetes_service.hms_readwrite[0].metadata[0].name}.${kubernetes_service.hms_readwrite[0].metadata[0].namespace}.svc.cluster.local:9083"
}
env {
name = "HIVE_METASTORE_LOG_LEVEL"
value = var.hms_log_level
}
env {
name = "ENABLE_S3_INVENTORY"
value = var.s3_enable_inventory
}
env {
name = "APIARY_S3_INVENTORY_TABLE_FORMAT"
value = var.s3_inventory_format
}
env {
name = "APIARY_S3_INVENTORY_PREFIX"
value = local.s3_inventory_prefix
}
}
image_pull_secrets {
name = var.k8s_docker_registry_secret
}
}
}
}
}
}
}