198 Commits

Author SHA1 Message Date
dandds
41bab4f594 Do not run test workflow for merges to main branches.
We should not run a redundant testing workflow on merges to master or
staging.

This also includes a quick fix to configure the FLASK_ENV for the main
site.
2019-11-22 12:56:17 -05:00
tomdds
4df68bab23 Add BLOB_STORAGE_URL config
Our content security policy in non-dev environments didn't allow uploading to azure blob storage. This adds a configurable blob storage base URL to allow regions to specify which storage endpoint they expect the upload request to use.
2019-11-22 11:56:27 -05:00
dandds
08fc530223 Add config value for CDN origin.
This value is set as the Access-Control-Allow-Origin header value for
the application. When using Azure CDN, the CDN will consume this header
when it populates its cache and use it on subsequent requests.

It would be possible to make this the same as the Flask SERVER_NAME
value. We explicitly set SERVER_NAME for Celery worker processes because
they need that information to contruct URLs outside of the request cycle
(Flask can infer the server name within a request cycle). I decided not
to rely on SERVER_NAME though because it has side effects:

- It determines what `url_for` uses as the host domain (which would be
  fine).
- It makes it so that the Flask app can only server requests to that
  domain (probably fine, but it felt like too big a side effect).

Additionally, SERVER_NAME does not include the scheme. For all of these
reasons I opted to make CDN_ORIGIN a separate config value.
2019-11-21 16:43:22 -05:00
dandds
c6187466a3 Configure staging with different FLASK_ENV, include sub-route for CDN_URL. 2019-11-21 16:43:22 -05:00
richard-dds
8e12c6bfbd Add CDN config for staging 2019-11-21 16:42:42 -05:00
richard-dds
e29163f65a Add CDN config for prod 2019-11-21 16:42:42 -05:00
dandds
280778ab5f Set SERVER_NAME correctly for staging Celery workers. 2019-11-19 13:36:47 -05:00
dandds
88171aaee7 Supply named default queue for Celery.
Supplying this will prevent queue clashes between various ATAT sites
sharing the same Redis instance.

Note that the Celery documentation is currently wrong about the name for
configuring this:

https://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_default_queue

It specifies `CELERY_TASK_DEFAULT_QUEUE`, but
`CELERY_DEFAULT_QUEUE` is the value that Celery currently looks for.
This appears to be fixed in on an upcoming release:

https://github.com/celery/celery/issues/5575

This is worth keeping an eye on, since the configuration key could
change in the future.
2019-11-14 15:48:14 -05:00
dandds
bf1badeff0
Merge pull request #1182 from dod-ccpo/lets-encrypt-manually
Configure K8s deployment for easy LetsEncrypt verification.
2019-11-14 12:46:25 -05:00
dandds
79eb691907 Configure K8s deployment for easy LetsEncrypt verification.
This is not the certificate setup we will use in production. I'd like to
merge this configuration as a reference point because this is the
easiest way to handle manual LetsEncrypt verification within the
cluster.

This allows NGINX to serve static files over HTTP from the
".well-known/acme-challenge" directory, which is necessary for certbot
validation of domain ownership.
2019-11-14 09:51:35 -05:00
dandds
387f957aa4 Add CircleCI config for staging deployment.
This generalizes the deploy step into a configurable CircleCI command.
The available parameters are:

- `namespace`: the K8s namespace to alter
- `tag`: the docker tag to apply to the image

The script for applying migrations to the K8s environment and the
corresponding K8s Job config have been generalized so that they can be
configured to run in the specified namespace.

The main workflow has been updated so that the appropriate deployment
will happen, depending on whether we are merging to staging or master.
In the future, we could look to add an additional workflow based around
Git tags for production.

Note that this also removes the creation of the `latest` tag from CD.
That tag is no longer hard-coded into our K8s config and so there's no
longer a need to update it in our container registry.
2019-11-13 09:56:36 -05:00
dandds
fd57036f74 Keep client CAs as a K8s ConfigMap.
The CAs used to verify clients are not secrets and can be committed to
the repository as K8s ConfigMaps. This updates the config to include
them.
2019-11-08 14:28:45 -05:00
dandds
630469744a Use kustomize and envsubst to generalize k8s config.
Adds a [kustomize](https://github.com/kubernetes-sigs/kustomize) overlay
for a new staging environment. Additionally, adds environment variables
in the place of certain pieces of information that need to be templated.

The K8s README ("deploy/README.md") has been updated to reflect the new
method for applying config.

This commit also removes the configuration for the AWS cluster and
references to AWS in the README.
2019-11-08 14:28:45 -05:00
dandds
efcb9681d3 Make Postgres SSL connection configurable.
This will allow us to force SSL connections to the database in
production by setting two values:

- PGSSLMODE should be set to "verify-full". This forces the client to
  verify the server against a known CA: https://www.postgresql.org/docs/10/libpq-ssl.html
- PGSSLROOTCERT should be set to the path of the public cert for the
  relevant CA.

When the database connection is made, these values are passed to the
adapter. For local development, PGSSLMODE is set to "prefer" and
PGSSLROOTCERT is left unset.

Kubernetes config has been added to maintain the root CAs for both Azure
and AWS as k8s ConfigMap objects. These are mounted into the containers
and referenced by PGSSLROOTCERT in the container environment.
2019-10-17 16:05:19 -04:00
dandds
4169dcb310 Fix CI/CD bug with PGSSLROOTCERT.
Because I pushed the environment variable changes to the cluster
already, psycopg2 was automatically trying to connect to the database
using the file specified in PGSSLROOTCERT. That ConfigMap was not
mounted into the migrations container, so I'm doing that here.
2019-10-17 14:59:41 -04:00
dandds
fc637e933d Specify Flask SERVER_NAME value for Celery worker.
The Celery worker cannot render URLs for the app without having a
SERVER_NAME value set. AT-AT's ability to send notifications when an
environment is ready is broken as a result.

This commit sets a null default value for SERVER_NAME in the default
config file. A setting must exist in the INI file in order to be
over-written by an environment variable, which is why we declare it as
null here. There is an additional kwarg, "allow_no_value", that must be
passed to ConfigParser to allow null values.

This also applies the correct domains as SERVER_NAME environment
variables in the Kubernetes ConfigMaps for the AWS and Azure Celery
workers.
2019-10-16 11:57:18 -04:00
dandds
73a459ea28
Merge pull request #1113 from dod-ccpo/k8s-log-aggregation
K8s log aggregation
2019-10-14 13:15:41 -04:00
dandds
05c84877dd Add k8s config for adding Fluentd and piping logs to CloudWatch.
With this configuration, all Kubernetes logs within the ATAT cluster
will be sent to AWS CloudWatch.

Note that this requires applying an additional IAM policy to the worker
nodes' role.
2019-10-11 12:54:50 -04:00
dandds
bbd0ffe1a9 Kubernetes configuration to allow Azure Monitor to collect logs.
With this additional ClusterRole and ClusterRoleBinding, Azure Monitor
will receive the aggregate logs from our application containers.
2019-10-11 11:24:53 -04:00
dandds
d1ed0f6692 Add setup script and configuration for Minikube cluster.
The Minikube version of the cluster has some differences from the main
config (noted in the README) but will be useful for for future DevOps
development.
2019-10-04 17:48:46 -04:00
dandds
67ff70201e Add beat worker to the deployment.
We will run a separate pod for the beat worker. There should only ever
be a single beat worker (to avoid redundant work) so the number of
replicas needs to be managed independently.

This adds both the Kubernetes config for the new pod and additional
CircleCI config to swap a new image into the pod during CD.
2019-09-18 16:34:56 -04:00
dandds
ace222fe95 Push multiple Docker tags for image in CD.
This will allow Kubernetes resources that only pull images occasionally
(i.e., k8s jobs) to point to a static tag name, "latest", that is updated
regularly. It also means we can refer to that image in the k8s config
tracked in the repo, instead of out-of-date images.
2019-09-11 15:37:09 -04:00
dandds
e809f06c32 Make log-level INFO for Celery workers in kubernetes cluster.
This is useful for testing and development purposes. Otherwise there's
not much log output.
2019-08-29 14:18:06 -04:00
dandds
d7478e322a Use Celery instead of RQ.
Celery provides a more robust set of queueing options for both tasks and
worker processes. Updates include:
- infrastructure necessary to run Celery, including celery entrypoint
- backgrounded functions are now imported directly from atst.jobs
- update tests as-needed
- update kubernetes worker pod command
2019-08-29 09:33:47 -04:00
dandds
485f578c78 Apply config changes for CSP file uploads.
This applies configuration changes for the Flask app and adds changes to
the Dockerfile so that the build can make a CSP-specific JS bundle. It
adds `write_dotenv` script that creates the appropriate `.env` file for
the `parcel` bundler depending on how the `CSP` environment variable is
set.

- Configure K8s environment variables for Flask CSP usage
- Supply default CSP config setting to Flask app
- Declare the CSP arg in the Dockerfile
- Supply extra Docker build args to CD
- Fix top-level reference to boto3 in file_upload module
- Add back missing sample NGINX config for docker-compose build
2019-08-09 08:05:20 -04:00
dandds
6593b7eda1 Create README for Kubernetes config. 2019-08-08 09:33:09 -04:00
dandds
c100cc8d1f Move k8s config dir to deploy dir 2019-08-08 08:30:14 -04:00
dandds
52829a1236 Add additional k8s config for AWS and Azure.
- remove unused k8s environment config
- experimental config for azure and aws
- use nginx for proxy and add rq worker pod
2019-07-31 11:57:24 -04:00
dandds
ef8fd2fa41 Put Dockerfile in repo root for ease of use.
Most build tools (i.e., the CircleCI Orbs) expect a Dockerfile in the
repo root. Rather than have to configure an exception everywhere, put it
where most people/tools expect it to be.
2019-07-14 16:00:09 -04:00
dandds
03a445e759 Copy USWDS fonts to static directory in Docker build.
This step was missing from the initial Docker build and causing errors
in fresh repositories.
2019-07-14 15:57:34 -04:00
dandds
6f8ef27bf1 Single Dockerfile for building ATAT.
Dockerfile is now a single multi-stage build that relies on a Python 3.7
base image.

Notes:
- This builds uWSGI with a `pip install` because the Alpine vendored
  uWSGI is built against Python 3.6.
- Adds a docker-compose file that can be used for testing that the build
  works. It is not usable for development purposes because it creates a
  static copy of the application.
2019-07-11 11:27:33 -04:00
dandds
0bde431a70 extend soft delete functionality to app and env roles 2019-04-15 15:58:38 -04:00
dandds
a5d285c840 update k8s config with new docker registry url 2019-04-15 12:31:32 -04:00
dandds
09f58dc6cb set flask app instances to log json in k8s clusters 2019-04-03 06:26:39 -04:00
dandds
f72ec839a9 configure json logging for uwsgi in k8s environments 2019-04-03 06:09:47 -04:00
dandds
cb91003675 configure json logging for nginx in k8s cluster 2019-03-29 10:04:57 -04:00
dandds
410b0fc112 add missing crl sync config option to k8s clusters 2019-03-15 13:33:23 -04:00
dandds
2ef200a2b7 specify timezone in an environment variable for app containers 2019-03-11 20:59:42 -04:00
dandds
51aff4578e update k8s config so auth traffic is only directed to web pods 2019-02-01 11:16:56 -05:00
dandds
4bd41950c6 remove REQUIRE_CRLS setting in favor of DISABLE_CRL_CHECK 2019-01-18 09:48:43 -05:00
dandds
f3c294659a refine test environment sample data script, add k8s role and role binding for updating sample data 2018-12-04 16:12:23 -05:00
dandds
bd0b7b9dcd script for rotating sample data on test env 2018-12-04 09:42:47 -05:00
dandds
bbeef23c45 test testing build 2018-12-03 16:34:39 -05:00
dandds
b54e3147c3 try scheduling nightly deploys for test env with CircleCI config 2018-12-03 09:11:25 -05:00
dandds
23294b2e2b note nodePort must match auth load balancer 2018-12-03 09:11:25 -05:00
dandds
689f7723dc add readme for creating new site 2018-12-03 09:11:25 -05:00
dandds
5272226725 update image for test env, remove unused secret 2018-12-03 09:11:25 -05:00
dandds
1cea2b63ac update auth port for test environment 2018-12-03 09:11:25 -05:00
dandds
80124e8925 basic test config 2018-12-03 09:11:25 -05:00
Patrick Smith
2a48a78561 Add worker envvars for UAT env 2018-10-31 16:42:10 -04:00