Skip to content

Sab/tf rework1#2

Open
ThatDevopsGuy wants to merge 19 commits into
masterfrom
sab/tf-rework1
Open

Sab/tf rework1#2
ThatDevopsGuy wants to merge 19 commits into
masterfrom
sab/tf-rework1

Conversation

@ThatDevopsGuy
Copy link
Copy Markdown
Collaborator

Omnibus Update

"If you have overcome your inclination and not been overcome by it, you have reason to rejoice."
-Plautus

Oh, rejoice we shall!

Massive Changes

Wordpress Migration

Due to some bugs inherent in the Bitnami Drupal container's initialization methods, I'm disinclined to continue using their image (namely, leveraging their MYSQL client bootstrapping portion (which establishes the database and users) requires you have a WORDPRESS variable set (meaning they didn't get around to cleaning up their script).

Moreover, I wasn't able to get it to pick up the right environment variables in a timely fashion. Wordpress, on the other hand, is not only well-documented in this respect, but also is used in our official GKE/CloudSQL documentation.

Initialization Procedure

Things are properly templated in Terraform variables, and default TFVARS, courtesy of the preflight script. To get things working properly, the only requirement is the presences of these executable binaries:

  • terraform
  • gcloud

And to have the proper settings inside of gcloud, namely authentication, project, region/zone.

Minor Changes

NFS GCE VM

I've upgraded the version of Ubuntu to 18.04 LTS, after playing around with Debian 9. There's some packaging post-install issues in Debian which don't really start NFS properly for us. I've also reworked the script substantially to both increase ease of comprehension and ease of use by internal and external users.

Housekeeping

Some files were moved around, renamed, and/or cleaned-up. Unused variables were removed. Unnecessary TF outputs were removed. Comments were tidied. The .gitignore file was updated. Stuff like this.

Kubernetes Stuff

The replica count is now 1. I suppose we can add a delay as was present, but to keep things simpler and let the user scale the deployment at their behest also seems attractive.

I've also added variable names to prevent metadata scrubbing (meaning it's easier to read by referencing 1 variable, rather than the output of another command which defines its name there (anti-pattern).

Last but not least, we're actually using secrets properly for the DB connection. Terraform didn't have adequate documentation, but in looking at their source code, it turns out secrets in environment variables are in fact resolvable.

Testing and Verification

From a blank-ish project:

./preflight
terraform apply

And then things are accessible at the LB IP, where you can install Wordpress and login!

ThatDevopsGuy and others added 17 commits June 1, 2018 17:49
* Updated welcome message to be more friendly
* Created functions to execute command checking and config checking
* Added check for Terraform binary
* Added warning about existing .terraform directory (see below)
* Reworked gcloud variable state checking (see below)
* Updated Terraform bucket name to include "cloudlamp"
* Preflight now calls `terraform init`

Existing Terraform Directory
----------------------------
If an existing .terraform directory is present, there is a chance
TF will attempt to reconcile state with a nonexistent project (or
components therein). Discarding the local file alleviates the need
to check these parameters. Useful in debugging.

Gcloud Variable Checking
------------------------
Upon testing in Cloud Shell, it turns out it emits a message which
begins with "Your active configuration", which was not present on
other CLI clients. Now we use wildcard matching to ensure the right
variables are set prior to execution.
Cleanup, new process, etc.
@ThatDevopsGuy ThatDevopsGuy added bug Something isn't working enhancement New feature or request labels Jul 19, 2018
@ThatDevopsGuy ThatDevopsGuy requested a review from fersantxez July 19, 2018 02:27
ThatDevopsGuy and others added 2 commits July 18, 2018 22:57
* Removed check for kubectl
* Fixed asinine STDOUT/STDERR gcloud config get-value behavior
Preflight now handles API enablement, due to odd Terraform action.

It does this by gathering required APIs, and then enabling them
in parallel, through a single extra `gcloud` invocation. The
script will *NOT* enable an already-enabled API, which saves a lot
of time in execution, as while `gcloud services enable` does take
multiple parameters, it executes each in series.

This might introduce odd behavior in hierarchical API requests,
but I'm not sure. i.e. does 'containers' require 'compute'? If so,
There will be one more superfluous call made to the API endpoint.
However, API enablement calls are idempotent, so calling 'enable'
more than once per API will not have an noticable effect.

Also things operate in groups now, with slightly more output, which
looks nicer. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants