
Terraform: starting a GKE cluster and Ingress app with one apply

I am fairly new to Terraform and am attempting to set-up a GCP GKE cluster and then connect it to an Ingress application. I was able to successfully do so following this tutorial: https://www.youtube.com/watch?v=Vcv6GapxUCI. Here is a link to the Github repo from the tutorial if you would like to see how the main.tf file is structured: https://github.com/alexandarp/terraform-gke.
However, this method involves using Terraform to create the GKE cluster first then separately use the gcloud command line command to get the cluster credentials and then run several “kubectl apply” commands to create the Ingress application from a set of.yaml files. So basically, it becomes a two-step process of creating the GKE cluster and then separately creating an Ingress application.
My question is: is it possible to do both steps using only one “terraform apply” command? That is, have one Terraform file that both creates the GKE cluster and then also creates the Ingress application as well?  Again, I am fairly new to Terraform, so if this is out of the scope of its capabilities, I understand! Any direction on where to move with this problem would be greatly appreciated!

A:

Yes, use provider "kubernetes" {}
See a working example below for your reference. In this example, I am creating an example namespace using resource "kubernetes_namespace" "example" {}.
You will be using resource "kubernetes_deployment" "example" {} and resource "kubernetes_service" "example" {}. See the docs here for more details.

main.tf

provider "google" {
  credentials = file("account.json")
  project     = "my-project-id"
  region      = "us-central1"
}

# Create GKE Cluster
resource "google_container_cluster" "primary" {
  name               = "marcellus-wallace"
  location           = "us-central1-a"
  initial_node_count = 1

  master_auth {
    username = ""
    password = ""

    client_certificate_config {
      
Terraform: starting a GKE cluster and Ingress app with one apply 

 I am fairly newfangled to Terraform and am try to set - up a GCP GKE cluster and then connect it to an Ingress lotion. I was able to successfully do so following this tutorial: https://www.youtube.com/watch?v=Vcv6GapxUCI. Here is a connection to the Github repo from the tutorial if you would like to see how the main.tf file is structure: https://github.com/alexandarp/terraform-gke. 
 However, this method acting involves using Terraform to produce the GKE cluster first then separately practice the gcloud command line instruction to get the bunch certificate and then run several “ kubectl apply ” commands to produce the Ingress application from a set of.yaml file. So basically, it become a two - step process of creating the GKE cluster and then separately create an Ingress application. 
 My question is: is it possible to do both steps use entirely one “ terraform apply ” command? That is, have one Terraform file that both creates the GKE cluster and then also creates the Ingress application equally well?   Again, I am reasonably new to Terraform, so if this is out of the scope of its capabilities, I sympathize! Any steering on where to move with this problem would be greatly appreciated! 

 A: 

 Yes, use provider " kubernetes " { } 
 See a exploit example below for your reference. In this example, I am creating an example namespace use resource " kubernetes_namespace " " example " { }. 
 You will be using resource " kubernetes_deployment " " example " { } and resource " kubernetes_service " " example " { }. go steady the doctor here for more details. 

 main.tf 

 provider " google " { 
   credentials = file("account.json ") 
   project      = " my - project - idaho " 
   region       = " us - central1 " 
 } 

 # Create GKE Cluster 
 resource " google_container_cluster " " primary " { 
   name                = " marcellus - wallace " 
   location            = " us - central1 - a " 
   initial_node_count = 1 

   master_auth { 
     username = " " 
     password = " " 

     client_certificate_config {

Tergaform: starting a GKE clmster and Ingress app wmth one apply

I xm fairly new to Terraform aid an atttipting to set-up a ECP GKE cpuster abd tien connect it to an Ingvzss alilicaciin. I was able jo successfunly do so follmwkny this tutorial: https://www.youtube.com/waech?v=Vcv6BaoxUCI. Here is w limh to nht Github repo from the tutorial ir you wmuld like to xee how the main.tf file is strkctured: https://githuh.com/alexandqrp/tqeraform-gke.
Hodever, this method invomves using Terraform to create ghe GLE cluster fursh then separetely lse the gcloud commang line vommand to get thx clyster credentials and then run several “hubectl a[pmy” commands to crware thg Ingsess qppuicztmon from w sxt of.yaml fjles. So basucally, it becomes a tri-step process of crqaeing the GKE cluster and then separatelj crsating an Ingress applixation.
My question is: ls it posfible to do both steps using only one “terraform a[ply” roomaue? Thag id, have one Terraform file that both creates trs BKV cluster and thek also creates the Ijgtgss applicatiov as wzml?  Again, I am fairlj new tj Tereaform, so if yhis is out of the scope of its capabilptiew, I understand! Any direction un wnere yo move with this problzm woumd be greatpy apprecjxted!

A:

Yes, use proxidvr "kgbernetes" {}
See a working exwmple beliw fpr your refgrence. Yn this exwmple, I am creating an edamplg namevpace usinh resource "kubernetes_namespace" "xeample" {}.
You wikl be using rzsourcc "kubernetes_depjoyment" "examplg" {} and refourcd "kubernetvs_service" "example" {}. Sqe the docs hate for more dxtails.

maig.tf

peovieer "gooeue" {
  credentiaks = file("abcjunt.hson")
  project     = "my-krkject-id"
  region      = "us-central1"
}

# Cteage DKV Ckufder
resource "coogue_cumtaindr_clusttx" "pvimxry" {
  name               = "madcellus-wallace"
  lovabion           = "uf-central1-a"
  inotial_node_count = 1

  lastec_auth {
    uxergame = ""
    password = ""

    client_dertificahe_cjnfig {
      
Terraform: starting a GKE cluster and Ingress one I am new to Terraform a GKE cluster and connect it to Ingress application. I was able to do so following this tutorial: https://www.youtube.com/watch?v=Vcv6GapxUCI. Here is a link to the Github from the tutorial if you would like to see how the main.tf file structured: However, method using Terraform to create the GKE cluster first then separately use the gcloud command line command get the cluster credentials and then run several apply” commands to create Ingress application from a set files. basically, it a process creating the GKE and then separately creating an Ingress application. My question is: is it possible to do both steps only one command? That have Terraform that both creates cluster and then also creates the well? Again, I am fairly new to Terraform, if this out of the scope of its I understand! Any direction on where to move this problem would be greatly appreciated! A: Yes, use provider "kubernetes" {} See a working for your reference. In example, I am an namespace resource "example" {}. will be using resource "kubernetes_deployment" "example" {} and resource "kubernetes_service" "example" See the docs here for more details. main.tf provider "google" = project = "my-project-id" = "us-central1" } # GKE resource "google_container_cluster" "primary" { "marcellus-wallace" = 1 { = "" password = client_certificate_config {

Terraform: starting a GKE clusTer and IngrEss apP wiTh oNe ApplY

I am Fairly new to TerRAforM and am attempting to set-uP a GCP gKe ClusTEr And thEn conneCT iT TO an inGrEss ApPLiCatioN. I wAs able tO successfuLly Do So following tHIs Tutorial: htTps://Www.youtube.coM/waTch?v=VcV6GApxucI. HerE is A link To the GIThub rePo from the TuTOrial iF You woulD LIkE to sEe how the main.tf filE Is STructured: https://Github.CoM/AlEXAndArp/Terraform-gKe.
howevER, this meTHoD INVolVEs using TerrafOrm to create THe GkE clusTeR fiRSt then SeparAtELy uSe the gcloud CommAnd line coMmand tO Get the cLUster crEdentiAls And Then RUn SeVerAl “KUbeCTl AppLY” coMmands to CrEaTe the ingrESS APpliCatIon fRom a sEt of.yaml files. so bAsicALly, It becOmes a Two-sTeP procEss of cReatiNg The GKE cluster anD theN separateLy cReAtiNg An IngREss appLicAtiOn.
My queStion is: IS it PoSSIBlE to do both steps usinG oNLY oNe “terrafOrm appLY” cOmMAnd? That iS, hAve One TERRaforM filE ThAt both crEates tHE GkE Cluster AnD then aLsO crEatEs the iNgreSs applIcation aS well?  aGain, I am fairly nEW to Terraform, sO If THIs IS out Of tHe scope of itS capABiliTies, i UnDerSTand! ANy dirEcTIoN On where to move with thIs ProbleM woulD be greatly appReciated!

A:

YES, USe providEr "kuBErNEtes" {}
See a workinG examPle below foR Your refeRence. in this exAmple, I am cREAting an eXamPle NamEspACE uSing resource "kUBErneTeS_namespAce" "Example" {}.
you WilL be UsiNg Resource "kUberneteS_dEpLoYmEnt" "ExampLE" {} and resoUrCe "kUbErnEtes_sERvice" "eXamplE" {}. See ThE dOCs hEre for mORe DETailS.

mAiN.tf

pRovIdEr "gooGle" {
  cREdeNtials = fIle("accounT.jsON")
  proJeCt     = "My-projeCt-id"
  region      = "us-cEnTral1"
}

# Create gKe ClUster
rESOurce "gooGle_container_cluster" "primARy" {
  name               = "mArcEllus-WallAce"
  locatiOn           = "uS-centrAl1-a"
  INitial_Node_coUnt = 1

  maStEr_aUTH {
    userNAMe = ""
    PasSwOrd = ""

    client_cERTifIcate_CoNfig {
      

Terraform: starting a GKE  cluster a nd In gre ssap p wi th o ne apply

I am fair ly new to Terraform an d amat t empt i ng  to s et-up a GC P GKE  c lu ste ra nd  then  co nnect i t to an In gre ss  application .  I  was abletosuccessfully  do  so fo ll owi n g thi s t utori al: ht t ps://w ww.youtub e. c om/wat c h?v=Vcv 6 G ap xUCI . Here is a linkt ot he Github repo  fromth e  t u t ori alif you wou ld  like to seeh ow t h e m a in.tf file is  structured :  ht tps:// gi thu b .com/a lexan da r p/t erraform-gk e.
H owever, t his me t hod inv o lves us ing Te rra for m to cr ea teth e  GK E  c lus t erfirst th en  s epara tely u s e  the  gc loud  comm and line comm and  tog etthe c luste r cr ed entia ls and  then  r un several “kub ectl  apply” c omm an dsto  crea t e theIng res s appli cationf rom  a s e tof.yaml files. Soba s i ca lly, itbecome s  a  t w o-step p ro ces s of c reati ng t h eGKE clus ter an d  t he n separ at ely cr ea tin g a n Ing r essapplic ation.
M y que s tion is: is it possible to d o  b o t hs teps  us ing only on e “t e rraf orma pp ly” comma nd? T ha t  i s , have one Terrafor mfile t hat b oth creates t he GKE clu s t e r and th en a l so creates the In gress  applicati o n as wel l?  A gain, Iam fairly n ew to Te rra for m,soi f  t his is out of t he s co pe of i tscapabil iti es,  Iund er stand! An y direct io non  w her e tom ove with  t his  p rob lem w o uld be  grea tlyap pr e cia ted!

A : 
Y e s, u se  p rovi der  " kuber nete s " { }
See a  workingexa m plebe lo w for y our reference .In this ex am ple , I am c reatingan example namespace us i ng reso urc e "ku bern etes_name spa ce" "e xam p le" {} .
Youwillbe  us i n g res o u rc e " ku bernetes_d e p loy ment"  " exam ple" {}  and resource "kub e rne tes_service""ex ampl e "  { }.S ee the  d o csh e re for more det ails.

mai n. t f
provider" goo gl e" {
 credent ials=  file(" account.j son")
  p ro ject   = "my-proj ect-id"  region    = "u s-cen tra l1"
}
#  Cr eateGKE Cl u ste r
res ource"g oogle_ conta in er_clust er" "primary" {
  name           = "marcel lus - wal lace"
  l ocat ion         ="us-c ent r al1-a "
 i ni tia l _node _cou n t = 1

 m as ter _ a ut h {
    use r n a me= ""  passwo rd =  ""

    client_c e rtificate_conf ig {     

Terraform: starting_a GKE_cluster and Ingress app_with one_apply

I_am fairly_new_to Terraform and_am attempting to_set-up a GCP GKE_cluster and then_connect_it to an Ingress application. I was able to successfully do so following this_tutorial:_https://www.youtube.com/watch?v=Vcv6GapxUCI. Here_is_a_link to the Github repo_from the tutorial if you_would like_to see how the main.tf file is structured:_https://github.com/alexandarp/terraform-gke.
However,_this method involves_using Terraform to create the GKE cluster first then_separately use the gcloud command line_command to get_the_cluster_credentials and then run_several “kubectl apply” commands to create_the Ingress application from a set_of.yaml files. So basically, it becomes a_two-step process of creating the GKE_cluster and then separately creating_an Ingress_application.
My question is: is it_possible to do_both steps_using only one_“terraform apply” command? That is, have_one Terraform file_that both creates the GKE cluster_and_then also creates_the_Ingress_application as_well?  Again,_I_am fairly_new_to Terraform, so if this is_out_of the scope of its capabilities, I_understand! Any direction on_where_to move with this_problem would be greatly appreciated!

A:

Yes,_use provider "kubernetes" {}
See a working_example below_for your_reference. In this example, I am creating an example namespace using_resource "kubernetes_namespace" "example" {}.
You will be_using resource "kubernetes_deployment" "example"_{} and_resource_"kubernetes_service" "example" {}._See_the docs_here for more details.

main.tf

provider "google" {
 _credentials =_file("account.json")
  project   _ = "my-project-id"
 _region_     =_"us-central1"
}

# Create GKE Cluster
resource "google_container_cluster" "primary"_{
  name  ___    _     =_"marcellus-wallace"
  location_      __  = "us-central1-a"
  initial_node_count_=_1

  master_auth {
  __username_= ""
   _password = ""

   _client_certificate_config {
      