├── .gitignore ├── 01-Terraform-Install-Tools └── README.md ├── 02-Terraform-Commands ├── README.md └── terraform-manifests │ └── vpc.tf ├── 03-Terraform-Language-Basics ├── README.md └── terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ └── c5-vminstance.tf ├── 04-Terraform-MetaArgument-provider ├── README.md └── terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ └── c3-vpc.tf ├── 05-Terraform-Variables-Output-Values ├── README.md └── terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-vminstance.tf │ ├── c6-output-values.tf │ ├── terraform.tfvars │ ├── vm.auto.tfvars │ └── vm.tfvars ├── 06-Terraform-MetaArgument-count ├── README.md └── terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-vminstance.tf │ ├── c6-output-values.tf │ └── terraform.tfvars ├── 07-Terraform-Datasources ├── README.md └── terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-vminstance.tf │ ├── c6-02-vminstance-outputs.tf │ └── terraform.tfvars ├── 08-Terraform-MetaArgument-foreach ├── D1-terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-vminstance.tf │ ├── c6-02-vminstance-outputs.tf │ └── terraform.tfvars ├── D2-terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-vminstance.tf │ ├── c6-02-vminstance-outputs.tf │ └── terraform.tfvars └── README.md ├── 09-GKE-Public-Standard-Cluster ├── README.md └── p1-gke-public-cluster │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-01-gke-service-account.tf │ ├── c5-02-gke-cluster.tf │ ├── c5-03-gke-linux-nodepool.tf │ ├── c5-04-gke-outputs.tf │ └── terraform.tfvars ├── 10-Kubernetes-Resources-yaml ├── README.md ├── p1-gke-public-cluster │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-01-gke-service-account.tf │ ├── c5-02-gke-cluster.tf │ ├── c5-03-gke-linux-nodepool.tf │ ├── c5-04-gke-outputs.tf │ └── terraform.tfvars └── p2-k8sresources-yaml │ ├── 01-kubernetes-deployment.yaml │ └── 02-kubernetes-loadbalancer-service.yaml ├── 11-Kubernetes-Resources-Terraform ├── README.md ├── p1-gke-public-cluster │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-01-gke-service-account.tf │ ├── c5-02-gke-cluster.tf │ ├── c5-03-gke-linux-nodepool.tf │ ├── c5-04-gke-outputs.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 01-kubernetes-deployment.yaml │ └── 02-kubernetes-loadbalancer-service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 12-GKE-Private-Standard-Cluster-Autoscaler ├── README.md ├── p1-gke-private-cluster-autoscaler │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-gke-service-account.tf │ ├── c6-02-gke-cluster.tf │ ├── c6-03-gke-linux-nodepool.tf │ ├── c6-04-gke-outputs.tf │ ├── c7-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 01-kubernetes-deployment.yaml │ └── 02-kubernetes-loadbalancer-service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 13-GKE-Horizontal-Pod-Autoscaling ├── README.md ├── p1-gke-private-cluster-autoscaler │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-gke-service-account.tf │ ├── c6-02-gke-cluster.tf │ ├── c6-03-gke-linux-nodepool.tf │ ├── c6-04-gke-outputs.tf │ ├── c7-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml-hpa-v1 │ ├── 01-kubernetes-deployment.yaml │ ├── 02-kubernetes-cip-service.yaml │ └── 03-kubernetes-hpa.yaml ├── p3-k8sresources-yaml-hpa-v2 │ ├── 01-kubernetes-deployment.yaml │ ├── 02-kubernetes-cip-service.yaml │ └── 03-kubernetes-hpa.yaml └── p4-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-clusterip-service.tf │ ├── c6-kubernetes-hpa.tf │ └── terraform.tfvars ├── 14-GKE-Vertical-Pod-Autoscaling ├── README.md ├── p1-gke-private-cluster-autoscaler │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-gke-service-account.tf │ ├── c6-02-gke-cluster.tf │ ├── c6-03-gke-linux-nodepool.tf │ ├── c6-04-gke-outputs.tf │ ├── c7-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml-vpa │ ├── 01-kubernetes-deployment.yaml │ ├── 02-kubernetes-cip-service.yaml │ └── 03-vpa-manifest.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-clusterip-service.tf │ ├── c6-kubernetes-vpa.tf │ └── terraform.tfvars ├── 15-GKE-Private-Standard-Cluster-private-endpoint ├── README.md ├── p1-gke-private-cluster-private-endpoint │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-firewallrules.tf │ ├── c5-datasource.tf │ ├── c6-01-gke-service-account.tf │ ├── c6-02-gke-cluster.tf │ ├── c6-03-gke-linux-nodepool.tf │ ├── c6-04-gke-outputs.tf │ ├── c7-Cloud-NAT-Cloud-Router.tf │ ├── c8-bastion-vm.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 01-kubernetes-deployment.yaml │ └── 02-kubernetes-loadbalancer-service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 16-GKE-Private-Autopilot-cluster ├── README.md ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 01-kubernetes-deployment.yaml │ └── 02-kubernetes-loadbalancer-service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 17-GKE-Storage-Persistent-Disks ├── README.md ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 00-storage-class.yaml │ ├── 01-persistent-volume-claim.yaml │ ├── 02-UserManagement-ConfigMap.yaml │ ├── 03-mysql-deployment.yaml │ ├── 04-mysql-clusterip-service.yaml │ ├── 05-UserMgmtWebApp-Deployment.yaml │ └── 06-UserMgmtWebApp-LoadBalancer-Service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-01-storage-class.tf │ ├── c4-02-persistent-volume-claim.tf │ ├── c4-03-UserMgmtWebApp-ConfigMap.tf │ ├── c4-04-mysql-deployment.tf │ ├── c4-05-mysql-clusterip-service.tf │ ├── c4-06-UserMgmtWebApp-deployment.tf │ ├── c4-07-UserMgmtWebApp-loadbalancer-service.tf │ ├── terraform.tfvars │ └── webappdb.sql ├── 18-GKE-Storage-CloudSQL ├── README.md ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-cloudsql-privatedb │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-private-service-connection.tf │ ├── c4-01-cloudsql.tf │ ├── c4-02-cloudsql-outputs.tf │ ├── c5-vminstance.tf │ ├── mysql-client-install.sh │ └── terraform.tfvars └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-06-UserMgmtWebApp-deployment.tf │ ├── c4-07-UserMgmtWebApp-loadbalancer-service.tf │ └── terraform.tfvars ├── 19-GKE-Cloud-Storage-FUSE-CSI ├── README.md ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── c1-k8s-namespace.yaml │ ├── c2-k8s-serviceaccount.yaml │ ├── c3-k8s-pv.yaml │ ├── c4-k8s-pvc.yaml │ ├── c5-kubernetes-deployment.yaml │ └── c6-kubernetes-loadbalancer-service.yaml ├── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-01-cloud-storage-bucket.tf │ ├── c4-02-bucket-iam-binding.tf │ ├── c5-01-persistent-volume.tf │ ├── c5-02-namespace.tf │ ├── c5-03-persistent-volume-claim.tf │ ├── c5-04-service-account.tf │ ├── c5-05-myapp1-deployment.tf │ ├── c5-06-myapp1-loadbalancer-service.tf │ └── terraform.tfvars ├── review-containers-in-a-pod └── static-files │ ├── file1.html │ ├── file2.html │ └── index.html ├── 20-GKE-Storage-Filestore ├── README.md ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── p2-k8sresources-yaml │ ├── 00-filestore-storage-class.yaml │ ├── 01-filestore-pvc.yaml │ ├── 02-write-to-filestore-pod.yaml │ ├── 03-myapp1-deployment.yaml │ └── 04-loadBalancer-service.yaml └── p3-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-01-storage-class.tf │ ├── c4-02-persistent-volume-claim.tf │ ├── c5-01-write-to-filestore-pod.tf │ ├── c5-02-myapp1-deployment.tf │ ├── c5-03-myapp1-loadbalancer-service.tf │ └── terraform.tfvars ├── 21-GKE-Gateway-API ├── 01-GKE-LB-Gateway-API-Basic │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-gateway.yaml │ │ └── 04-gateway-http-route.yaml │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-myapp1-deployment.tf │ │ ├── c5-myapp1-clusterip-service.tf │ │ ├── c6-gateway.tf │ │ ├── c7-gateway-http-route.tf │ │ └── terraform.tfvars ├── 02-GKE-LB-Gateway-API-StaticIP │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-gateway.yaml │ │ └── 04-gateway-http-route.yaml │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-myapp1-deployment.tf │ │ ├── c5-myapp1-clusterip-service.tf │ │ ├── c6-gateway.tf │ │ ├── c7-gateway-http-route.tf │ │ ├── c8-static-ip.tf │ │ └── terraform.tfvars ├── 03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-gateway.yaml │ │ ├── 04-gateway-http-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-myapp1-deployment.tf │ │ ├── c5-myapp1-clusterip-service.tf │ │ ├── c6-gateway.tf │ │ ├── c7-gateway-http-route.tf │ │ ├── c8-static-ip.tf │ │ ├── c9-kubernetes-secret.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 04-GKE-Gateway-API-Selfsigned-SSL-CertManager │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-gateway.yaml │ │ ├── 04-gateway-http-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-myapp1-deployment.tf │ │ ├── c5-myapp1-clusterip-service.tf │ │ ├── c6-gateway.tf │ │ ├── c7-gateway-http-route.tf │ │ ├── c8-static-ip.tf │ │ ├── c9-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-gateway.yaml │ │ ├── 04-gateway-http-route.yaml │ │ ├── 05-gateway-http-to-https-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-myapp1-deployment.tf │ │ ├── c5-myapp1-clusterip-service.tf │ │ ├── c6-01-gateway.tf │ │ ├── c6-02-gateway-http-route.tf │ │ ├── c6-03-gateway-http-to-https-route.tf │ │ ├── c7-static-ip.tf │ │ ├── c8-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 06-GKE-Gateway-API-ContextPath-Routing │ ├── README.md │ ├── curl-pod.yaml │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── 01-myapp1-deployment.yaml │ │ ├── 02-myapp1-clusterip-service.yaml │ │ ├── 03-myapp2-deployment.yaml │ │ ├── 04-myapp2-clusterip-service.yaml │ │ ├── 05-myapp3-deployment.yaml │ │ ├── 06-myapp3-clusterip-service.yaml │ │ ├── 07-gateway.yaml │ │ ├── 08-gateway-http-route.yaml │ │ ├── 09-gateway-http-to-https-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-deployment.tf │ │ ├── c4-02-myapp1-clusterip-service.tf │ │ ├── c4-03-myapp2-deployment.tf │ │ ├── c4-04-myapp2-clusterip-service.tf │ │ ├── c4-05-myapp3-deployment.tf │ │ ├── c4-06-myapp3-clusterip-service.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-route.tf │ │ ├── c5-03-gateway-http-to-https-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 07-GKE-Gateway-API-Domain-Routing │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── c1-01-myapp1-deployment.yaml │ │ ├── c1-02-myapp1-clusterip-service.yaml │ │ ├── c2-01-myapp2-deployment.yaml │ │ ├── c2-02-myapp2-clusterip-service.yaml │ │ ├── c3-01-myapp3-deployment.yaml │ │ ├── c3-02-myapp3-clusterip-service.yaml │ │ ├── c4-01-gateway.yaml │ │ ├── c4-02-gateway-http-to-https-route.yaml │ │ ├── c4-03-gateway-app1-http-route.yaml │ │ ├── c4-04-gateway-app2-http-route.yaml │ │ ├── c4-05-gateway-app3-http-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-deployment.tf │ │ ├── c4-02-myapp1-clusterip-service.tf │ │ ├── c4-03-myapp2-deployment.tf │ │ ├── c4-04-myapp2-clusterip-service.tf │ │ ├── c4-05-myapp3-deployment.tf │ │ ├── c4-06-myapp3-clusterip-service.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-to-https-route.tf │ │ ├── c5-03-gateway-app1-http-route.tf │ │ ├── c5-04-gateway-app2-http-route.tf │ │ ├── c5-05-gateway-app3-http-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 08-GKE-Gateway-API-Traffic-Splitting │ ├── README.md │ ├── curl-pod.yaml │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── c1-01-myapp1-v1-deployment.yaml │ │ ├── c1-02-myapp1-v1-clusterip-service.yaml │ │ ├── c2-01-myapp1-v2-deployment.yaml │ │ ├── c2-02-myapp1-v2-clusterip-service.yaml │ │ ├── c4-01-gateway.yaml │ │ ├── c4-02-gateway-http-to-https-route.yaml │ │ ├── c4-03-gateway-app1-http-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-v1-deployment.tf │ │ ├── c4-02-myapp1-v1-clusterip-service.tf │ │ ├── c4-03-myapp2-v2-deployment.tf │ │ ├── c4-04-myapp2-v2-clusterip-service.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-to-https-route.tf │ │ ├── c5-03-gateway-app1-http-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 09-GKE-Gateway-API-HealthChecks-SessionAffinity │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ ├── p2-regional-k8sresources-yaml │ │ ├── c1-01-myapp1-deployment.yaml │ │ ├── c1-02-myapp1-clusterip-service.yaml │ │ ├── c1-03-myapp1-healthcheck.yaml │ │ ├── c1-04-session-affinity.yaml │ │ ├── c2-01-gateway.yaml │ │ ├── c2-02-gateway-http-route.yaml │ │ ├── c2-03-gateway-http-to-https-route.yaml │ │ └── self-signed-ssl │ │ │ ├── app1.crt │ │ │ ├── app1.csr │ │ │ └── app1.key │ └── p3-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-deployment.tf │ │ ├── c4-02-myapp1-clusterip-service.tf │ │ ├── c4-03-myapp1-healthcheck.tf │ │ ├── c4-04-myapp1-session-affinity.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-to-https-route.tf │ │ ├── c5-03-gateway-http-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 10-Cloud-Domains-and-Cloud-DNS │ ├── 01-Cloud-Domains-Basics │ │ └── README.md │ ├── 02-Cloud-DNS-Basics │ │ ├── README.md │ │ └── nginx-webserver.sh │ └── README.md ├── 11-GKE-Gateway-API-ProdSSL-CloudDNS │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ └── p2-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-deployment.tf │ │ ├── c4-02-myapp1-clusterip-service.tf │ │ ├── c4-03-myapp1-healthcheck.tf │ │ ├── c4-04-myapp1-session-affinity.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-to-https-route.tf │ │ ├── c5-03-gateway-http-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── c8-cloud-dns.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars ├── 12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-vpc.tf │ │ ├── c4-01-gke-cluster.tf │ │ ├── c4-02-gke-outputs.tf │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ └── terraform.tfvars │ └── p2-regional-k8sresources-terraform-manifests │ │ ├── c1-versions.tf │ │ ├── c2-01-variables.tf │ │ ├── c2-02-local-values.tf │ │ ├── c3-01-remote-state-datasource.tf │ │ ├── c3-02-providers.tf │ │ ├── c4-01-myapp1-deployment.tf │ │ ├── c4-02-myapp1-clusterip-service.tf │ │ ├── c4-03-myapp1-healthcheck.tf │ │ ├── c4-04-myapp1-session-affinity.tf │ │ ├── c5-01-gateway.tf │ │ ├── c5-02-gateway-http-to-https-route.tf │ │ ├── c5-03-gateway-http-route.tf │ │ ├── c6-static-ip.tf │ │ ├── c7-certificate-manager.tf │ │ ├── c8-cloud-dns.tf │ │ ├── self-signed-ssl │ │ ├── app1.crt │ │ ├── app1.csr │ │ └── app1.key │ │ └── terraform.tfvars └── 13-GKE-Gateway-API-Global-LB │ ├── README.md │ ├── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars │ ├── p2-global-k8sresources-yaml │ ├── 01-myapp1-deployment.yaml │ ├── 02-myapp1-clusterip-service.yaml │ ├── 03-gateway.yaml │ └── 04-gateway-http-route.yaml │ └── p3-global-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-myapp1-deployment.tf │ ├── c5-myapp1-clusterip-service.tf │ ├── c6-gateway.tf │ ├── c7-gateway-http-route.tf │ └── terraform.tfvars ├── 22-Terraform-Modules ├── 01-base-terraform-manifests │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-locals.tf │ ├── c4-vpc.tf │ ├── c5-firewalls.tf │ ├── c6-vminstance.tf │ ├── c7-outputs.tf │ └── terraform.tfvars ├── 02-terraform-manifests-with-modules │ ├── app1-webserver-install.sh │ ├── c1-versions.tf │ ├── c2-variables.tf │ ├── c3-locals.tf │ ├── c4-vpc.tf │ ├── c5-firewalls.tf │ ├── c6-vminstance.tf │ ├── c7-outputs.tf │ └── terraform.tfvars └── README.md ├── 23-GKE-Infra-Custom-Terraform-Modules ├── README.md ├── modules │ └── gke_cluster │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── p1-gke-autopilot-cluster-private │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-vpc.tf │ ├── c4-01-gke-cluster.tf │ ├── c4-02-gke-outputs.tf │ ├── c5-Cloud-NAT-Cloud-Router.tf │ └── terraform.tfvars ├── 24-GKE-Infra-DevOps-CloudBuild-GitHub ├── Git-Repo-files │ ├── .gitignore │ ├── README.md │ ├── cloudbuild.yaml │ ├── environments │ │ ├── dev │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-vpc.tf │ │ │ ├── c4-01-gke-cluster.tf │ │ │ ├── c4-02-gke-outputs.tf │ │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ │ └── terraform.tfvars │ │ └── prod │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-vpc.tf │ │ │ ├── c4-01-gke-cluster.tf │ │ │ ├── c4-02-gke-outputs.tf │ │ │ ├── c5-Cloud-NAT-Cloud-Router.tf │ │ │ └── terraform.tfvars │ ├── git-deploy.sh │ └── modules │ │ └── gke_cluster │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── README.md ├── 25-GKE-Workloads-Custom-Terraform-Modules ├── README.md ├── modules │ ├── gke_cluster │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf │ └── kubernetes_deployment │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── p2-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 26-GKE-Workloads-DevOps-CloudBuild-GitHub ├── Git-Repo-Files │ ├── .gitignore │ ├── README.md │ ├── cloudbuild.yaml │ ├── environments │ │ ├── dev │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-01-remote-state-datasource.tf │ │ │ ├── c3-02-providers.tf │ │ │ ├── c4-kubernetes-deployment.tf │ │ │ ├── c5-kubernetes-loadbalancer-service.tf │ │ │ └── terraform.tfvars │ │ └── prod │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-01-remote-state-datasource.tf │ │ │ ├── c3-02-providers.tf │ │ │ ├── c4-kubernetes-deployment.tf │ │ │ ├── c5-kubernetes-loadbalancer-service.tf │ │ │ └── terraform.tfvars │ ├── git-deploy.sh │ └── modules │ │ └── kubernetes_deployment │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── README.md ├── 27-GKE-App-Continuous-Integration ├── App-GitRepoFiles │ ├── .gitignore │ ├── BACKUP_v1-cloudbuild-ci.yaml │ ├── Dockerfile │ ├── README.md │ ├── cloudbuild.yaml │ ├── git-deploy.sh │ └── index.html ├── README.md ├── modules │ └── kubernetes_deployment │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── p2-k8sresources-terraform-manifests │ ├── c1-versions.tf │ ├── c2-01-variables.tf │ ├── c2-02-local-values.tf │ ├── c3-01-remote-state-datasource.tf │ ├── c3-02-providers.tf │ ├── c4-kubernetes-deployment.tf │ ├── c5-kubernetes-loadbalancer-service.tf │ └── terraform.tfvars ├── 28-GKE-App-Continuous-Delivery ├── 01-SSH-Keys │ ├── id_github │ └── id_github.pub ├── 02-App-GitRepoFiles │ ├── .gitignore │ ├── BACKUP_v1-cloudbuild-ci.yaml │ ├── BACKUP_v2-cloudbuild-ci-cd.yaml │ ├── Dockerfile │ ├── README.md │ ├── cloudbuild.yaml │ ├── git-deploy.sh │ ├── index.html │ ├── known_hosts.github │ └── main.tf.tpl ├── 03-K8s-GitRepoFiles │ ├── .gitignore │ ├── README.md │ ├── cloudbuild.yaml │ ├── environments │ │ ├── dev │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-01-remote-state-datasource.tf │ │ │ ├── c3-02-providers.tf │ │ │ ├── c4-kubernetes-deployment.tf │ │ │ ├── c5-kubernetes-loadbalancer-service.tf │ │ │ └── terraform.tfvars │ │ └── prod │ │ │ ├── c1-versions.tf │ │ │ ├── c2-01-variables.tf │ │ │ ├── c2-02-local-values.tf │ │ │ ├── c3-01-remote-state-datasource.tf │ │ │ ├── c3-02-providers.tf │ │ │ ├── c4-kubernetes-deployment.tf │ │ │ ├── c5-kubernetes-loadbalancer-service.tf │ │ │ └── terraform.tfvars │ ├── git-deploy.sh │ └── modules │ │ └── kubernetes_deployment │ │ ├── main.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── versions.tf └── README.md ├── README.md ├── course-presentation └── Terraform-on-GCP-GKE-v1.pptx ├── gcp-gke-terraform-1.png ├── gcp-gke-terraform-2.png └── git-deploy.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /02-Terraform-Commands/terraform-manifests/vpc.tf: -------------------------------------------------------------------------------- 1 | # Terraform Provider Configuration: google 2 | provider "google" { 3 | project = "gcplearn9" 4 | region = "us-central1" 5 | } 6 | 7 | # Resource: VPC 8 | resource "google_compute_network" "myvpc" { 9 | name = "vpc1" 10 | auto_create_subnetworks = false 11 | } 12 | 13 | # Resource: Subnet 14 | resource "google_compute_subnetwork" "mysubnet" { 15 | name = "subnet1" 16 | region = "us-central1" 17 | ip_cidr_range = "10.128.0.0/20" 18 | network = google_compute_network.myvpc.id // GET VPC ID 19 | } 20 | 21 | -------------------------------------------------------------------------------- /03-Terraform-Language-Basics/terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8.5" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.33.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = "gcplearn9" # PROJECT_ID 15 | region = "us-central1" 16 | } 17 | 18 | -------------------------------------------------------------------------------- /03-Terraform-Language-Basics/terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables (Place-holder file for this demo) 2 | -------------------------------------------------------------------------------- /03-Terraform-Language-Basics/terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "subnet1" 10 | region = "us-central1" 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /04-Terraform-MetaArgument-provider/terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.34.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider-1: us-central1 13 | provider "google" { 14 | project = "gcplearn9" 15 | region = "us-central1" 16 | alias = "us-central1" 17 | } 18 | 19 | # Terraform Provider-2: europe-west1 20 | provider "google" { 21 | project = "gcplearn9" 22 | region = "europe-west1" 23 | alias = "europe-west1" 24 | } -------------------------------------------------------------------------------- /04-Terraform-MetaArgument-provider/terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.34.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = var.gcp_project 15 | region = var.gcp_region1 16 | } -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # GCP Project 3 | variable "gcp_project" { 4 | description = "Project in which GCP Resources to be created" 5 | type = string 6 | default = "kdaida123" 7 | } 8 | 9 | # GCP Region 10 | variable "gcp_region1" { 11 | description = "Region in which GCP Resources to be created" 12 | type = string 13 | default = "us-east1" 14 | } 15 | 16 | # GCP Compute Engine Machine Type 17 | variable "machine_type" { 18 | description = "Compute Engine Machine Type" 19 | type = string 20 | default = "e2-small" 21 | } -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/vm.auto.tfvars: -------------------------------------------------------------------------------- 1 | # machine_type = "e2-medium" -------------------------------------------------------------------------------- /05-Terraform-Variables-Output-Values/terraform-manifests/vm.tfvars: -------------------------------------------------------------------------------- 1 | # machine_type = "e2-standard-2" -------------------------------------------------------------------------------- /06-Terraform-MetaArgument-count/terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.26.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = var.gcp_project 15 | region = var.gcp_region1 16 | } -------------------------------------------------------------------------------- /06-Terraform-MetaArgument-count/terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # GCP Project 3 | variable "gcp_project" { 4 | description = "Project in which GCP Resources to be created" 5 | type = string 6 | default = "kdaida123" 7 | } 8 | 9 | # GCP Region 10 | variable "gcp_region1" { 11 | description = "Region in which GCP Resources to be created" 12 | type = string 13 | default = "us-east1" 14 | } 15 | 16 | # GCP Compute Engine Machine Type 17 | variable "machine_type" { 18 | description = "Compute Engine Machine Type" 19 | type = string 20 | default = "e2-small" 21 | } -------------------------------------------------------------------------------- /06-Terraform-MetaArgument-count/terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /06-Terraform-MetaArgument-count/terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" -------------------------------------------------------------------------------- /07-Terraform-Datasources/terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.26.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = var.gcp_project 15 | region = var.gcp_region1 16 | } -------------------------------------------------------------------------------- /07-Terraform-Datasources/terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # GCP Project 3 | variable "gcp_project" { 4 | description = "Project in which GCP Resources to be created" 5 | type = string 6 | default = "kdaida123" 7 | } 8 | 9 | # GCP Region 10 | variable "gcp_region1" { 11 | description = "Region in which GCP Resources to be created" 12 | type = string 13 | default = "us-east1" 14 | } 15 | 16 | # GCP Compute Engine Machine Type 17 | variable "machine_type" { 18 | description = "Compute Engine Machine Type" 19 | type = string 20 | default = "e2-small" 21 | } -------------------------------------------------------------------------------- /07-Terraform-Datasources/terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /07-Terraform-Datasources/terraform-manifests/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | /* Datasource: Get a list of Google 3 | Compute zones that are UP in a region */ 4 | data "google_compute_zones" "available" { 5 | status = "UP" 6 | } 7 | 8 | # Output value 9 | output "compute_zones" { 10 | description = "List of compute zones" 11 | value = data.google_compute_zones.available.names 12 | } 13 | -------------------------------------------------------------------------------- /07-Terraform-Datasources/terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D1-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.35.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = var.gcp_project 15 | region = var.gcp_region1 16 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D1-terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # GCP Project 3 | variable "gcp_project" { 4 | description = "Project in which GCP Resources to be created" 5 | type = string 6 | default = "kdaida123" 7 | } 8 | 9 | # GCP Region 10 | variable "gcp_region1" { 11 | description = "Region in which GCP Resources to be created" 12 | type = string 13 | default = "us-east1" 14 | } 15 | 16 | # GCP Compute Engine Machine Type 17 | variable "machine_type" { 18 | description = "Compute Engine Machine Type" 19 | type = string 20 | default = "e2-small" 21 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D1-terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D1-terraform-manifests/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D1-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D2-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.8" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.35.0" 8 | } 9 | } 10 | } 11 | 12 | # Terraform Provider Block 13 | provider "google" { 14 | project = var.gcp_project 15 | region = var.gcp_region1 16 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D2-terraform-manifests/c2-variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | # GCP Project 3 | variable "gcp_project" { 4 | description = "Project in which GCP Resources to be created" 5 | type = string 6 | default = "kdaida123" 7 | } 8 | 9 | # GCP Region 10 | variable "gcp_region1" { 11 | description = "Region in which GCP Resources to be created" 12 | type = string 13 | default = "us-east1" 14 | } 15 | 16 | # GCP Compute Engine Machine Type 17 | variable "machine_type" { 18 | description = "Compute Engine Machine Type" 19 | type = string 20 | default = "e2-small" 21 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D2-terraform-manifests/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "vpc1" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D2-terraform-manifests/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | -------------------------------------------------------------------------------- /08-Terraform-MetaArgument-foreach/D2-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-public" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "${local.name}-vpc" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${local.name}-${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | private_ip_google_access = true 14 | } -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/c5-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /09-GKE-Public-Standard-Cluster/p1-gke-public-cluster/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-public" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "${local.name}-vpc" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${local.name}-${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | private_ip_google_access = true 14 | } -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/c5-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p1-gke-public-cluster/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p2-k8sresources-yaml/01-kubernetes-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: # Dictionary 4 | name: myapp1-deployment 5 | spec: # Dictionary 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: myapp1 10 | template: 11 | metadata: # Dictionary 12 | name: myapp1-pod 13 | labels: 14 | app: myapp1 # Key Value Pairs 15 | spec: 16 | containers: # List 17 | - name: myapp1-container 18 | image: ghcr.io/stacksimplify/kubenginx:1.0.0 19 | ports: 20 | - containerPort: 80 -------------------------------------------------------------------------------- /10-Kubernetes-Resources-yaml/p2-k8sresources-yaml/02-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-public" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/c3-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "${local.name}-vpc" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${local.name}-${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | private_ip_google_access = true 14 | } -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/c5-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p1-gke-public-cluster/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p2-k8sresources-yaml/01-kubernetes-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: # Dictionary 4 | name: myapp1-deployment 5 | spec: # Dictionary 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: myapp1 10 | template: 11 | metadata: # Dictionary 12 | name: myapp1-pod 13 | labels: 14 | app: myapp1 # Key Value Pairs 15 | spec: 16 | containers: # List 17 | - name: myapp1-container 18 | image: ghcr.io/stacksimplify/kubenginx:1.0.0 19 | ports: 20 | - containerPort: 80 -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p2-k8sresources-yaml/02-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.31" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-public" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /11-Kubernetes-Resources-Terraform/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | 13 | -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/c6-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p1-gke-private-cluster-autoscaler/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" 6 | subnet_ip_range = "10.128.0.0/20" 7 | pods_ip_range = "10.1.0.0/21" 8 | services_ip_range = "10.2.0.0/21" 9 | master_ip_range = "10.3.0.0/28" 10 | -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p2-k8sresources-yaml/02-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /12-GKE-Private-Standard-Cluster-Autoscaler/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | 13 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c6-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" 6 | subnet_ip_range = "10.128.0.0/20" 7 | pods_ip_range = "10.1.0.0/21" 8 | services_ip_range = "10.2.0.0/21" 9 | master_ip_range = "10.3.0.0/28" 10 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p2-k8sresources-yaml-hpa-v1/02-kubernetes-cip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-cip-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port 13 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p2-k8sresources-yaml-hpa-v1/03-kubernetes-hpa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: autoscaling/v1 2 | kind: HorizontalPodAutoscaler 3 | metadata: 4 | name: hpa-myapp1 5 | spec: 6 | scaleTargetRef: 7 | apiVersion: apps/v1 8 | kind: Deployment 9 | name: myapp1-deployment 10 | minReplicas: 1 11 | maxReplicas: 10 12 | targetCPUUtilizationPercentage: 30 13 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p3-k8sresources-yaml-hpa-v2/02-kubernetes-cip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-cip-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port 13 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p3-k8sresources-yaml-hpa-v2/03-kubernetes-hpa.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: autoscaling/v2 2 | kind: HorizontalPodAutoscaler 3 | metadata: 4 | name: myapp1-hpa 5 | spec: 6 | scaleTargetRef: 7 | apiVersion: apps/v1 8 | kind: Deployment 9 | name: myapp1-deployment 10 | minReplicas: 1 11 | maxReplicas: 10 12 | metrics: 13 | - type: Resource 14 | resource: 15 | name: cpu 16 | target: 17 | type: Utilization 18 | averageUtilization: 30 -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p4-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p4-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p4-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p4-k8sresources-terraform-manifests/c5-kubernetes-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: Load Balancer) 2 | resource "kubernetes_service_v1" "cip_service" { 3 | metadata { 4 | name = "myapp1-cip-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /13-GKE-Horizontal-Pod-Autoscaling/p4-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.40.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c4-firewallrules.tf: -------------------------------------------------------------------------------- 1 | # Firewall Rule: SSH 2 | resource "google_compute_firewall" "fw_ssh" { 3 | name = "${local.name}-fwrule-allow-ssh22" 4 | allow { 5 | ports = ["22"] 6 | protocol = "tcp" 7 | } 8 | direction = "INGRESS" 9 | network = google_compute_network.myvpc.id 10 | priority = 1000 11 | source_ranges = ["0.0.0.0/0"] 12 | target_tags = ["ssh-tag"] 13 | } 14 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | 13 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/c6-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p1-gke-private-cluster-autoscaler/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" 6 | subnet_ip_range = "10.128.0.0/20" 7 | pods_ip_range = "10.1.0.0/21" 8 | services_ip_range = "10.2.0.0/21" 9 | master_ip_range = "10.3.0.0/28" 10 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p2-k8sresources-yaml-vpa/02-kubernetes-cip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-cip-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port 13 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p3-k8sresources-terraform-manifests/c5-kubernetes-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: Load Balancer) 2 | resource "kubernetes_service_v1" "cip_service" { 3 | metadata { 4 | name = "myapp1-cip-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /14-GKE-Vertical-Pod-Autoscaling/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p1-gke-private-cluster-private-endpoint/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p1-gke-private-cluster-private-endpoint/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p1-gke-private-cluster-private-endpoint/c5-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Datasources 2 | # Datasource: Get a list of Google Compute zones that are UP in a region 3 | data "google_compute_zones" "available" { 4 | status = "UP" 5 | } 6 | 7 | # Output value 8 | output "compute_zones" { 9 | description = "List of compute zones" 10 | value = data.google_compute_zones.available.names 11 | } 12 | 13 | -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p1-gke-private-cluster-private-endpoint/c6-01-gke-service-account.tf: -------------------------------------------------------------------------------- 1 | resource "google_service_account" "gke_sa" { 2 | account_id = "${local.name}-gke-sa" 3 | display_name = "${local.name} GKE Service Account" 4 | } -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p1-gke-private-cluster-private-endpoint/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-medium" 4 | environment = "dev" 5 | business_divsion = "hr" 6 | subnet_ip_range = "10.128.0.0/20" 7 | pods_ip_range = "10.1.0.0/21" 8 | services_ip_range = "10.2.0.0/21" 9 | master_ip_range = "10.3.0.0/28" 10 | -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p2-k8sresources-yaml/02-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /15-GKE-Private-Standard-Cluster-private-endpoint/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p2-k8sresources-yaml/02-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port 13 | -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /16-GKE-Private-Autopilot-cluster/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p2-k8sresources-yaml/00-storage-class.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: storage.k8s.io/v1 2 | kind: StorageClass 3 | metadata: 4 | name: gke-pd-standard-rwo-sc 5 | provisioner: pd.csi.storage.gke.io 6 | volumeBindingMode: WaitForFirstConsumer 7 | allowVolumeExpansion: true 8 | reclaimPolicy: Retain 9 | parameters: 10 | type: pd-balanced # Other Options supported are pd-ssd, pd-standard 11 | 12 | # STORAGE CLASS 13 | # 1. A StorageClass provides a way for administrators 14 | # to describe the "classes" of storage they offer. 15 | # 2. Here we are offering GCP PD Storage for GKE Cluster -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p2-k8sresources-yaml/04-mysql-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mysql 5 | spec: 6 | selector: 7 | app: mysql 8 | ports: 9 | - port: 3306 10 | clusterIP: None # This means we are going to use Pod IP -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p2-k8sresources-yaml/06-UserMgmtWebApp-LoadBalancer-Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: usermgmt-webapp-lb-service 5 | labels: 6 | app: usermgmt-webapp 7 | spec: 8 | type: LoadBalancer 9 | selector: 10 | app: usermgmt-webapp 11 | ports: 12 | - port: 80 # Service Port 13 | targetPort: 8080 # Container Port -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/ums-webapp-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/c4-01-storage-class.tf: -------------------------------------------------------------------------------- 1 | # Resource: Kubernetes Storage Class 2 | resource "kubernetes_storage_class_v1" "gke_sc" { 3 | metadata { 4 | name = "gke-pd-standard-rwo-sc" 5 | } 6 | storage_provisioner = "pd.csi.storage.gke.io" 7 | volume_binding_mode = "WaitForFirstConsumer" 8 | allow_volume_expansion = true 9 | reclaim_policy = "Retain" 10 | parameters = { 11 | type = "pd-balanced" # Other Options supported are pd-ssd 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/c4-03-UserMgmtWebApp-ConfigMap.tf: -------------------------------------------------------------------------------- 1 | # Resource: Config Map 2 | resource "kubernetes_config_map_v1" "config_map" { 3 | metadata { 4 | name = "usermanagement-dbcreation-script" 5 | } 6 | data = { 7 | "webappdb.sql" = "${file("${path.module}/webappdb.sql")}" 8 | } 9 | } -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /17-GKE-Storage-Persistent-Disks/p3-k8sresources-terraform-manifests/webappdb.sql: -------------------------------------------------------------------------------- 1 | DROP DATABASE IF EXISTS webappdb; 2 | CREATE DATABASE webappdb; -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "cloudsql/privatedb" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_vpc_id" { 11 | value = data.terraform_remote_state.gke.outputs.vpc_id 12 | } 13 | 14 | output "p1_vpc_self_link" { 15 | value = data.terraform_remote_state.gke.outputs.vpc_self_link 16 | } 17 | 18 | output "p1_mysubnet_id" { 19 | value = data.terraform_remote_state.gke.outputs.mysubnet_id 20 | } 21 | -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/c4-02-cloudsql-outputs.tf: -------------------------------------------------------------------------------- 1 | output "cloudsql_db_private_ip" { 2 | value = google_sql_database_instance.mydbinstance.private_ip_address 3 | } 4 | 5 | output "mydb_schema" { 6 | value = google_sql_database.mydbschema.name 7 | } 8 | 9 | output "mydb_user" { 10 | value = google_sql_user.users.name 11 | } 12 | 13 | output "mydb_password" { 14 | value = google_sql_user.users.password 15 | sensitive = true 16 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/mysql-client-install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # Update package list 3 | sudo apt update 4 | 5 | # Install telnet (For Troubelshooting) 6 | sudo apt install -y telnet 7 | 8 | # Install MySQL Client (For Troubelshooting) 9 | sudo apt install -y default-mysql-client 10 | -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p2-cloudsql-privatedb/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | cloudsql_database_version = "MYSQL_8_0" -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/ums-webapp-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /18-GKE-Storage-CloudSQL/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p2-k8sresources-yaml/c1-k8s-namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: mydemo1ns 5 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p2-k8sresources-yaml/c2-k8s-serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: mydemo1sa 5 | namespace: mydemo1ns 6 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p2-k8sresources-yaml/c3-k8s-pv.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolume 3 | metadata: 4 | name: gcs-fuse-csi-pv 5 | spec: 6 | accessModes: 7 | - ReadWriteMany 8 | capacity: 9 | storage: 5Gi 10 | storageClassName: dummy-storage-class 11 | mountOptions: 12 | - implicit-dirs 13 | csi: 14 | driver: gcsfuse.csi.storage.gke.io 15 | volumeHandle: gke-object-storage-102 16 | volumeAttributes: 17 | gcsfuseLoggingSeverity: warning -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p2-k8sresources-yaml/c4-k8s-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: gcs-fuse-csi-static-pvc 5 | namespace: mydemo1ns 6 | spec: 7 | accessModes: 8 | - ReadWriteMany 9 | resources: 10 | requests: 11 | storage: 5Gi 12 | volumeName: gcs-fuse-csi-pv 13 | storageClassName: dummy-storage-class -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p2-k8sresources-yaml/c6-kubernetes-loadbalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | namespace: mydemo1ns 6 | spec: 7 | type: LoadBalancer # ClusterIp, # NodePort 8 | selector: 9 | app: myapp1 10 | ports: 11 | - name: http 12 | port: 80 # Service Port 13 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/gcs-fuse-storage-demo" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/c5-02-namespace.tf: -------------------------------------------------------------------------------- 1 | # Resource: Kubernetes Namespace 2 | resource "kubernetes_namespace" "myns" { 3 | metadata { 4 | name = "${local.name}-mydemo-ns" 5 | } 6 | } 7 | 8 | # Outputs 9 | output "my_namespace" { 10 | value = kubernetes_namespace.myns.metadata[0].name 11 | } -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/c5-04-service-account.tf: -------------------------------------------------------------------------------- 1 | # Resource: Kubernetes Service Account 2 | resource "kubernetes_service_account" "mysa" { 3 | metadata { 4 | name = "${local.name}-mydemosa" 5 | namespace = kubernetes_namespace.myns.metadata[0].name 6 | } 7 | } 8 | 9 | # Outputs 10 | output "my_serviceaccount" { 11 | value = kubernetes_service_account.mysa.metadata[0].name 12 | } -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/static-files/file1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

File-1: Welcome to StackSimplify: FROM GCP CLOUD STORAGE BUCKET

5 |

Application Version: V1

6 |

Google Cloud Platform - Demos

7 | 8 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/static-files/file2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

File-2: Welcome to StackSimplify: FROM GCP CLOUD STORAGE BUCKET

5 |

Application Version: V1

6 |

Google Cloud Platform - Demos

7 | 8 | -------------------------------------------------------------------------------- /19-GKE-Cloud-Storage-FUSE-CSI/static-files/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome to StackSimplify: FROM GCP CLOUD STORAGE BUCKET

5 |

Application Version: V1

6 |

Google Cloud Platform - Demos

7 | 8 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p2-k8sresources-yaml/00-filestore-storage-class.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: storage.k8s.io/v1 2 | kind: StorageClass 3 | metadata: 4 | name: filestore-storage-class 5 | provisioner: filestore.csi.storage.gke.io # File Store CSI Driver 6 | volumeBindingMode: WaitForFirstConsumer 7 | allowVolumeExpansion: true 8 | parameters: 9 | tier: standard # Allowed values standard, premium, or enterprise 10 | network: hr-dev-vpc # The network parameter can be used when provisioning Filestore instances on non-default VPCs. -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p2-k8sresources-yaml/01-filestore-pvc.yaml: -------------------------------------------------------------------------------- 1 | kind: PersistentVolumeClaim 2 | apiVersion: v1 3 | metadata: 4 | name: gke-filestore-pvc 5 | spec: 6 | accessModes: 7 | - ReadWriteMany 8 | storageClassName: filestore-storage-class 9 | resources: 10 | requests: 11 | storage: 1Ti 12 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p2-k8sresources-yaml/02-write-to-filestore-pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: filestore-writer-app 5 | spec: 6 | containers: 7 | - name: app 8 | image: centos 9 | command: ["/bin/sh"] 10 | args: ["-c", "while true; do echo GCP Cloud FileStore used as PV in GKE $(date -u) >> /data/myapp1.txt; sleep 5; done"] 11 | volumeMounts: 12 | - name: my-filestore-storage 13 | mountPath: /data 14 | volumes: 15 | - name: my-filestore-storage 16 | persistentVolumeClaim: 17 | claimName: gke-filestore-pvc -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p2-k8sresources-yaml/04-loadBalancer-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-lb-service 5 | spec: 6 | type: LoadBalancer # ClusterIp, # NodePort 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port 13 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p3-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/filestore-demo" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p3-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p3-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p3-k8sresources-terraform-manifests/c4-01-storage-class.tf: -------------------------------------------------------------------------------- 1 | # Resource: Kubernetes Storage Class 2 | resource "kubernetes_storage_class_v1" "filestore_sc" { 3 | metadata { 4 | name = "my-gke-filestore-sc" 5 | } 6 | storage_provisioner = "filestore.csi.storage.gke.io" # File Store CSI Driver 7 | volume_binding_mode = "WaitForFirstConsumer" 8 | allow_volume_expansion = true 9 | parameters = { 10 | tier = "standard" 11 | network = data.terraform_remote_state.gke.outputs.vpc_name 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /20-GKE-Storage-Filestore/p3-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.38.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p2-regional-k8sresources-yaml/03-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p2-regional-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | rules: 10 | - backendRefs: 11 | - name: myapp1-service 12 | port: 80 13 | weight: 100 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.37.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.31" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/c6-gateway.tf: -------------------------------------------------------------------------------- 1 | resource "kubernetes_manifest" "my_gateway" { 2 | manifest = { 3 | apiVersion = "gateway.networking.k8s.io/v1" 4 | kind = "Gateway" 5 | metadata = { 6 | name = "mygateway1-regional" 7 | namespace = "default" 8 | } 9 | spec = { 10 | gatewayClassName = "gke-l7-regional-external-managed" 11 | listeners = [ 12 | { 13 | name = "http" 14 | protocol = "HTTP" 15 | port = 80 16 | } 17 | ] 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/01-GKE-LB-Gateway-API-Basic/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.38.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p2-regional-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | rules: 10 | - backendRefs: 11 | - name: myapp1-service 12 | port: 80 13 | weight: 100 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.37.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.31" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/c8-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/02-GKE-LB-Gateway-API-StaticIP/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p2-regional-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | rules: 10 | - backendRefs: 11 | - name: myapp1-service 12 | port: 80 13 | weight: 100 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c8-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/c9-kubernetes-secret.tf: -------------------------------------------------------------------------------- 1 | resource "kubernetes_secret" "tls_secret" { 2 | metadata { 3 | name = "${local.name}-my-tls-secret" 4 | namespace = "default" 5 | } 6 | type = "kubernetes.io/tls" 7 | data = { 8 | "tls.crt" = file("${path.module}/self-signed-ssl/app1.crt") 9 | "tls.key" = file("${path.module}/self-signed-ssl/app1.key") 10 | } 11 | } 12 | 13 | output "tls_secret_name" { 14 | value = kubernetes_secret.tls_secret.metadata[0].name 15 | } 16 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/03-GKE-Gateway-API-Selfsigned-SSL-k8sSecrets/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p2-regional-k8sresources-yaml/03-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: https 9 | protocol: HTTPS 10 | port: 443 11 | tls: 12 | mode: Terminate 13 | options: 14 | networking.gke.io/cert-manager-certs: app1-us-central1-cert 15 | addresses: 16 | - type: NamedAddress 17 | value: my-regional-ip1 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p2-regional-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | rules: 10 | - backendRefs: 11 | - name: myapp1-service 12 | port: 80 13 | weight: 100 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/c8-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/04-GKE-Gateway-API-Selfsigned-SSL-CertManager/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p2-regional-k8sresources-yaml/03-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | - name: https 12 | protocol: HTTPS 13 | port: 443 14 | tls: 15 | mode: Terminate 16 | options: 17 | networking.gke.io/cert-manager-certs: app1-us-central1-cert 18 | addresses: 19 | - type: NamedAddress 20 | value: my-regional-ip1 21 | 22 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p2-regional-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | rules: 11 | - backendRefs: 12 | - name: myapp1-service 13 | port: 80 14 | weight: 100 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p2-regional-k8sresources-yaml/05-gateway-http-to-https-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: redirect 5 | spec: 6 | parentRefs: 7 | - name: mygateway1-regional 8 | sectionName: http 9 | rules: 10 | - filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | scheme: https -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.42.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/c7-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/05-GKE-Gateway-API-HTTP-to-HTTPS-Redirect/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/curl-pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: curl-pod 5 | spec: 6 | containers: 7 | - name: curl 8 | image: curlimages/curl 9 | command: [ "sleep", "600" ] -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p2-regional-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p2-regional-k8sresources-yaml/04-myapp2-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp2-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp2 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p2-regional-k8sresources-yaml/06-myapp3-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp3-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp3 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p2-regional-k8sresources-yaml/07-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | - name: https 12 | protocol: HTTPS 13 | port: 443 14 | tls: 15 | mode: Terminate 16 | options: 17 | networking.gke.io/cert-manager-certs: app1-us-central1-cert 18 | addresses: 19 | - type: NamedAddress 20 | value: my-regional-ip1 21 | 22 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p2-regional-k8sresources-yaml/09-gateway-http-to-https-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: redirect 5 | spec: 6 | parentRefs: 7 | - name: mygateway1-regional 8 | sectionName: http 9 | rules: 10 | - filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | scheme: https -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c4-02-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp1_service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c4-04-myapp2-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp2_service" { 3 | metadata { 4 | name = "myapp2-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp2.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c4-06-myapp3-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp3_service" { 3 | metadata { 4 | name = "myapp3-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp3.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/06-GKE-Gateway-API-ContextPath-Routing/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c1-02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c2-02-myapp2-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp2-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp2 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c3-02-myapp3-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp3-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp3 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c4-01-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | - name: https 12 | protocol: HTTPS 13 | port: 443 14 | tls: 15 | mode: Terminate 16 | options: 17 | networking.gke.io/cert-manager-certs: app1-us-central1-cert 18 | addresses: 19 | - type: NamedAddress 20 | value: my-regional-ip1 21 | 22 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c4-02-gateway-http-to-https-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: redirect 5 | spec: 6 | parentRefs: 7 | - name: mygateway1-regional 8 | sectionName: http 9 | rules: 10 | - filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | scheme: https -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c4-03-gateway-app1-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: app1-route 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | hostnames: 11 | - "app1.stacksimplify.com" 12 | rules: 13 | - matches: 14 | - path: 15 | type: PathPrefix 16 | value: /app1 17 | backendRefs: 18 | - name: myapp1-service 19 | port: 80 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c4-04-gateway-app2-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: app2-route 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | hostnames: 11 | - "app2.stacksimplify.com" 12 | rules: 13 | - matches: 14 | - path: 15 | type: PathPrefix 16 | value: /app2 17 | backendRefs: 18 | - name: myapp2-service 19 | port: 80 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p2-regional-k8sresources-yaml/c4-05-gateway-app3-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: app3-default-route 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | rules: 11 | - backendRefs: 12 | - name: myapp3-service 13 | port: 80 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c4-02-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp1_service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c4-04-myapp2-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp2_service" { 3 | metadata { 4 | name = "myapp2-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp2.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c4-06-myapp3-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp3_service" { 3 | metadata { 4 | name = "myapp3-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp3.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/07-GKE-Gateway-API-Domain-Routing/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/curl-pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: curl-pod 5 | spec: 6 | containers: 7 | - name: curl 8 | image: curlimages/curl 9 | command: [ "sleep", "600" ] -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p2-regional-k8sresources-yaml/c1-02-myapp1-v1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service-v1 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1-v1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p2-regional-k8sresources-yaml/c2-02-myapp1-v2-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service-v2 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1-v2 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p2-regional-k8sresources-yaml/c4-01-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-regional 5 | spec: 6 | gatewayClassName: gke-l7-regional-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | - name: https 12 | protocol: HTTPS 13 | port: 443 14 | tls: 15 | mode: Terminate 16 | options: 17 | networking.gke.io/cert-manager-certs: app1-us-central1-cert 18 | addresses: 19 | - type: NamedAddress 20 | value: my-regional-ip1 21 | 22 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p2-regional-k8sresources-yaml/c4-02-gateway-http-to-https-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: redirect 5 | spec: 6 | parentRefs: 7 | - name: mygateway1-regional 8 | sectionName: http 9 | rules: 10 | - filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | scheme: https -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p2-regional-k8sresources-yaml/c4-03-gateway-app1-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: app1-route 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | rules: 11 | - backendRefs: 12 | - name: myapp1-service-v1 13 | port: 80 14 | weight: 50 15 | - name: myapp1-service-v2 16 | port: 80 17 | weight: 50 18 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c4-02-myapp1-v1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp1_service_v1" { 3 | metadata { 4 | name = "myapp1-service-v1" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1_v1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c4-04-myapp2-v2-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "myapp1_service_v2" { 3 | metadata { 4 | name = "myapp1-service-v2" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1_v2.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/08-GKE-Gateway-API-Traffic-Splitting/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p2-regional-k8sresources-yaml/c1-02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p2-regional-k8sresources-yaml/c1-04-session-affinity.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.gke.io/v1 2 | kind: GCPBackendPolicy 3 | metadata: 4 | name: myapp1-backend-policy 5 | namespace: default 6 | spec: 7 | default: 8 | sessionAffinity: 9 | type: GENERATED_COOKIE # or CLIENT_IP 10 | cookieTtlSec: 50 11 | targetRef: 12 | group: "" 13 | kind: Service 14 | name: myapp1-service -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p2-regional-k8sresources-yaml/c2-02-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1beta1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-regional 9 | sectionName: https 10 | rules: 11 | - backendRefs: 12 | - name: myapp1-service 13 | port: 80 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p2-regional-k8sresources-yaml/c2-03-gateway-http-to-https-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1beta1 3 | metadata: 4 | name: redirect 5 | spec: 6 | parentRefs: 7 | - name: mygateway1-regional 8 | sectionName: http 9 | rules: 10 | - filters: 11 | - type: RequestRedirect 12 | requestRedirect: 13 | scheme: https -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/c4-02-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/09-GKE-Gateway-API-HealthChecks-SessionAffinity/p3-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/10-Cloud-Domains-and-Cloud-DNS/02-Cloud-DNS-Basics/nginx-webserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt install -y telnet 3 | sudo apt install -y nginx 4 | sudo systemctl enable nginx 5 | sudo chmod -R 755 /var/www/html 6 | HOSTNAME=$(hostname) 7 | sudo echo "

Welcome to StackSimplify - WebVM App1

VM Hostname: $HOSTNAME

VM IP Address: $(hostname -I)

Application Version: V1

Google Cloud Platform - Demos

" | sudo tee /var/www/html/index.html 8 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/10-Cloud-Domains-and-Cloud-DNS/README.md: -------------------------------------------------------------------------------- 1 | # Cloud Domains and Cloud DNS -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/c4-02-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/11-GKE-Gateway-API-ProdSSL-CloudDNS/p2-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-regional-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/c4-02-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/c6-static-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "static_ip" { 2 | name = "${local.name}-my-regional-ip" 3 | region = var.gcp_region1 4 | network_tier = "STANDARD" 5 | } 6 | 7 | output "static_ip_address" { 8 | value = google_compute_address.static_ip.address 9 | } 10 | 11 | output "static_ip_name" { 12 | value = google_compute_address.static_ip.name 13 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/12-GKE-Gateway-API-ProdSSL-ExternalDomainProvider/p2-regional-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.38.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p2-global-k8sresources-yaml/02-myapp1-clusterip-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: myapp1-service 5 | spec: 6 | type: ClusterIP # ClusterIP, # NodePort # LoadBalancer 7 | selector: 8 | app: myapp1 9 | ports: 10 | - name: http 11 | port: 80 # Service Port 12 | targetPort: 80 # Container Port -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p2-global-k8sresources-yaml/03-gateway.yaml: -------------------------------------------------------------------------------- 1 | kind: Gateway 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: mygateway1-global 5 | spec: 6 | gatewayClassName: gke-l7-global-external-managed 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p2-global-k8sresources-yaml/04-gateway-http-route.yaml: -------------------------------------------------------------------------------- 1 | kind: HTTPRoute 2 | apiVersion: gateway.networking.k8s.io/v1 3 | metadata: 4 | name: route-external-http 5 | spec: 6 | parentRefs: 7 | - kind: Gateway 8 | name: mygateway1-global 9 | rules: 10 | - backendRefs: 11 | - name: myapp1-service 12 | port: 80 -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "dev/k8s-gateway-global-demo1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster-private-autopilot" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/c5-myapp1-clusterip-service.tf: -------------------------------------------------------------------------------- 1 | # Kubernetes Service Manifest (Type: ClusterIP) 2 | resource "kubernetes_service_v1" "service" { 3 | metadata { 4 | name = "myapp1-service" 5 | } 6 | spec { 7 | selector = { 8 | app = kubernetes_deployment_v1.myapp1.spec.0.selector.0.match_labels.app 9 | } 10 | port { 11 | name = "http" 12 | port = 80 13 | target_port = 80 14 | } 15 | type = "ClusterIP" 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/c6-gateway.tf: -------------------------------------------------------------------------------- 1 | resource "kubernetes_manifest" "my_gateway" { 2 | manifest = { 3 | apiVersion = "gateway.networking.k8s.io/v1" 4 | kind = "Gateway" 5 | metadata = { 6 | name = "mygateway1-global" 7 | namespace = "default" 8 | } 9 | spec = { 10 | gatewayClassName = "gke-l7-global-external-managed" 11 | listeners = [{ 12 | name = "http" 13 | protocol = "HTTP" 14 | port = 80 15 | }] 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /21-GKE-Gateway-API/13-GKE-Gateway-API-Global-LB/p3-global-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /22-Terraform-Modules/01-base-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "gcplearn9-tfstate" 12 | prefix = "env/tfvm-base" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } 21 | 22 | -------------------------------------------------------------------------------- /22-Terraform-Modules/01-base-terraform-manifests/c3-locals.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /22-Terraform-Modules/01-base-terraform-manifests/c4-vpc.tf: -------------------------------------------------------------------------------- 1 | # Resource: VPC 2 | resource "google_compute_network" "myvpc" { 3 | name = "${local.name}-vpc" 4 | auto_create_subnetworks = false 5 | } 6 | 7 | # Resource: Subnet 8 | resource "google_compute_subnetwork" "mysubnet" { 9 | name = "${local.name}-${var.gcp_region1}-subnet" 10 | region = var.gcp_region1 11 | ip_cidr_range = "10.128.0.0/20" 12 | network = google_compute_network.myvpc.id 13 | } 14 | -------------------------------------------------------------------------------- /22-Terraform-Modules/01-base-terraform-manifests/c7-outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Output Values 2 | output "vpc_id" { 3 | description = "VPC ID" 4 | value = google_compute_network.myvpc.id 5 | } 6 | output "subnet_id" { 7 | description = "Subnet ID" 8 | value = google_compute_subnetwork.mysubnet.id 9 | } 10 | output "vm_external_ip" { 11 | description = "VM External IPs" 12 | value = google_compute_instance.myapp1.network_interface.0.access_config.0.nat_ip 13 | } 14 | -------------------------------------------------------------------------------- /22-Terraform-Modules/01-base-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" 4 | environment = "dev" 5 | business_divsion = "hr" -------------------------------------------------------------------------------- /22-Terraform-Modules/02-terraform-manifests-with-modules/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "gcplearn9-tfstate" 12 | prefix = "env/tf-module" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region1 20 | } 21 | 22 | -------------------------------------------------------------------------------- /22-Terraform-Modules/02-terraform-manifests-with-modules/c3-locals.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /22-Terraform-Modules/02-terraform-manifests-with-modules/c7-outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Output Values 2 | output "vpc_id" { 3 | description = "VPC ID" 4 | #value = google_compute_network.myvpc.id 5 | value = module.vpc.network_id 6 | } 7 | output "subnet_id" { 8 | description = "Subnet ID" 9 | #value = google_compute_subnetwork.mysubnet.id 10 | value = module.vpc.subnets_ids[0] 11 | } 12 | output "vm_external_ip" { 13 | description = "VM External IPs" 14 | value = google_compute_instance.myapp1.network_interface.0.access_config.0.nat_ip 15 | } 16 | -------------------------------------------------------------------------------- /22-Terraform-Modules/02-terraform-manifests-with-modules/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | machine_type = "e2-micro" 4 | environment = "dev" 5 | business_divsion = "hr" -------------------------------------------------------------------------------- /23-GKE-Infra-Custom-Terraform-Modules/modules/gke_cluster/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /23-GKE-Infra-Custom-Terraform-Modules/p1-gke-autopilot-cluster-private/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster-private-autopilot" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region 20 | } -------------------------------------------------------------------------------- /23-GKE-Infra-Custom-Terraform-Modules/p1-gke-autopilot-cluster-private/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /23-GKE-Infra-Custom-Terraform-Modules/p1-gke-autopilot-cluster-private/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/README.md: -------------------------------------------------------------------------------- 1 | # terraform-gcp-gke-devops1 2 | Implement DevOps Pipelines for Terraform Configs on GCP GKE (Google Kubernetes Engine) Resources 3 | -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/dev/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "dev/gke-cluster" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region 20 | } -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/dev/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/dev/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.128.0.0/20" 6 | pods_ip_range = "10.1.0.0/21" 7 | services_ip_range = "10.2.0.0/21" 8 | master_ip_range = "10.3.0.0/28" 9 | -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/prod/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | backend "gcs" { 11 | bucket = "terraform-on-gcp-gke" 12 | prefix = "prod/gke-cluster" 13 | } 14 | } 15 | 16 | # Terraform Provider Block 17 | provider "google" { 18 | project = var.gcp_project 19 | region = var.gcp_region 20 | } -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/prod/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/environments/prod/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region = "us-central1" 3 | environment = "prod" 4 | business_divsion = "hr" 5 | subnet_ip_range = "10.138.0.0/20" 6 | pods_ip_range = "10.11.0.0/21" 7 | services_ip_range = "10.22.0.0/21" 8 | master_ip_range = "10.33.0.0/28" 9 | -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push -------------------------------------------------------------------------------- /24-GKE-Infra-DevOps-CloudBuild-GitHub/Git-Repo-files/modules/gke_cluster/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/modules/gke_cluster/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/modules/kubernetes_deployment/outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Outputs 2 | output "deployment_labels" { 3 | description = "Kubernetes Deployment Selector Match Labels" 4 | value = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 5 | } 6 | 7 | -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/modules/kubernetes_deployment/variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | variable "deployment_name" { 3 | type = string 4 | description = "(Required) Kubernetes Deployment Name" 5 | } 6 | 7 | variable "namespace" { 8 | type = string 9 | description = "(Optional) Kubernetes Deployment Name" 10 | default = "default" 11 | } 12 | 13 | variable "replicas" { 14 | type = number 15 | description = "(Required) Number of Replicas" 16 | } 17 | 18 | variable "app_name_label" { 19 | type = string 20 | description = "(Required) App Name label" 21 | } 22 | 23 | -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/modules/kubernetes_deployment/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/p2-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "workloads/dev/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/p2-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/p2-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/p2-k8sresources-terraform-manifests/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1" 5 | app_name_label = "${local.name}-myapp1" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /25-GKE-Workloads-Custom-Terraform-Modules/p2-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/README.md: -------------------------------------------------------------------------------- 1 | # terraform-gcp-gke-workloads-devops1 2 | - Implement DevOps Pipelines for Terraform Configs on GCP GKE Workloads (Google Kubernetes Engine) 3 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/dev/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "workloads/dev/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/dev/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/dev/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/dev/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1" 5 | app_name_label = "${local.name}-myapp1" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/dev/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/prod/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "workloads/prod/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/prod/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/prod/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "prod/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/prod/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1" 5 | app_name_label = "${local.name}-myapp1" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/environments/prod/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "prod" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/modules/kubernetes_deployment/outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Outputs 2 | output "deployment_labels" { 3 | description = "Kubernetes Deployment Selector Match Labels" 4 | value = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 5 | } 6 | 7 | -------------------------------------------------------------------------------- /26-GKE-Workloads-DevOps-CloudBuild-GitHub/Git-Repo-Files/modules/kubernetes_deployment/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/App-GitRepoFiles/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/App-GitRepoFiles/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx 2 | COPY index.html /usr/share/nginx/html -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/App-GitRepoFiles/README.md: -------------------------------------------------------------------------------- 1 | # gcp-gke-terraform-app 2 | gcp-gke-terraform-app 3 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/App-GitRepoFiles/git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/App-GitRepoFiles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome to StackSimplify

5 |

Google Kubernetes Engine

6 |

Application Version: V1

7 | 8 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/modules/kubernetes_deployment/outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Outputs 2 | output "deployment_labels" { 3 | description = "Kubernetes Deployment Selector Match Labels" 4 | value = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 5 | } 6 | 7 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/modules/kubernetes_deployment/variables.tf: -------------------------------------------------------------------------------- 1 | # Input Variables 2 | variable "deployment_name" { 3 | type = string 4 | description = "(Required) Kubernetes Deployment Name" 5 | } 6 | 7 | variable "namespace" { 8 | type = string 9 | description = "(Optional) Kubernetes Deployment Name" 10 | default = "default" 11 | } 12 | 13 | variable "replicas" { 14 | type = number 15 | description = "(Required) Number of Replicas" 16 | } 17 | 18 | variable "app_name_label" { 19 | type = string 20 | description = "(Required) App Name label" 21 | } 22 | 23 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/modules/kubernetes_deployment/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/p2-k8sresources-terraform-manifests/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "artifact-registry-demo/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/p2-k8sresources-terraform-manifests/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/p2-k8sresources-terraform-manifests/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/p2-k8sresources-terraform-manifests/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1-ar-demo" 5 | app_name_label = "${local.name}-myapp1-ar-demo" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /27-GKE-App-Continuous-Integration/p2-k8sresources-terraform-manifests/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx 2 | COPY index.html /usr/share/nginx/html -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/README.md: -------------------------------------------------------------------------------- 1 | # terraform-gcp-gke-k8s-devops 2 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Welcome to StackSimplify

5 |

Google Kubernetes Engine

6 |

Application Version: V1

7 | 8 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/02-App-GitRepoFiles/known_hosts.github: -------------------------------------------------------------------------------- 1 | github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk= 2 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/.gitignore: -------------------------------------------------------------------------------- 1 | .terraform* 2 | *.tfstate* 3 | *.tfplan -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/README.md: -------------------------------------------------------------------------------- 1 | # terraform-gcp-gke-k8s-devops 2 | Implement DevOps Pipelines for Terraform Configs on GCP GKE Workloads (Google Kubernetes Engine) 3 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/dev/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "workloads/dev/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/dev/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/dev/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "dev/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/dev/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1" 5 | app_name_label = "${local.name}-myapp1" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/dev/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "dev" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/prod/c1-versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 6.0.0" 8 | } 9 | kubernetes = { 10 | source = "hashicorp/kubernetes" 11 | version = ">= 2.32" 12 | } 13 | } 14 | backend "gcs" { 15 | bucket = "terraform-on-gcp-gke" 16 | prefix = "workloads/prod/k8s-myapp1" 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/prod/c2-02-local-values.tf: -------------------------------------------------------------------------------- 1 | # Define Local Values in Terraform 2 | locals { 3 | owners = var.business_divsion 4 | environment = var.environment 5 | name = "${var.business_divsion}-${var.environment}" 6 | #name = "${local.owners}-${local.environment}" 7 | common_tags = { 8 | owners = local.owners 9 | environment = local.environment 10 | } 11 | } -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/prod/c3-01-remote-state-datasource.tf: -------------------------------------------------------------------------------- 1 | # Terraform Remote State Datasource 2 | data "terraform_remote_state" "gke" { 3 | backend = "gcs" 4 | config = { 5 | bucket = "terraform-on-gcp-gke" 6 | prefix = "prod/gke-cluster" 7 | } 8 | } 9 | 10 | output "p1_gke_cluster_name" { 11 | value = data.terraform_remote_state.gke.outputs.gke_cluster_name 12 | } 13 | 14 | output "p1_gke_cluster_location" { 15 | value = data.terraform_remote_state.gke.outputs.gke_cluster_location 16 | } 17 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/prod/c4-kubernetes-deployment.tf: -------------------------------------------------------------------------------- 1 | # Module: Kubernetes Deployment Manifest 2 | module "myapp1_deployment" { 3 | source = "../../modules/kubernetes_deployment" 4 | deployment_name = "${local.name}-myapp1" 5 | app_name_label = "${local.name}-myapp1" 6 | replicas = 2 7 | } 8 | 9 | # Outputs 10 | output "deployment_labels" { 11 | value = module.myapp1_deployment.deployment_labels 12 | } -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/environments/prod/terraform.tfvars: -------------------------------------------------------------------------------- 1 | gcp_project = "gcplearn9" 2 | gcp_region1 = "us-central1" 3 | environment = "prod" 4 | business_divsion = "hr" -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/modules/kubernetes_deployment/outputs.tf: -------------------------------------------------------------------------------- 1 | # Terraform Outputs 2 | output "deployment_labels" { 3 | description = "Kubernetes Deployment Selector Match Labels" 4 | value = kubernetes_deployment_v1.myapp1.spec[0].selector[0].match_labels.app 5 | } 6 | 7 | -------------------------------------------------------------------------------- /28-GKE-App-Continuous-Delivery/03-K8s-GitRepoFiles/modules/kubernetes_deployment/versions.tf: -------------------------------------------------------------------------------- 1 | # Terraform Settings Block 2 | terraform { 3 | required_version = ">= 1.9" 4 | required_providers { 5 | google = { 6 | source = "hashicorp/google" 7 | version = ">= 5.40.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /course-presentation/Terraform-on-GCP-GKE-v1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stacksimplify/terraform-on-google-kubernetes-engine/bcc07d432e7c2b8ec1e448662030c17af5194186/course-presentation/Terraform-on-GCP-GKE-v1.pptx -------------------------------------------------------------------------------- /gcp-gke-terraform-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stacksimplify/terraform-on-google-kubernetes-engine/bcc07d432e7c2b8ec1e448662030c17af5194186/gcp-gke-terraform-1.png -------------------------------------------------------------------------------- /gcp-gke-terraform-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stacksimplify/terraform-on-google-kubernetes-engine/bcc07d432e7c2b8ec1e448662030c17af5194186/gcp-gke-terraform-2.png -------------------------------------------------------------------------------- /git-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Add files and do local commit" 4 | git add . 5 | git commit -am "Welcome to StackSimplify" 6 | 7 | echo "Pushing to Github Repository" 8 | git push --------------------------------------------------------------------------------