How to start using terraform by deploying the application locally on top of the minikube , and then run it on top of kubernetes in cloud.google.com
To begin with, let's configure minikube and with the help of terraform we will deploy our application, for this we have already prepared a project. It only remains:
vagrant up
At the output, we have a virtual machine at 192.168.56.123 with the vagrant / vagrant login / password and / or your public key for root and vagrant users.
Here everything becomes more interesting, we will connect to cloud.google.com and launch our application there.
gcloud init
and follow the instructions. gcloud init
gcloud container clusters create gke-cluster gcloud container clusters list
[root@terraform-adm terraform]# gcloud container clusters get-credentials gke-cluster Fetching cluster endpoint and auth data. kubeconfig entry generated for gke-cluster.
[root@terraform-adm terraform]# kubectl config use-context gke_tutorial-project-183818_europe-west1-d_gke-cluster Switched to context "gke_tutorial-project-183818_europe-west1-d_gke-cluster".
[root@terraform-adm terraform]# kubectl config rename-context gke_tutorial-project-183818_europe-west1-d_gke-cluster gke_tutorial Context "gke_tutorial-project-183818_europe-west1-d_gke-cluster" was renamed to "gke_tutorial".
cp /vagrant/terraform/terraform.tfvars.example /vagrant/terraform/terraform.tfvars vi /vagrant/terraform/terraform.tfvars
terraform workspace new prod terraform init terraform plan terraform apply
terraform output lb_ingress
terraform destroy gcloud container clusters delete gke-cluster
Terraform was not so scary. Terraform opens the way for structuring and maintaining environments in an identical state.
Source: https://habr.com/ru/post/340884/
All Articles