198 Commits

Author SHA1 Message Date
dandds
46643f7f41 Config for JEDI dev cluster.
- Transition to VMSS identity for flexvol
- Update some environment variables for cloudzero dev
- Overlay for applying migrations
- Updates to disable CDN, which will not be available
- Removes CronJob for resetting the database; don't need that in this
  cluster for now.
2020-02-08 15:06:43 -05:00
dandds
26cc4ce79a Disable cipher export for TLS negotiation.
In order to meet compliance requirements, this adds the EXPORT option to
NGINX's ssl_cipher config. Extended discussion here:

https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
2020-01-29 16:48:33 -05:00
dandds
6edc7b138b Set SESSION_COOKIE_SECURE for deployed environments.
This sets the "Secure" attribute on cookies sent to the client:

https://flask.palletsprojects.com/en/1.1.x/config/#SESSION_COOKIE_SECURE
2020-01-29 14:39:56 -05:00
dandds
b630433aa8 Disable container privilege escalation.
Per Azure best practice, disable a container's ability to escalate its
privileges.

https://docs.microsoft.com/en-us/azure/aks/developer-best-practices-pod-security#secure-pod-access-to-resources
2020-01-28 14:10:55 -05:00
dandds
0fa4fd2304 Limit concurrent session by default for deployed sites.
To meet ATO requirements, a user should not be able to have concurrent
logins.
2020-01-23 10:29:37 -05:00
dandds
2ab9790f3e
Merge branch 'staging' into cloudzero-k8s 2020-01-21 10:23:50 -05:00
raydds
35cd76adf5 Try to fit two web processes per node 2020-01-20 15:41:52 -05:00
raydds
14b9f36204 Minimize staging 2020-01-20 15:41:52 -05:00
raydds
2008b4e6e3 Run UWSGI with 4 processes and 2 threads. Allocate more CPU/memory 2020-01-20 15:41:52 -05:00
dandds
591682ab87 Display client source IP correctly in logs.
In order to display the client source IP, we need to make a
configuration change to the cluster. Setting externalTrafficPolicy to
"Local" preserves the client IP, per:

https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
2020-01-20 10:37:20 -05:00
dandds
2254e0dd01
Merge branch 'staging' into 170505212-uwsgi-logs 2020-01-16 16:58:52 -05:00
dandds
d121a12429 Minimal config for cloudzero dev environment.
This includes config for the VMSS assigned identity to authenticate for
FlexVol purposes. Right now, some dummy keys are referenced in the
config that we'll swap for the real ones later.

This also includes config for specifying the subnet the load balancers
should be in.
2020-01-16 11:51:02 -05:00
raydds
eb7625a26e Bump CPU for atst worker 2020-01-16 10:16:54 -05:00
raydds
d07d4f09fd This HPA should point at the worker 2020-01-16 10:16:54 -05:00
raydds
f14b30b346 Min workers is 1 2020-01-16 10:16:54 -05:00
raydds
5813cc1370 Do not explicitly set replica count 2020-01-16 10:16:54 -05:00
raydds
5fdfc8a425 Create a horizontal pod autoscaler 2020-01-16 10:16:54 -05:00
dandds
a54db5a688 Remove Minkube config.
We do not have the bandwidth to keep the Minikube deployment up-to-date,
so rather than leave half-baked config in the repo we'll remove it for
now. Complications that would have to be resolved for running Minikube
locally include managing secrets out of Azure Key Vault and managing TLS
termination over localhost.

The Synack audit also identified the Minikube basic auth password as an
issue; it's only for demo purposes, but this will resolve that ticket.
2020-01-14 15:46:08 -05:00
Ray Zane
835cd4f12e First pass at setting CPU and memory limits in Kubernetes 2020-01-13 13:00:21 -05:00
dandds
49446fdbe9 uWSGI plugin config changes.
uWGI was generating warnings about being unable to find plugin files we
specify. To fix this, I've added uwsgi-python3 to the list of Alpine
packages we install in the container specified the plugins directory in
the uWSGI config. The updated uWSGI ConfigMap has been applied to the
staging cluster, which eliminated the warning about the logfile plugin.
The remaining warning about the python3 plugin will be eliminated once
the new container built by this branch is deployed.
2020-01-09 11:36:00 -05:00
dandds
51f7afd5b0 Update NGINX config to use supplied domains.
I left the domains hard-coded for the redirects in our NGINX config,
which was breaking authentication for versions of the site that don't
use that domain. This updates the config to use the domains supplied via
environment variable.
2020-01-07 06:12:56 -05:00
dandds
60b12fca52 Config to specify session cookie domain.
This got lost somewhere along the way (almost certainly by me), so this
commit tries to make it explicit. The app needs to be able to configure
the session cookie domain name so that it is valid for both the main
site domain and the authentication subdomain. For instance, if the site
is runnning at uat.atat.code.mil and authentication happens at
auth-uat.atat.code.mil, SESSION_COOKIE_DOMAIN should be set to
atat.code.mil so that it's valid for both.

This adds the setting to the base INI file and a default for our K8s
clusters.
2020-01-06 14:07:53 -05:00
dandds
8ec23b54a8 WIP: k8s config for cloud-zero 2019-12-23 18:39:55 -05:00
dandds
9d282ee82a K8s cronjob for resetting the database on staging.
This K8s CronJob will run the script for resetting the database. It will
only be applied to the staging site.
2019-12-17 13:19:40 -05:00
dandds
1466a302b2 K8s YAML integer values need to be quoted. 2019-12-13 12:11:31 -05:00
dandds
ec638d6b01 Transition to using secrets in Key Vault.
This does the following:

- Removes references to the atst-override.ini file, now deprecated.
- Adds all non-secret data that was managed in the override file to the
  relevant K8s ConfigMaps.
