Skip to content
Snippets Groups Projects
Commit b3bf7ba6 authored by PERDEREAU Eloi's avatar PERDEREAU Eloi
Browse files

update README

    * move part 3 to part 2.2
    * description of what is expected in the assignment
    * add improvements
parent e427fd26
No related branches found
No related tags found
No related merge requests found
......@@ -3,61 +3,85 @@ FILA3 Voting App Terraform Project
# Table of Content
* [Local Docker deployment](#part-1---local-docker-deployment)
* [Kubernetes on GCP](#part-2---gke-and-kubernetes)
* [Offloading Redis from the Cluster](#part-3-optional---gke-kubernetes-and-offloaded-redis)
* [Objectives](#objectives)
* [Part 1 - Local Docker deployment](#part-1---local-docker-deployment)
* [Part 2 - GCP GKE Deployment](#part-2---gcp-gke-deployment)
* [Part 2.2 optional - Offloaded Redis DB](#part-2.2-optional---offloaded-redis-db)
* [Debugging tips](#debugging-tips)
* [Destroy everything](#destroy-everything)
## Objectives
The objective is to use _only_ Terraform to deploy the voting app.
The objective is to use Terraform to deploy the voting app.
The tutorial on Terraform did not give you _all_ elements for this project: it was on purpose.
The point is for you to learn how to seek information in providers and other documentations.
But most elements in the tutorials can be directly applied.
Different levels are possible, the more advancement you make the better. **Part 1 and Part 2 are mandatory.**
Different levels are possible, the more advancement you make the better.
Part 1 and Part 2 are considered two different deployment infrastructure, they must be in different directories.
*Part 2.2 and "Improvements" are optional*
We expect a URL to a git repository with your code and a thorough README with at least
* How to use the repo (where to apply terraform, in which order, scripts to execute if any, where to put our GCP credentials, etc.)
* The architecture design:
* mechanism used for reusing small pieces of the infrastructure (either `modules` or `terraform_remote_state` or a combination of both)
* mechanism used for setting values of input `variable`s (location and name of the `.tfvars` files, which environment variables to set, etc.)
* Explanations on your choices.
## Part 1 - Local Docker deployment
![voting-app-docker](figures/login-nuage-voting.drawio.svg)
In this first part, you must write Terraform code that deploys the application with the Docker provider.
In this first part, you must write Terraform code that builds and deploys the voting services with the Docker provider.
The app will thus be deployed locally inside containers on your machine.
Use the given `docker-compose.yml` as a reference configuration.
**TIP**: Recall that a Docker Compose "service" creates a DNS records accessible by other containers.
**TIP**: Recall that a Docker Compose "service" creates a DNS record accessible by other containers.
Terraform does not do that, so you will need to add the relevant `host` configurations.
*Improvement*: Make so that `apply` rebuilds an image if the files in the voting service directory have changed.
## Part 2 - GKE and Kubernetes
## Part 2.1 - GCP GKE Deployment
![voting-app-k8s](figures/login-nuage-voting-k8s.drawio.svg)
In this second part, you must write code that deploys the application onto a Kubernetes cluster provisioned with Terraform on GKE.
Google and Kubernetes providers will be thus be used. Unlike the tutorials and for simplicity, configure the cluster to be in the GCP predefined `default` network.
In this second part, you must write code that deploys the voting services onto a Kubernetes cluster provisioned with Terraform on GKE.
Google and Kubernetes providers will be thus be used.
Use the given manifests in `k8s-manifests/`.
Unlike the tutorials and for simplicity, use a `data` source to read the GCP predefined `default` network and use it for configuring the cluster network.
**TIP**: Add `deletion_protection = true` to the cluster resource so that `$ terraform destroy` will be able to delete the cluster.
The YAML manifest files are given in `k8s-manifests/`. Use at least one `count` or `for_each`.
**TIP**: You can use the `kubernetes_manifest` resource and provide any YAML manifest file directly.
**TIP**: You can use the `kubernetes_manifest` resource and give it a YAML manifest directly.
**IMPORTANT**: Make sure to organize your Terraform code well. Attention will be given to your organization (modules, directories, files)
*Improvements*:
* Make it work without modifying the given YAML manifest (except the `image` repo of deployment containers).
* Make so that `apply` rebuilds and repush an image if the code of the voting service have changed.
* Reuse the `docker_image`s from Part 1.
## Part 3 optional - GKE, Kubernetes and offloaded Redis
## Part 2.2 optional - Offloaded Redis DB
In this last part, you must deploy with Terraform the `Redis` database inside a VM on GCP rather than on the cluster.
To install Redis upon startup of the VM, use the given `install-redis.sh.tftpl` template script in the `metadata_startup_script` attribute.
This database must be available to the other components of the application located on the GKE cluster.
This database must be reachable to the other components of the application located on the GKE cluster.
**TIP**: You will need a `google_compute_firewall` resource to allow port `6379` on `source_ranges` `0.0.0.0/0`.
Don't forgot to link the firewall rule to the VM through a shared *tag*.
Don't forget to link the firewall rule to the VM through a shared *tag*.
Services *vote* and *worker* need to be aware of the Redis host IP and password.
**TIP**: *vote* and *worker* need to be aware of the Redis host IP and password.
*Improvements*:
* Refine the firewall rule so that only machines from the cluster can reach the VM.
* Put the cluster on a dedicated network and the redis VM on another network.
## Debugging tips
......@@ -87,9 +111,7 @@ Do not forgot to destroy all resources, especially the K8S cluster.
$ terraform destroy
```
If you forgot to add `deletion_protection = true` in the Terraform cluster resource, you can modify the state directly.
*This is not good practice.*
Remember to set `deletion_protection = true` in the `google_container_cluster` resource. Edit the `terraform.tfstate` file in your editor or run the following
```
sed -e '/deletion_protection/s/true/false/' -i terraform.tfstate
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment