Commit Graph

71 Commits

Author SHA1 Message Date
Iain Sproat ee7c9f0a0c feat(helm): s3 configuration can be loaded from configmap (#1048)
* feat(helm): s3 configuration can be loaded from configmap
- Variables for s3's configuration can now be read in from a configmap in the cluster. This allows
deployment tooling, such as Terraform or CloudFormation, to dynamically create an s3 bucket and
create a configmap with the necessary values. This decouples the cluster deployment from the helm
release.
* Update values.schema.json for helm chart
- also include changes from a previous commit that had not been included previously
2022-09-30 10:34:08 +01:00
Iain Sproat 77678ecaa8 feat(helm chart): secrets can be referenced from different kubernetes Secret resources (#1005)
* feat(helm chart): secrets can be referenced from different kubernetes Secret resources

Currently secrets have to be referenced from a single kubernetes Secret resource (default name
'server-vars').  This PR allows each secret to be loaded from a separate kubernetes Secret.  If
values for individual secrets are not provided, it defaults to the previous single kubernetes
resource.  This single kubernetes secret should now be considered deprecated in favour of individual
references.

* Fix error in Redis key

* Fix DNS egress for Redis in CiliumNetworkPolicy

- only give access to optional secrets if the component is enabled

* Values should be empty by default to allow for backwards compatibility
2022-09-21 16:27:05 +02:00
Iain Sproat 9f9f1c381f Only create configmap for DB certificate if certificate is provided in helm chart (#999)
- otherwise, we should expect the configmap to already be in the namespace
2022-09-09 11:10:46 +01:00
Iain Sproat 23bc801eb0 fix(helm chart): allow egress to auth providers (#970)
* fix(helm chart): allow egress to auth providers
* Increase Azure AD allowlist to match https://docs.microsoft.com/en-us/azure/azure-portal/azure-portal-safelist-urls?tabs=public-cloud
* Allows customisation of azure AD domains
2022-08-29 12:10:37 +01:00
Iain Sproat 278da16e53 fix(helm chart server kubernetes network policy): update CIDR for Apollo (#968)
Apollo responded to our support question, they confirmed that 34.120.83.176/32 is sufficient for
egress to usage-reporting.api.apollographql.com
2022-08-26 17:05:32 +01:00
Iain Sproat 5aa00784a6 fix(helm chart): allow egress from server to email server (#966)
Network Policies omitted to allow egress to email.  This commit allows egress to email.
2022-08-25 16:00:34 +01:00
Iain Sproat ab0c60ec57 Helm Chart: Network Policies allow server egress to apollo (#965)
* fix(helm chart): allow egress in server Network Policies to Apollo

The Cilium and Kubernetes network policies currently do not allow egress from the server to Apollo
for graphql monitoring.

Kubernetes Network Policies don't allow domain names.  We have an open support ticket with Apollo
Studio to request which CIDR to limit egress to.  Until then, we will need to open egress to
everywhere if a Kubernetes Network Policy is used.
2022-08-25 15:08:25 +01:00
Iain Sproat d6f6a64630 fix(helm chart): remove unnecessary values from helm chart (#964)
* fix(helm chart): remove unused values from helm chart

Previous commit introduced two additional values that are not being used for s3.  This commit
removes them.

* Looks up domain or IP from secret for redis and postgres

- undertakes a kubectl get on the secret.  The user or service account that deploys helm must have permissions to view the secret.
- fix: matchName for domain instead of matchPattern
- fix: typo in protocol

* Only allow monitoring ingress if monitoring is enabled

* Port can be determine from the provided secret
 - updates values.yaml to only require port for postgres and redis for inCluster endpoints
2022-08-25 10:36:15 +02:00
Iain Sproat b61f0ffabe Cilium network policies (#954)
* feat(helm chart): deployes Cilium Network Policies when configured

Cilium Network Policies provide more features over regular Kubernetes Network Policies, but Cilium
is not available everywhere.  When selected by an operator, Cilium Network Policies will be deployed
instead of Kubernetes Network Policies.

Fixes https://github.com/specklesystems/speckle-server/issues/913

* Cilium Network Policy for fileimport service.
* tested only for external host.
* Still to test internal pod and external IP.

* Cilium network policy for file import service restricts DNS

* allows egress to service instead of endpoint
* file import service uses service url of speckle-server
* helper functions for server and dns

* DRY the prometheus selector

* CiliumNetworkPolicy for frontend

* CiliumNetworkPolicy for monitoring service

* CiliumNetworkPolicy for preview service

* CiliumNetworkPolicy for test

* CiliumNetworkPolicy for webhook_service

* CiliumNetworkPolicy for Server

* Test should egress to domain, not internally

* Test should be in tests directory to match Helm convention for tests
* Test should explicitly deny ingress from everywhere

* Server needs to egress to canonical domain (i.e. itself)

- DNS and egress for canonical domain added to Server
- As Test also egresses via canonical domain to access Server, we do not require the intra-cluster ingress to the server from the test pod
- Explicitly deny all egress from frontend

* WIP update to schema.json

* Breaking Change: inCluster network policies supported for cilium

* Breaking change: kubernetes network policy podSelector and namespaceSelector are now at a different level
* Updates schema.json

* add notes to remove egress once bug is fixed
2022-08-24 17:25:08 +02:00
Iain Sproat 56d0d54bca refactor(helm chart): explicitly define the deployment rollout strategy (#963)
Partially addresses https://github.com/specklesystems/speckle-server/issues/925
2022-08-24 17:21:01 +02:00
Iain Sproat 44bd5919f8 Revert "perf(Docker images): production images are based on distroless (#899)" (#934)
This reverts commit 7fe41b1fb2.
2022-08-16 16:42:59 +01:00
Iain Sproat 7fe41b1fb2 perf(Docker images): production images are based on distroless (#899)
- perf(server, webhook-service): production images are based on distroless

Reduces image file size by >40% for images which can use distroless base image.  As
well as improving boot-up & restart time (via smaller download & load size), Distroless reduces the
attack surface area by removing almost all binaries & packages (e.g. shell, chown) that are not
necessary to run node.

- ensures distroless node images run tini
- removes fonts-dejavu-core and fontconfig from speckle-server
- Remove man and doc files if they exist
- args hoisted to top of Dockerfile and consolidated
- env vars consolidated to prevent additional layers

address https://github.com/specklesystems/speckle-server/issues/883
2022-08-16 16:17:07 +01:00
Iain Sproat 49fdd818ce docs(helm chart): values.yaml is documented and json.schema provided (#932)
* docs(helm chart): values.yaml is documented and json.schema provided

Helm Chart values.yaml file is documented with inline comments.  These have been used to generate a
README (in the helm repo) and a values.json.schema file.

fixes https://github.com/specklesystems/speckle-server/issues/887
fixes https://github.com/specklesystems/speckle-server/issues/867
2022-08-16 14:41:34 +01:00
Iain Sproat ca1a612a29 feat(helm chart): serviceAccounts are provided for each service (#922)
ServiceAccounts for each service do not mount service account token (which allows access to the
kubernetes API), and limit the secrets each user of the service account has access to.

Fixes https://github.com/specklesystems/speckle-server/issues/859
2022-08-15 16:24:34 +01:00
Iain Sproat 35e2652714 feat(helm chart): node affinities, tolerations etc. are configurable (#926)
* feat(helm chart): node affinities, tolerations etc. are configurable

Kubernetes operators should be able to configure Speckle to be deployed on certain nodes based on
rules they provide.  This commit allows affinity, nodeSelector, tolerations, and
topologySpreadConstrains to be provided by the operator.

fixes https://github.com/specklesystems/speckle-server/issues/861
2022-08-15 16:04:50 +01:00
Iain Sproat da7dafe819 fix(fileimport service): s3 is not required by fileimport service (#924)
Fileimport service retreives blobs via the server storage API, and not directly from s3.  Fileimport
service no longer requires information or credentials about s3.
2022-08-15 15:49:10 +01:00
Iain Sproat 19b59fa4d8 fix(frontend): frontend revert security context to prior permissions (#929)
Frontend could not chown within a rw emptyDir
2022-08-15 14:56:26 +01:00
Iain Sproat 5972e6b42a fix(frontend): frontend currently cannot run as non-root (#928)
Nginx needs to bind to port 80 which requires root permissions
2022-08-15 15:13:44 +02:00
Peter Grainger 72d27b9a7c Allow save object to S3 in different region (#910)
* Allow save object to S3 in different region

* feat(helm & docker-compose): adds S3_REGION to helm chart & docker-compose

Explicitly adding the environment variable to deployment configuration files provides system operators with documentation of its existence.

Set to empty by default, which will result in the default value being used.

Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2022-08-15 14:24:30 +02:00
Iain Sproat 0084102d0d feat(helm chart): network policies are provided for all services (#909)
* feat(helm chart): network policies are provided for all services

Network policies are used to deny arbitrary egress and ingress to a pod, providing more security
hardening.

Fix https://github.com/specklesystems/speckle-server/issues/860

* NetworkPolicies for remaining services

* Network policies are configurable but enabled by default

* fix to naming

* Use named port

* Helper function for defining redis egress

* Network policy is more tightly defined to port for service if fqdn

* if an IP is provided for redis, postgres, or blob storage, egress is limited to that IP

* Note about limitations

* Simplifies networkpolicy logic by requiring variables to be provided in values.yaml

* default disable networkpolicy, otherwise end users will have to provide all the additional values and that could become confusing
* supports dependencies being deployed within the same cluster

* Disable network policies by default

* Ensure the host name does not contain a port

* Exclude (likely) kubernetes IP ranges from allowed egress

* Add explicit ingress to the server from fileimport and test

* disable test networkpolicy if test is disabled

* Allow egress to sentry
* remove access to s3 from preview service
* remove access to redis from fileimport service

* Allow prometheus ingress to metrics endpoints

* tightens ingress by restricting to the prometheus pod in a single namespace

* Limit ingress on the server to the nginx ingress controller and prometheus

* Limit ingress to frontend to just the nginx ingress controller

* Fileimport does not require s3
2022-08-15 14:23:14 +02:00
Iain Sproat fb5631bd32 feat(helm chart): prometheus monitoring namespace and release name should be configurable (#914)
* feat(helm chart): prometheus monitoring namespace and release name should be configurable

Currently Speckle assumes prometheus is deployed in the 'speckle' namespace and is deployed as a
release named 'kube-prometheus-stack'.  This commit introduces non-breaking changes that allow
custom values for these to be provided, defaulting to the current assumed values if they are not
provided.

fixes https://github.com/specklesystems/speckle-server/issues/863

* Fix serviceMonitor so that it can find services in a different namespace

* Namespace selector is not required if the default namespace is being used
2022-08-15 14:21:01 +02:00
Iain Sproat 65a00dca2e feat(helm chart): add SecurityContext to pods and containers (#917)
* feat(helm chart): add SecurityContext to pods and containers

Speckle pods should run with minimal privileges and capabilities to function.

Fix https://github.com/specklesystems/speckle-server/issues/857

* Update securityContext for all pods

* frontend runs as nonroot and readonly root filesystem

- set fsgroup for all pods with volumes

* Frontend requires write directory at /etc/nginx/conf.d

* Allow openresty log directory to be writable

* feat(helm local test): add test container into the make script

Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
2022-08-15 14:20:19 +02:00
Iain Sproat 427050a15d chore(pre-commit): Add shellcheck to pre-commit hook (#850)
* chore(pre-commit): adds shellcheck
* Resolves shellcheck linting issues in existing files
2022-08-09 15:00:51 +01:00
Iain Sproat 1c5964fc41 Add Hadolint to pre-commit (#848)
* Adds hadolint as pre-commit step
* Addresses all hadolint comments
  * Use noninteractive apt-get frontend and clean after install
  * dockerfile RUN statements are consolidated to prevent additional layers
  * installed packages have pinned versions
* build(circleci): use speckle pre-commit runner with built-in hadolint
* Integrate pre-commit with husky bash script for git pre-commit hooks
  * catches errors in bash
  * if pre-commit is installed, it is run
  * if optional additional binaries are installed, further pre-commit steps are run
* Update README with revised developer instructions
* Adds a pre-commit yarn script
2022-08-09 13:47:02 +01:00
Iain Sproat 81bed0c760 style: at newlines at end of files (#893) 2022-08-08 11:06:56 +02:00
Iain Sproat 3eaf72f830 refactor(helm chart): DRY common labels (#884)
* refactor(helm chart): dRY for some labels

* Metadata for Chart.yaml

* refactor(helm chart): dRY using common selector labels

Able to remove `app` and `project` labels from each template and incorporate into definitions
2022-08-08 11:05:22 +02:00
Iain Sproat 80d9aa0e9f refactor(helm chart): use named ports where possible (#898) 2022-08-08 11:03:57 +02:00
Iain Sproat a0fe0b8f8a feat(helm chart): use standard helm labels on all pods and services (#882)
Helm best practices recommend use of standard labels
https://helm.sh/docs/chart_best_practices/labels/#standard-labels

fix https://github.com/specklesystems/speckle-server/issues/864
2022-08-04 14:34:20 +01:00
Iain Sproat 2821f4f243 Helm refactor deployments to separate directories (#877)
* refactor(helm chart): separate each service into a directory
2022-08-04 10:15:10 +01:00
Iain Sproat 57eb9c21f6 Configurable imagePullPolicy (#875)
* style(helm chart): define named ports on pods and target them in Services

Named ports improve flexibility and reduce configuration errors

Fix https://github.com/specklesystems/speckle-server/issues/868

* feat(helm): enables imagePullPolicy to be configured by operator

Fix https://github.com/specklesystems/speckle-server/issues/869

* Fix indentation

* Fix broken merge from main
2022-08-04 11:08:17 +02:00
Iain Sproat fd9c891c74 style(helm chart): define named ports on pods and target them in Services (#873)
Named ports improve flexibility and reduce configuration errors

Fix https://github.com/specklesystems/speckle-server/issues/868
2022-08-04 10:53:38 +02:00
Iain Sproat d2a1bf210a docs(helm chart): include logo 2022-08-03 18:54:09 +01:00
Gergő Jedlicska 8f922dbd62 fix(helm chart): fix not quoted config value (#840) 2022-07-29 12:22:42 +02:00
Iain Sproat 90847e422d Feat: configurable file limits (#835)
* Feat: configurable file limits

* ci(circleci): container build speed imporvements

* feat(frontend nginx): add file size limit configurability to frontend nginx

* feat(server blobstorage): use the new file size limit customization value

* feat(helm chart): implement the file size configuration in the helm chart

* fix(frontend docker): fix entrypoint script

* fix(server blobstorage): fix env var parsing NaN

* feat(fileimport-service): add customizable import timeout

* feat(helm chart): add fileimport service timeout value to helm chart

* feat(blobstorage): add server side blob storage size limits

* feat(docker-compose): add blob size limit env var to  docker-compose files

* refactor(frontend file uploads): refactor file uploads to use `useQuery`

* refactor(server env helper): move env helper to shared module

* refactor(blobstorage): use env helper for file size limit

* refactor(frontend file uploads): use generated query document

* fix(server blob sotrage): fix file size limit function call

Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
2022-07-29 12:00:29 +02:00
Kristaps Fabians Geikins 86c63c29db feat: adding extra apollo studio env vars to helm chart (#830)
* feat: adding extra apollo studio env vars to helm chart

* made apollo read version from SPECKLE_SERVER_VERSION

* moved from graph_ref to graph_id

* changing up some values
2022-07-19 16:36:16 +02:00
Kristaps Fabians Geikins f046df86ca feat: helm chart support for apollo studio reporting (#829) 2022-07-18 14:38:16 +02:00
Gergő Jedlicska c894f40f83 minor updates (#817)
* feat(server): add server authz pipeline rework first sketch

* feat(server authz): add new server authz middleware poc implementation

* test(server authz): add unittests for the new server authz workflow

* feat(wip rework of fileuploads vs blob storage): add basim impl of separate blob storage service

* feat(fileimport service): refactored file import service to utilize the new asssetstorage service

* refactor(server errors): refactor server errors to use the shared module definitions

Now all the errors inherit from BaseError

* refactor(fileimport service): cleanup after refactor

* feat(frontend fileimports): use the new blob storage for downloading the original file

* refactor(server fileimports): clean up the remnants of S3 storage from file imports

* refactor(server authz): centralize generic authz pipeline configs

* refactor(server blob storage): refactor / rename everything to use the `blob-storage` name

* ci(circleci): add s3 objectstorage environment variables

* ci(circleci): fix missing env variables

* ci(circleci): add minio test container

* ci(circleci): fix minio app startup

* ci(circleci): enable circleci remote docker

* ci(circleci): fix minio startup

* ci(cirleci): detach and wait properly for minio to start

* ci(circleci): revert to additional minio img config, it only fails when the container is stopped ?!

* ci(circleci): disable file uploads

* fix(fileimports): update with blob storage refactor leftovers

* feat(server blob storage): add blob storage graphql api

* refactor(server errors): merge new errors to shared module

* fix(server comments rte): fix import for RTE error

* chore(fileimports): remove node-fetch from dependency

* chore(server): remove body parser dependency

* fix(server blob storage): fix gql api

* fix(frontend): fix fileupload item not loading the new upload status, cause of premature event fire

* feat(server blob storage): fix file size limit and allow for public streams

* Update packages/server/modules/blobstorage/graph/schemas/blobstorage.graphql

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>

* chore(blobstorage): fix PR review issues

* fix(server): fix import bugs

* test(server): blob storage first test

* test(server blob services): add tests for blob storage services

* test(server blob storage): add service and rest api tests

* test(server blob storage): add server blob storage graphql api tests

* feat(server blob storage): store and make available blob fileHash attribute

* feat(server authz): add fatal failure option to server authz pipeline

* test(server authz): add optional stream context checks with tests

* feat(monitor deployment): add shutdown signal handling to monitor deployment container

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2022-07-04 19:29:45 +02:00
Gergő Jedlicska 1194d4a5b6 fix(helm chart): quote integer value in chart 2022-06-17 09:26:56 +02:00
Gergő Jedlicska d817e6dd0a gergo/pgTimeout (#805)
* feat(server): add server authz pipeline rework first sketch

* feat(server authz): add new server authz middleware poc implementation

* test(server authz): add unittests for the new server authz workflow

* feat(wip rework of fileuploads vs blob storage): add basim impl of separate blob storage service

* feat(fileimport service): refactored file import service to utilize the new asssetstorage service

* refactor(server errors): refactor server errors to use the shared module definitions

Now all the errors inherit from BaseError

* refactor(fileimport service): cleanup after refactor

* feat(frontend fileimports): use the new blob storage for downloading the original file

* refactor(server fileimports): clean up the remnants of S3 storage from file imports

* refactor(server authz): centralize generic authz pipeline configs

* refactor(server blob storage): refactor / rename everything to use the `blob-storage` name

* ci(circleci): add s3 objectstorage environment variables

* ci(circleci): fix missing env variables

* ci(circleci): add minio test container

* ci(circleci): fix minio app startup

* ci(circleci): enable circleci remote docker

* ci(circleci): fix minio startup

* ci(cirleci): detach and wait properly for minio to start

* ci(circleci): revert to additional minio img config, it only fails when the container is stopped ?!

* ci(circleci): disable file uploads

* fix(fileimports): update with blob storage refactor leftovers

* feat(server blob storage): add blob storage graphql api

* refactor(server errors): merge new errors to shared module

* fix(server comments rte): fix import for RTE error

* chore(fileimports): remove node-fetch from dependency

* chore(server): remove body parser dependency

* fix(server blob storage): fix gql api

* fix(frontend): fix fileupload item not loading the new upload status, cause of premature event fire

* feat(server blob storage): fix file size limit and allow for public streams

* Update packages/server/modules/blobstorage/graph/schemas/blobstorage.graphql

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>

* chore(blobstorage): fix PR review issues

* fix(server): fix import bugs

* chore(docker): ignore python venv data for docker build context

* feat(knex): update knex configuration with min max connections and application_name

* feat(helm chart): configure postgres max connections for server in the helm chart

Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2022-06-17 08:38:34 +02:00
Gergő Jedlicska 142219dc4c fix(helm chart): default create namespace to false, it interferes with our deployment setup 2022-05-31 10:24:39 +02:00
Gergő Jedlicska 1c234a86b2 gergo/hotfixes (#785)
* ci(circleci): publish npm packages with the implicit default `latest` tag

* feat(helm chart): add a conditional flag for creating k8s namespace in the helm chart

* fix(server package.json): fix cross-env variable string naming

fix #780
2022-05-30 19:40:20 +02:00
Gergő Jedlicska a4a7cb35b9 feat(fileimports): update container timeout
update timeout in helm chart
2022-05-24 19:14:11 +02:00
Gergő Jedlicska 7d7427671c feat(helm chart): make sure the helm chart includes the required namespace for the app (#765) 2022-05-24 11:31:39 +02:00
Cristian Balas ebe1571488 deployment monitor fix (#744) 2022-05-06 12:59:54 +03:00
cristi8 0a0fe3cb77 monitoring microservices; new container for overall monitoring of a deployment; helm update; helm local testing 2022-05-05 02:01:00 +03:00
luz paz 915cb0afaf Fix various typos
Found via `codespell -q 3 -S CHANGELOG.md -L doesnt,optio,promisses,tread,usera`
2022-04-15 13:49:46 -04:00
Cristian Balas 5a0632b7a3 auth fixes, k8s fixes (#696) 2022-04-13 17:11:11 +03:00
Fabians abe6d5e086 chore: re-formatted everything with prettier 2022-03-30 12:54:24 +03:00
Cristian Balas 4fdd8457ee fixed the fileimport service in helm chart (#587) 2022-02-09 13:09:39 +02:00
Gergő Jedlicska 8f07fb6c8b test(helm test, ci): undo the demo damage 2022-01-14 16:08:14 +01:00