- Adds additional documentation explaining out use of Key Vault for
  secrets management.
2019-12-10 10:14:54 -05:00
dandds
972cf14a66 K8s configuration for mounting application config.
This adds an additional volume mount for Flask application secrets.
These will be mounted into the ATST container so that their values can
be read in as config.
2019-12-10 10:14:53 -05:00
dandds
20c7e943c8 Compose REDIS_URI from component parts.
This updates the configuration handling for the Redis connection string.
The motivation is so that the Redis password can be managed separately
via Azure Key Vault and eventually be rotated independently of the rest
of the connection URI.

This also tweaks the method we use to build the DATABASE_URI and removes
some stale config from the CI config file.
2019-12-04 13:28:26 -05:00
dandds
f4ffde89d0 Add more restrictions to K8s CRL CronJob.
The K8s CronJob that manages CRL syncing often leaves pods hanging
around for days at a time. This appears to happen when the download of a
particular CRL from DISA hangs for whatever reason. This updates the
configuration so that a running cronjob is automatically replaced by its
successor, rather than the two running concurrently. (The CRL CronJob
runs every hour, and it one has taken that long then it's hanging and
needs to be replace.) Similarly, this updates the config to only retain
one successful CRL pod, rather than the default of three.
2019-12-03 11:37:29 -05:00
tomdds
728bb5713f Fix flexVol serving of nginx certificates
FlexVol requires that you specify certificates as secrets in order to get both the certificate and private key in the appropriate format for nginx to consume. Additionally, flexvol shouldn't interfer with other secrets mounted in it's host directory.
2019-12-02 15:45:16 -05:00
tomdds
df6ab4a016 Fix some formatting problems in nginx configs 2019-12-02 15:45:16 -05:00
tomdds
5006945cfe Remove tls volumeMount 2019-12-02 15:45:16 -05:00
tomdds
33ce02d045 Better differentiate between master and staging vault config via overlay 2019-12-02 15:45:16 -05:00
tomdds
253ddaa49e Properly register key vault object types 2019-12-02 15:45:16 -05:00
tomdds
36406372e3 Remove unused secret volume for tls key and cert 2019-12-02 15:45:16 -05:00
tomdds
221e9ab26b Add a staging overlay for the key vault name
Currently we're just using the test vault, but in the future we want to be able to prescribe vault names for different environments via overlay.
2019-12-02 15:45:16 -05:00
tomdds
26bb2f4614 Use mounted all-in-one cert for nginx ssl
Mount the combined key and cert for nginx ssl using flexvol and point the necessary nginx config at it.
2019-12-02 15:45:16 -05:00
tomdds
9b8d5e3662 Document generation and updating of dhparams. 2019-12-02 15:45:16 -05:00
tomdds
1c4e00e914 Update Deploy Readme for FlexVol consumption
Explain via example how you can use FlexVol to mount secrets in our containers.
2019-12-02 15:45:16 -05:00
tomdds
9469d1ff1b Introduce TEMPLATE_ID variable for FlexVolume
FlexVolume requires you specify the tenant id of the key vault instance, so this will need to be templated in for future enviroments
2019-12-02 15:45:16 -05:00
tomdds
949ffa294d Use a single FlexVolume for nginx secrets
Just a name update for now, but we'll use the one flex volume to mount all the nginx related secrets going forward.
2019-12-02 15:45:16 -05:00
tomdds
6acc085a77 Use dhparam.pem from AZ Key Vault 2019-12-02 15:45:16 -05:00
dandds
a3aa3e6935 Config for NGINX SSL/TLS.
This adds additional SSL/TLS config to specify the acceptable TLS
version, cipher suites, session cache, etc. Values are currently based
on the Mozilla Foundation's recommendations for intermediate
compatibility:

https://wiki.mozilla.org/Security/Server_Side_TLS

We will manage NGINX configuration snippets as a K8s ConfigMap so that
they can be included in server blocks as-needed.
2019-12-02 15:45:16 -05:00
dandds
26c5b5ea7f Add JSON logging back for NGINX container.
This configures the NGINX container to log in JSON. It also updates the
K8s config so that we mount all of the key/value pairs available in the
atst-nginx ConfigMap as files in "/etc/nginx/conf.d" inside the
container. This simplifies the config a little.
2019-12-02 15:45:16 -05:00
dandds
d32536cf39 Fix ConfigMap to directory mapping.
Turns out you can't map multiple K8s resources over the same directory.
The K8s secret for the INI file and the ConfigMap for the uWSGI config
both map into /opt/atat/atst in the container. This caused errors when
the container tried to launch. Instead, we need to specify the full file
path for every file we're mapping into that directory to avoid
conflicts.
2019-11-27 09:57:58 -05:00
dandds
69bbb12a8e
Merge pull request #1209 from dod-ccpo/uwsgi-logging
Enable uwsgi logging again.
2019-11-27 09:38:42 -05:00
dandds
d5865c1ab3 Script for compiling K8s config. 2019-11-25 14:24:53 -05:00
tomdds
bc9e4fd142 Include new KeyVault env vars in both diff and apply sections of deploy readme 2019-11-25 11:52:15 -05:00
dandds
4d4c873c73 Enable uwsgi logging again.
Updates the K8s config to enable extended uWSGI JSON logging again. This
commit updates the name of the ConfigMap for the uWSGI config to avoid
confusion.
2019-11-25 11:38:29 -05:00
tomdds
f8e95ae104 Initial FlexVol Setup
This commit is the first part of consuming secrets from the Azure Key Vault. This will set up the required services to consume Azure's RBAC controls in the cluster, an identity to read the secrets, and the tool (FlexVol) to mount the secrets.
2019-11-25 11:19:55 -05:00