nkhare / k8s-cicd-webinars

DigitalOcean Kubernetes CI/CD Webinar Series

Home Page:https://go.digitalocean.com/cicd-on-k8s

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a local-exec to backup a user's existing kube config

mike-hosseini opened this issue · comments

Please add a new local-exec to master droplet in k8s-cicd-webinars/webinar1/2-kubernetes/1-Terraform/cluster.tf to prevent it from replacing the user's existing kube config. I lost my kube config because the scp local-exec replaced it.

Proposed change:

...

  provisioner "local-exec" {
    command = "if [ ! -f '~/.kube/config' ]; then cp ~/.kube/config ~/.kube/config_backup; fi"
  }

  provisioner "local-exec" {
    command = "scp -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@${digitalocean_droplet.master.ipv4_address}:/root/.kube/config ~/.kube/."
  }

...