Skip to content

Instantly share code, notes, and snippets.

@thbkrkr
Created May 26, 2018 10:52
Show Gist options
  • Save thbkrkr/66653adce3bb57278f99d8cb3dc4ba7f to your computer and use it in GitHub Desktop.
Save thbkrkr/66653adce3bb57278f99d8cb3dc4ba7f to your computer and use it in GitHub Desktop.
Terraform config to deploy a bunch of yaml
variable kubeconfig {
default = "/ops/clusters/c1.test/config/kubectl.secrets.conf"
}
variable dirconfig {
default = "/ops/k8s-deployments/kube-state-metrics"
}
variable prefix {
default = "kube-state-metrics-"
}
resource "null_resource" "kubectl" {
triggers {
id = "${
sha1(format("%s%s%s%s%s%s%s",
file("${var.dir}/${var.prefix}cluster-role-binding.yaml"),
file("${var.dir}/${var.prefix}cluster-role.yaml"),
file("${var.dir}/${var.prefix}deployment.yaml"),
file("${var.dir}/${var.prefix}role-binding.yaml"),
file("${var.dir}/${var.prefix}role.yaml"),
file("${var.dir}/${var.prefix}service-account.yaml"),
file("${var.dir}/${var.prefix}service.yaml")
))}"
}
provisioner "local-exec" {
command = "kubectl --kubeconfig=${var.kubeconfig} apply -f ${var.dirconfig}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment