terraform { backend "local" {} required_version = ">= 0.15" required_providers { kubernetes = { source = "hashicorp/kubernetes" version = "2.3.2" } } } provider "kubernetes" { config_path = "~/.kube/config" config_context = "scck8s" } variable "influx_url" { type = string description = "influxdb connection url" } variable "namespace" { type = string } variable "instance_name" { type = string default = "osrsgamestats" } variable "image" { type = string default = "dockermirror:5000/dpedu/osrsgamestats" } variable "suspend" { type = bool default = false } variable "schedule" { type = string description = "kube cron expression" default = "*/10 * * * *" } resource "kubernetes_cron_job" "osrsgamestats" { metadata { name = var.instance_name namespace = var.namespace } spec { schedule = var.schedule concurrency_policy = "Replace" starting_deadline_seconds = 60 suspend = var.suspend job_template { metadata {} spec { template { metadata {} spec { restart_policy = "Never" container { name = "scrape" image = var.image image_pull_policy = "Always" env { name = "RSSCRAPE_INFLUX_URL" value = var.influx_url } } } } } } } }