Created
November 28, 2017 05:57
-
-
Save drzero42/31a1409a30a2d6288f6c655f4947ed15 to your computer and use it in GitHub Desktop.
Kubernetes terraform module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "kubernetes_config_map" "system" { | |
metadata { | |
name = "system" | |
namespace = "kube-system" | |
} | |
data { | |
project = "${var.project}" | |
clustername = "${var.cluster_name}" | |
} | |
} | |
resource "kubernetes_config_map" "database" { | |
metadata { | |
name = "database" | |
} | |
data { | |
name = "${var.db_name}" | |
username = "${var.db_username}" | |
hostname = "db" | |
port = "3306" | |
engine = "django.db.backends.mysql" | |
project = "${var.project}" | |
region = "${var.db_region}" | |
instance = "${var.db_instance}" | |
} | |
} | |
resource "kubernetes_secret" "google-application-credentials" { | |
metadata { | |
name = "google-application-credentials" | |
} | |
data { | |
credentials.json = "${base64decode(var.credentials)}" | |
} | |
} | |
resource "kubernetes_secret" "database" { | |
metadata { | |
name = "database" | |
} | |
data { | |
password = "${var.db_password}" | |
} | |
} | |
resource "kubernetes_config_map" "storage" { | |
metadata { | |
name = "storage" | |
} | |
data { | |
type = "gcs" | |
bucket = "${var.storage_bucket}" | |
endpoint = "https://storage.googleapis.com" | |
} | |
} | |
resource "kubernetes_config_map" "queue" { | |
metadata { | |
name = "queue" | |
} | |
data { | |
type = "pubsub" | |
topic = "${var.queue_topic}" | |
stitchingtopic = "${var.stitching_topic}" | |
project = "${var.project}" | |
subscriber = "worker" | |
stitchingsubscriber = "stitchingworker" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "kubernetes" { | |
host = "${var.k8s_endpoint}" | |
username = "${var.k8s_username}" | |
password = "${var.k8s_password}" | |
client_certificate = "${base64decode(var.k8s_client_certificate)}" | |
client_key = "${base64decode(var.k8s_client_key)}" | |
cluster_ca_certificate = "${base64decode(var.k8s_cluster_ca_certificate)}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "k8s_endpoint" {} | |
variable "k8s_username" {} | |
variable "k8s_password" {} | |
variable "k8s_client_certificate" {} | |
variable "k8s_client_key" {} | |
variable "k8s_cluster_ca_certificate" {} | |
variable "project" {} | |
variable "cluster_name" {} | |
variable "db_region" {} | |
variable "db_name" {} | |
variable "db_instance" {} | |
variable "db_username" {} | |
variable "db_password" {} | |
variable "storage_bucket" {} | |
variable "queue_topic" {} | |
variable "stitching_topic" {} | |
variable "credentials" {} | |
variable depends_on { | |
default = [] | |
type = "list" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment