Skip to content

Commit 3def2a6

Browse files
authored
Merge pull request #735 from MetaCell/feature/CH-100
CH-100 Add preliminary docker-compose support
2 parents 7761fe5 + 8bb9a1b commit 3def2a6

371 files changed

Lines changed: 17340 additions & 34784 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ __pycache__
1919
/application-templates
2020
/deployment-configuration
2121
/cloud-harness
22-
.openapi-generator
22+
.openapi-generator
23+
docker-compose.yaml

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ node_modules
77
.coverage
88
*.DS_Store
99
deployment/helm
10+
deployment/compose
11+
docker-compose.yaml
1012
*.egg-info
1113
*.idea
1214
/build

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<img src="https://github.com/MetaCell/cloud-harness/blob/develop/cloudharness.png?raw=true" alt="drawing" width="200"/>
33
</p>
44

5-
CloudHarness is a base infrastructure facilitator for microservice based applications deployed on Kubernetes.
5+
CloudHarness is a base infrastructure facilitator for microservice based applications deployed primarily on Kubernetes.
66
Can scaffold and maintain your cloud solution on top of Cloudharness without writing
77
Kubernetes templates, with in place common utilities and applications already configured for you.
88

99
What building your cloud solution with CloudHarness gives to you:
10-
- Common framework and utilities to develop and deploy micro-service application
10+
- Common framework and utilities to develop and deploy micro-service application
1111
- Helm chart automatic generation
1212
- deployments
1313
- services
@@ -17,6 +17,12 @@ What building your cloud solution with CloudHarness gives to you:
1717
- access gatekeepers configuration
1818
- secrets
1919
- templated config maps from files
20+
- Docker compose configuration generation
21+
- services
22+
- traefik configuration
23+
- databases (postgreql)
24+
- access gatekeepers configuration
25+
- secrets and configmaps
2026
* Automatic build and push of images
2127
* REST-API scaffolding building based on OpenApi
2228
* Continuous deployment script generation
@@ -46,17 +52,18 @@ In particular, these questions may rise:
4652
- How to manage databases without being locked to a specific vendor solution?
4753
- How to perform database backups?
4854
- How to manage secret data?
49-
- What about having a precounfigured account management application?
50-
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
55+
- What about having a precounfigured account management application?
56+
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
5157

5258
# Command line tools
5359

5460
CloudHarness provides the following command line tools to help application scaffolding and deployment.
5561

56-
* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
62+
* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
5763
* `harness-application` - create a new CloudHarness REST application.
5864
* `harness-generate` - generates server and client code for all CloudHarness REST applications.
5965
* `harness-test` - run end to end tests
66+
6067
# Get started
6168

6269
## Prerequisites
@@ -67,13 +74,13 @@ Cloudharness can be used on all major operative systems.
6774
- Linux: supported and tested
6875
- MacOS: supported and tested
6976
- Windows/WSL2: supported and tested
70-
- Windows native: mostly working, unsupported
77+
- Windows native: mostly working, unsupported
7178

7279
### Python
7380
Python 3.9 must be installed.
7481

7582
It is recommended to setup a virtual environment.
76-
With conda:
83+
With conda:
7784
```bash
7885
conda create --name ch python=3.12
7986
conda activate ch
@@ -94,6 +101,10 @@ conda activate ch
94101

95102
[Skaffold](https://skaffold.dev/docs/install/) is the way to go to build and debug your application in your local development environment.
96103

104+
### Docker compose
105+
106+
[Docker Compose](https://docs.docker.com/compose/) is required if the docker compose system is the target (instead of Kubernetes).
107+
97108
### Node environment
98109

99110
A node environment with npm is required for developing web applications and to run end to end tests.
@@ -126,24 +137,25 @@ To (re)generate the code for your applications, run `harness-generate` from the
126137
The script will look for all openapi applications, and regenerate the Flask server code and documentation.
127138
Note: the script will eventually override any manually modified file. To avoid that, define a file openapi-generator-ignore.
128139

129-
# Extend CloudHarness to build your solution
130-
CloudHarness is born to be extended. In order to extend CloudHarness you just need to mirror the folder structure:
131-
* **applications**: place here your custom applications, or override default ones
132-
* **deployment-configuration**: override the helm chart default values and templates
133-
* **infrastructure**: define base images to use in your application
140+
# Extend CloudHarness to build your project
141+
142+
CloudHarness is born to be extended.
143+
144+
The quickest way to start is to install Cloud Harness, copy the *blueprint* folder and build from that with the cli tools, such as
145+
`harness-application`, `harness-generate`, `harness-deployment`.
134146

135-
or simply copy the *blueprint* folder.
147+
See the [developers documentation](docs/dev.md#start-your-project) for more information.
136148

137149
# Build and deploy
138150

139151
The script `harness-deployment` scans your applications and configurations to create the build and deploy artifacts.
140152
Created artifacts include:
141-
- Helm chart
153+
- Helm chart (or docker compose configuration file)
142154
- Skaffold build and run configuration
143155
- Visual Studio Code debug and run configuration
144156
- Codefresh pipeline yaml specification (optional)
145157

146-
With your solution folder structure looking like
158+
With your project folder structure looking like
147159

148160
```
149161
applications
@@ -152,7 +164,7 @@ infrastructure
152164
cloud-harness
153165
```
154166

155-
run
167+
run
156168

157169
```
158170
harness-deployment cloud-harness . [PARAMS]
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
connexion[swagger-ui]==2.14.2
2-
swagger-ui-bundle >= 0.0.2
2+
Flask == 2.2.5
3+
swagger-ui-bundle==0.0.9
34
python_dateutil >= 2.6.0
45
setuptools >= 21.0.0
5-
Flask<3.0.0
6+
7+

application-templates/flask-server/backend/setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
# http://pypi.python.org/pypi/setuptools
1515

1616
REQUIRES = [
17-
"connexion>=2.0.2",
18-
"swagger-ui-bundle>=0.0.2",
17+
"connexion[swagger-ui]<3.0.0",
18+
"Flask>=2.2.5",
1919
"python_dateutil>=2.6.0",
2020
"pyjwt>=2.6.0",
21-
"cloudharness"
21+
"swagger-ui-bundle>=0.0.2",
22+
"cloudharness",
2223
]
2324

