Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[terraform] #874: terraform module for AWS #942

Merged
merged 37 commits into from
Feb 16, 2023

Conversation

barroco
Copy link
Contributor

@barroco barroco commented Jan 30, 2023

This PR introduces a terraform module (terraform-aws-dss) to deploy the DSS to AWS using Elastic Kubernetes Service.

Summary of changes:

  • A new dependency has been added to provision the infrastructure to AWS: dependencies/terraform-aws-kubernetes. See terraform-aws-kubernetes/README for design notes.
  • terraform-commons-dss: introduction of two variables (gateway_cert_name and workload_subnet) to support the new cloud provider and generate the correct tanka configuration.
  • Tanka manifests have been updated to support google and aws specific kubernetes resources. Note that the changes to the metadata variables should be backward compatible.
  • AWS unique identifier for cluster context uses urn which includes special characters. (ie : and /) Scripts in build/ have been updated to replace it by _.
  • google_kubernetes_storage_class variable has been removed from terraform-google-kubernetes since it is not required by the dependency.

The PR is quiet big, so please let me know if it is not manageable and I will break it down.

@barroco
Copy link
Contributor Author

barroco commented Jan 30, 2023

terraform-aws-dss (dns configured automatically and manually) and terraform-google-dss (dns configured automatically) successfully deployed to dedicated cloud accounts (no pooling). Resulting clusters were successfully probed individually.

@barroco barroco marked this pull request as ready for review January 30, 2023 22:16
Copy link
Member

@BenjaminPelletier BenjaminPelletier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though I don't have the capability currently to personally verify. Comments are mostly minor.

deploy/infrastructure/modules/terraform-aws-dss/README.md Outdated Show resolved Hide resolved
deploy/infrastructure/modules/terraform-aws-dss/README.md Outdated Show resolved Hide resolved
deploy/infrastructure/modules/terraform-aws-dss/README.md Outdated Show resolved Hide resolved
@@ -119,7 +120,7 @@ of this .pem file here as /public-certs/YOUR-KEY-NAME.pem replacing YOUR-KEY-NAM
if using the provided us-demo.pem, use the path /public-certs/us-demo.pem. Note that your .pem file should built
in the docker image or mounted manually.
Example:
```json
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd recommend (substituting backticks where appropriate)

Example 1 (dummy auth):
'''json
{
  public_key_pem_path = "/test-certs/auth2.pem"
}
'''
Example 2:
'''json
{
  public_key_pem_path = "/jwt-public-certs/us-demo.pem"
}
'''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have to be backticks though (not apostrophes); I didn't put backticks in my recommendation because then the preview wouldn't have rendered correctly :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

deploy/infrastructure/utils/variables.py Outdated Show resolved Hide resolved
@@ -147,23 +150,3 @@ variable "kubernetes_namespace" {
}
}

variable "app_hostname" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block with app_hostname and crdb_hostname_suffix needs to be re-added back, this breaks terraform plan command.

image

Copy link
Contributor Author

@barroco barroco Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hrishiballal for the feedback, may I kindly ask you to try again with the latest version of this branch. I just pushed a fix. The issue was introduced with 695e252. The problem should be solved. Tested planning with terraform-aws-dss and terraform-google-dss

@barroco barroco requested a review from hrishiballal January 31, 2023 17:39
Copy link
Member

@BenjaminPelletier BenjaminPelletier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor formatting issue remaining, but everything looks good to merge from my perspective.

@@ -0,0 +1,74 @@
# terraform-aws-dss
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we already talked about this or not, but these READMEs seem a little hidden down in the tree of directories. This might be for another PR, but I think there should be a README in the top level deploy directory that:

  • quickly explains the infrastructure directory contains terraform code for setting up k8s in different clouds
  • points to:
    • deploy/infrastructure/modules/terraform-aws-dss/README.md
    • deploy/infrastructure/modules/terraform-google-dss/README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like the right moment to add the README indeed.

1. Install [terraform](https://developer.hashicorp.com/terraform/downloads).
2. Install tools from [Prerequisites](../../../../build/README.md)
3. Install provider specific tools:
1. [Amazon Web Services](./README.md#amazon-web-services)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that a broken link? Where is it supposed to go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually correct. Markdown creates an anchor for each titles and it can be reference using the url's fragment. In this case, it points to the next section in the same document.
This prepares the ground for an aggregated README with all cloud providers.

If providing the access token public key via JWKS, do not provide this parameter.
If providing a .pem file directly as the public key to validate incoming access tokens, specify the name
of this .pem file here as /public-certs/YOUR-KEY-NAME.pem replacing YOUR-KEY-NAME as appropriate. For instance,
if using the provided us-demo.pem, use the path /public-certs/us-demo.pem. Note that your .pem file should built
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

Suggested change
if using the provided us-demo.pem, use the path /public-certs/us-demo.pem. Note that your .pem file should built
if using the provided us-demo.pem, use the path /public-certs/us-demo.pem. Note that your .pem file should be built

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,27 @@
# This file is an example, please adapt it to your configuration.
# See TFVARS.md for full set of variables and related descriptions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

Suggested change
# See TFVARS.md for full set of variables and related descriptions.
# See TFVARS.md for the full set of variables and related descriptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

6. In the new directory (ie /deploy/infrastructure/personal/terraform-aws-dss-dev), initialize terraform: `terraform init`.
7. Run `terraform plan` to check that the configuration is valid. It will display the resources which will be provisioned.
8. Run `terraform apply` to deploy the cluster. (This operation may take up to 15 min.)
9. If `aws_route53_zone_id` was not provided, configure the DNS resolution to the public ip addresses and for SSL certificate validation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend slightly rewording this: if aws_route53_zone_id is provided, please make sure that the domain or sub-domain in the Route 53 zone is mapped to Route53 via NS entries, e.g. see instuctitions for a sub-domain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I modified the description to point directly to the Setup DNS documentation and added a reference to domain delegation instructions (see aba1ddb)

2. Run `./get-credentials.sh` to login to kubernetes. You can now access the cluster with `kubectl`.
3. Generate the certificates using `./make-certs.sh`. Follow script instructions if you are not initializing the cluster.
4. Deploy the certificates using `./apply-certs.sh`.
5. Run `tk apply .` to deploy the services to kubernetes. (This may take up to 30 min)
Copy link
Contributor

@hrishiballal hrishiballal Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting a Kubernetes version error here. Maybe AWS expects a particular version:
image

The output of kubectl version --client is below:
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.1", GitCommit:"8f94681cd294aa8cfd3407b8191f6c70214973a4", GitTreeState:"clean", BuildDate:"2023-01-18T15:58:16Z", GoVersion:"go1.19.5", Compiler:"gc", Platform:"linux/amd64"} Kustomize Version: v4.5.7

When I install kubectl version as 1.24.10-00 in Ubuntu it works no problems.

@hrishiballal
Copy link
Contributor

I can confirm that DSS installation works and having run the prober tests, they pass / work as well.

## Clean up

1. Note that the following operations can't be reverted and all data will be lost.
2. To delete all resources, run `tk destroy .` in the workspace folder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no command called tk destroy . , did you mean tk delete . ?
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, tanka is generating an error when I do tk delete .

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deletion process works its just that tanka gives a error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in the documentation

Copy link
Contributor

@marcadamsge marcadamsge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deployed the DSS on AWS following these steps as is, it worked without issue, good job! 👍

@barroco barroco merged commit a039aec into interuss:master Feb 16, 2023
@barroco barroco deleted the 874-terraform-aws branch February 16, 2023 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants