Skip to content

Commit

Permalink
Add --namespace to kubectl commands in helm-template-release.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtyler committed May 2, 2018
1 parent c303578 commit 1c0ca5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.*.sw?
site
18 changes: 14 additions & 4 deletions modules/helm-template-release/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ resource "null_resource" "kubectl_apply" {

provisioner "local-exec" {
command = <<EOF
kubectl apply -f \
kubectl --namespace ${var.release_namespace} \
apply -f \
${path.root}/${var.istio_inject ? "release-injected" : "release"}.yaml
EOF
}
Expand All @@ -116,7 +117,10 @@ resource "null_resource" "kubectl_delete" {
provisioner "local-exec" {
when = "destroy"
on_failure = "continue"
command = "kubectl delete -f ${path.root}/release.yaml"
command = <<EOF
kubectl --namespace ${var.release_namespace} \
delete -f ${path.root}/release.yaml
EOF
}
}

Expand All @@ -128,12 +132,18 @@ resource "null_resource" "kubernetes_yaml" {
count = "${length(var.kubernetes_yaml)}"

provisioner "local-exec" {
command = "kubectl apply -f ${element(var.kubernetes_yaml, count.index)}"
command = <<EOF
kubectl --namespace ${var.release_namespace} \
apply -f ${element(var.kubernetes_yaml, count.index)}
EOF
}

provisioner "local-exec" {
when = "destroy"
command = "kubectl delete -f ${element(var.kubernetes_yaml, count.index)}"
command = <<EOF
kubectl --namespace ${var.release_namespace} \
delete -f ${element(var.kubernetes_yaml, count.index)}
EOF
}
}

Expand Down

0 comments on commit 1c0ca5e

Please sign in to comment.