Skip to content

Commit c460baa

Browse files
authored
Merge pull request #712 from MetaCell/release/2.2.0
Release/2.2.0
2 parents 392fc28 + d877554 commit c460baa

60 files changed

Lines changed: 1502 additions & 913 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from pprint import pprint
3+
import schemathesis as st
4+
from schemathesis.checks import response_schema_conformance, not_a_server_error
5+
6+
from cloudharness_test import apitest_init # include to perform default authorization
7+
8+
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
9+
10+
try:
11+
schema = st.from_uri(app_url + "/openapi.json")
12+
except:
13+
# support alternative schema location
14+
schema = st.from_uri(app_url.replace("/api", "") + "/openapi.json")
15+
16+
17+
@schema.parametrize(endpoint="/ping")
18+
def test_ping(case):
19+
response = case.call()
20+
pprint(response.__dict__)
21+
assert response.status_code == 200, "this api errors on purpose"
22+
23+
def test_state_machine():
24+
schema.as_state_machine().run()
25+
# APIWorkflow = schema.as_state_machine()
26+
# APIWorkflow.run()
27+
# TestAPI = APIWorkflow.TestCase

cloudharness.png

141 KB
Loading

deployment-configuration/helm/templates/auto-database.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ spec:
7474
volumeMounts:
7575
- name: {{ .app.harness.database.name | quote }}
7676
mountPath: /data/db
77-
{{- if .root.Values.backup.active }}
78-
- name: "db-backups"
79-
mountPath: {{ (printf "%s/%s/%s" .root.Values.backup.dir .app.harness.database.type .app.harness.database.name) | quote }}
80-
readOnly: true
81-
{{- end }}
8277
{{- if eq .app.harness.database.type "postgres" }}
8378
- mountPath: /dev/shm
8479
name: dshm
@@ -92,11 +87,6 @@ spec:
9287
medium: Memory
9388
name: dshm
9489
{{- end }}
95-
{{- if .root.Values.backup.active }}
96-
- name: "db-backups"
97-
persistentVolumeClaim:
98-
claimName: "db-backups"
99-
{{- end }}
10090
---
10191
{{- if .root.Values.backup.active }}
10292
{{- include (print "deploy_utils.database." .app.harness.database.type ".backup") . }}

deployment-configuration/helm/templates/auto-gatekeepers.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ data:
1818
enable-default-deny: {{ eq (.app.harness.secured | toString) "true" }}
1919
listen: 0.0.0.0:8080
2020
enable-refresh-tokens: true
21-
server-write-timeout: 180s
22-
upstream-response-header-timeout: 180s
21+
server-write-timeout: {{ .app.harness.proxy.timeout.send | default .root.Values.proxy.timeout.send | default 180 }}s
22+
upstream-timeout: {{ .app.harness.proxy.timeout.read | default .root.Values.proxy.timeout.read | default 180 }}s
23+
upstream-response-header-timeout: {{ .app.harness.proxy.timeout.read | default .root.Values.proxy.timeout.read | default 180 }}s
24+
upstream-expect-continue-timeout: {{ .app.harness.proxy.timeout.read | default .root.Values.proxy.timeout.read | default 180 }}s
25+
server-read-timeout: {{ .app.harness.proxy.timeout.read | default .root.Values.proxy.timeout.read | default 180 }}s
26+
upstream-keepalive-timeout: {{ .app.harness.proxy.timeout.keepalive | default .root.Values.proxy.timeout.keepalive | default 180 }}s
2327
http-only-cookie: false
2428
tls-cert:
2529
tls-private-key:
@@ -65,7 +69,7 @@ data:
6569
<h2 class="message">403 Permission Denied</h2>
6670
<div class="error-details">
6771
Sorry, you do not have access to this page, please contact your administrator.
68-
If you have been assigned new authorizations try to <a href="/oauth/logout?redirect=/">login again</a>.
72+
If you have been assigned new authorizations, try to refresh the page or to <a href="/oauth/logout?redirect=/">login again</a>.
6973
</div>
7074
</div>
7175
</div>

deployment-configuration/helm/templates/ingress.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ metadata:
3838
cert-manager.io/issuer: {{ printf "%s-%s" "letsencrypt" .Values.namespace }}
3939
{{- end }}
4040
nginx.ingress.kubernetes.io/ssl-redirect: {{ (and $tls .Values.ingress.ssl_redirect) | quote }}
41-
nginx.ingress.kubernetes.io/proxy-body-size: '250m'
41+
nginx.ingress.kubernetes.io/proxy-body-size: '{{ .Values.proxy.payload.max }}m'
4242
nginx.ingress.kubernetes.io/proxy-buffer-size: '128k'
4343
nginx.ingress.kubernetes.io/from-to-www-redirect: 'true'
4444
nginx.ingress.kubernetes.io/rewrite-target: /$1
45+
nginx.ingress.kubernetes.io/auth-keepalive-timeout: {{ .Values.proxy.timeout.keepalive | quote }}
46+
nginx.ingress.kubernetes.io/proxy-read-timeout: {{ .Values.proxy.timeout.read | quote }}
47+
nginx.ingress.kubernetes.io/proxy-send-timeout: {{ .Values.proxy.timeout.send | quote }}
4548
spec:
4649
rules:
4750
{{- range $app := .Values.apps }}

deployment-configuration/helm/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ backup:
6767
memory: "64Mi"
6868
# -- K8s cpu resource definition.
6969
cpu: "50m"
70+
proxy:
71+
timeout:
72+
# -- Timeout for proxy connections in seconds.
73+
send: 60
74+
# -- Timeout for proxy responses in seconds.
75+
read: 60
76+
keepalive: 60
77+
payload:
78+
# -- Maximum size of payload in MB
79+
max: 250

deployment-configuration/value-template.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ harness:
2222
- administrator
2323
- uri: /api/openapi.json
2424
white-listed: true
25+
- uri: /openapi.json
26+
white-listed: true
2527
# -- Defines reference deployment parameters. Values maps to k8s spec
2628
deployment:
2729
# -- When true, enables automatic deployment
@@ -125,3 +127,13 @@ harness:
125127
smoketest: true
126128
ignoreConsoleErrors: false
127129
ignoreRequestErrors: false
130+
proxy:
131+
timeout:
132+
# -- Timeout for proxy connections in seconds.
133+
send:
134+
# -- Timeout for proxy responses in seconds.
135+
read:
136+
keepalive:
137+
payload:
138+
# -- Maximum size of payload in MB
139+
max:

docs/accounts.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,22 @@ harness:
6262
secured: open
6363
```
6464

65+
#### Proxy specific configurations
66+
Proxy configurations can be personalized in the application in the case that we want to have more restrictive values than the global ones (see [here](./ingress-domains-proxies.md#proxy-configurations) for more )
6567

68+
```yaml
69+
harness:
70+
proxy:
71+
timeout:
72+
# -- Timeout for proxy connections in seconds.
73+
send:
74+
# -- Timeout for proxy responses in seconds.
75+
read:
76+
keepalive:
77+
payload:
78+
# -- Maximum size of payload in MB
79+
max:
80+
```
6681
### Secure an enpoint with OpenAPI
6782

6883
In every api endpoint that you want to secure, add the bearerAuth security as in the example:

docs/applications/databases.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,49 @@ Per default, database backups are disabled. However, you can overwrite backups b
111111

112112
```yaml
113113
backup:
114-
active: true
114+
active: true
115115
```
116116

117+
See all the default values [here](../../deployment-configuration/helm/values.yaml).
117118
You can find additional configuration fields for backups to overwrite in the generated `deployment/helm/values.yaml` once you deploy your applications.
118119

119120
Backups are defined for `mongo` and `postgres` database in form of a [K8s CronJob](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) that creates a dump of the database and stores it in a different persistent volume on the same cluster.
120121

121-
This is done periodically according to a configurable schedule, per default once a day.
122+
This is done periodically according to a configurable schedule, per default every 5 minutes.
123+
124+
A smart retention strategy is used for backups, by default:
125+
- all current days backups
126+
- one per day, last 7 days
127+
- one per week, last 4 weeks
128+
- one per month, last 6 months
129+
130+
Implementation of backups and retention is based on https://github.com/prodrigestivill/docker-postgres-backup-local.
131+
132+
#### How to monitor and restore backups
133+
134+
Backups are stored in a Kubernetes volume named `db-backups`.
135+
136+
Can mount the volume to your database pod by adding the following to your db deployment:
137+
138+
```yaml
139+
...
140+
spec:
141+
template:
142+
spec:
143+
containers:
144+
- ...
145+
volumeMounts:
146+
- name: "db-backups"
147+
mountPath: /backups
148+
readOnly: true
149+
...
150+
volumes:
151+
...
152+
- name: "db-backups"
153+
persistentVolumeClaim:
154+
claimName: "db-backups"
155+
```
156+
122157

123158

124159
### MongoDB

docs/ingress-domains-proxies.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Ingress, domains and proxies
2+
3+
## Default configurations for domain and subdomains
4+
Cloud Harness makes it very easy to configure domains and proxies, by making
5+
an underlying assumption:
6+
7+
- Applications share a main base domain (say ch.org)
8+
- Applications can define a subdomain (say myapp)
9+
10+
The main domain is configured in the [root values file](../deployment-configuration/values-template.yaml) and
11+
it is usually overridden by the `harness-deployment` command, e.g.
12+
13+
```
14+
harness-deployment ... -d ch.org
15+
```
16+
17+
The subdomain is defined in the application's values.yaml file in
18+
harness.subdomain (see for instance the [samples application configuration](../applications/samples/deploy/values.yaml))
19+
20+
For instance on applications/myapp/deploy/values.yaml:
21+
22+
```yaml
23+
harness:
24+
subdomain: myapp
25+
```
26+
27+
The above configurations put together create an ingress configuration for https://myapp.ch.org and automatically configure letsencrypt to create and renew certificates.
28+
29+
Note:
30+
that the tls and letsencrypt configurations are enabled by default but should usually be disabled locally with
31+
32+
```
33+
harness-deployment ... -dtls -l
34+
```
35+
36+
## Main application
37+
38+
The "main" application is deployed on the base domain.
39+
In order to specify a main application, override the value in your `/deployment-configuration/values-template.yaml` file.
40+
41+
Example
42+
```yaml
43+
mainapp: myapp
44+
```
45+
This creates a reverse proxy to https://ch.org pointing to myapp
46+
47+
## Proxy configurations
48+
49+
Ingress is a reverse proxy and as such has some configurations to take into account.
50+
The most common configurations are connection timeouts and payload size.
51+
52+
To configure it, override the following values in your `deployment-configuration/values-template.yaml` file.
53+
54+
```yaml
55+
proxy:
56+
timeout:
57+
# -- Timeout for proxy connections in seconds.
58+
send: 60
59+
# -- Timeout for proxy responses in seconds.
60+
read: 60
61+
keepalive: 60
62+
payload:
63+
# -- Maximum size of payload in MB
64+
max: 250
65+
```
66+
67+
Note that in the case that gatekeepers are enabled, the same configurations are applied
68+
to the gatekeepers, unless the application override them on `harness.proxy.*`.
69+
See also the [gatekeepers documentation](./accounts.md#secure-and-enpoint-with-the-gatekeeper).

0 commit comments

Comments
 (0)