2425
setup(
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{{- define "events.deployment" }}
2+
events:
3+
networks:
4+
- ch
5+
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
6+
ports:
7+
- "9094:9092"
8+
expose:
9+
- 5555
10+
- 9094
11+
- 9092
12+
environment:
13+
- CLASSPATH=/opt/kafka/libs/extensions/*
14+
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
15+
- JMX_PORT=5555
16+
command:
17+
- "./bin/kafka-server-start.sh"
18+
- "/etc/kafka/server.properties"
19+
- "--override"
20+
- "default.replication.factor=1"
21+
- "--override"
22+
- "min.insync.replicas=1"
23+
- "--override"
24+
- "offsets.topic.replication.factor=1"
25+
- "--override"
26+
- "offsets.topic.num.partitions=1"
27+
depends_on:
28+
events-kafka-init:
29+
condition: service_completed_successfully
30+
31+
events-kafka-init:
32+
networks:
33+
- ch
34+
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
35+
command:
36+
- "/bin/bash"
37+
- "/etc/kafka-configmap/init.sh"
38+
environment:
39+
40+
pzoo:
41+
networks:
42+
- ch
43+
expose:
44+
- 2181
45+
- 2888
46+
- 3888
47+
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
48+
command:
49+
- "./bin/zookeeper-server-start.sh"
50+
- "/etc/kafka/zookeeper.properties"
51+
environment:
52+
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
53+
depends_on:
54+
events-pzoo-init:
55+
condition: service_completed_successfully
56+
57+
events-pzoo-init:
58+
networks:
59+
- ch
60+
expose:
61+
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
62+
command:
63+
- "/bin/bash"
64+
- "/etc/kafka-configmap/init.sh"
65+
environment:
66+
- PZOO_REPLICAS=1
67+
- ZOO_REPLICAS=0
68+
69+
zoo:
70+
networks:
71+
- ch
72+
expose:
73+
- 2181
74+
- 2888
75+
- 3888
76+
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
77+
command:
78+
- "./bin/zookeeper-server-start.sh"
79+
- "/etc/kafka/zookeeper.properties"
80+
environment:
81+
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
82+
depends_on:
83+
events-zoo-init:
84+
condition: service_completed_successfully
85+
86+
events-zoo-init:
87+
networks:
88+
- ch
89+
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
90+
command:
91+
- "/bin/bash"
92+
- "/etc/kafka-configmap/init.sh"
93+
environment:
94+
- PZOO_REPLICAS=1
95+
- ZOO_REPLICAS=0
96+
- ID_OFFSET=2
97+
{{- end }}

applications/jupyterhub/deploy/resources/hub/jupyterhub_config.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# load the config object (satisfies linters)
2-
from z2jh import (
3-
get_config,
4-
get_name,
5-
get_name_env,
6-
get_secret_value,
7-
set_config_if_not_none,
8-
)
2+
93
c = get_config() # noqa
104

115
import glob
@@ -31,6 +25,14 @@
3125
configuration_directory = os.path.dirname(os.path.realpath(__file__))
3226
sys.path.insert(0, configuration_directory)
3327

28+
from z2jh import ( # noqa
29+
get_config,
30+
get_name,
31+
get_name_env,
32+
get_secret_value,
33+
set_config_if_not_none,
34+
)
35+
3436

3537
def camelCaseify(s):
3638
"""convert snake_case to camelCase
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- define "nfsserver.deployment" }}
2+
{{- with .apps.nfsserver}}
3+
4+
{{ .name }}:
5+
image: {{ .harness.deployment.image }}
6+
environment:
7+
# NFS useDNS? {{ .nfs.useDNS }}
8+
{{- if .nfs.useDNS }}
9+
- NFS_SERVER={{ printf "nfs-server.%s.svc.cluster.local" .namespace }}
10+
{{- end }}
11+
- NFS_PATH={{ .nfs.path }}
12+
- PROVISIONER_NAME={{ printf "%s-nfs-provisioner" .namespace }}
13+
14+
volumes:
15+
- type: volume
16+
source: {{ .nfs.volumeName }}
17+
target: {{ .nfs.path }}
18+
{{- end }}
19+
{{- end }}

applications/samples/api/openapi.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ paths:
2323
description: This won't happen
2424
"500":
2525
description: Sentry entry should come!
26-
deprecated: true
2726
operationId: error
2827
summary: test sentry is working
2928
x-openapi-router-controller: samples.controllers.test_controller
@@ -231,13 +230,11 @@ paths:
231230
schema:
232231
type: object
233232
description: Operation result
234-
deprecated: true
235233
operationId: submit_sync
236234
summary: Send a synchronous operation
237235
x-openapi-router-controller: samples.controllers.workflows_controller
238236
/operation_sync_results:
239237
get:
240-
deprecated: true
241238
tags:
242239
- workflows
243240
parameters:
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
2-
# 2.3 is the last version that supports python 3.4-3.5
3-
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
4-
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
5-
# we must peg werkzeug versions below to fix connexion
6-
# https://github.com/zalando/connexion/pull/1044
7-
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
8-
swagger-ui-bundle >= 0.0.2
9-
python_dateutil >= 2.6.0
10-
setuptools >= 21.0.0
11-
Flask == 2.1.1
1+
connexion[swagger-ui]==2.14.2
2+
Flask == 2.2.5
3+
swagger-ui-bundle==0.0.9

0 commit comments

Comments
 (0)