Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CH-100 Add preliminary docker-compose support #735

Merged
merged 102 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
d25230f
CH-100 Add first code to call a dedicated docker-compose generation
aranega Feb 6, 2024
6f306a1
Squashed commit of the following:
aranega Feb 7, 2024
6bbae19
CH-100 Add first skaffold dedicated generation for docker compose
aranega Feb 7, 2024
5287545
CH-100 Make skaffold script a little bit more generic (ugly)
aranega Feb 7, 2024
9f75c9c
CH-100 Fix issue with entrypoint
aranega Feb 7, 2024
c159a4f
CH-100 Remove generation of chart files for docker-compose
aranega Feb 8, 2024
02bd318
CH-100 Rollback default per-app helm template directory
aranega Feb 9, 2024
1a57064
CH-100 Add subdomain configuration
aranega Feb 9, 2024
b97c19c
CH-100 Fix bad "links" generation
aranega Feb 9, 2024
85dcfd9
CH-100 Add support for aliases and service links
aranega Feb 12, 2024
1ac8226
CH-100 Add first support for auto databases
aranega Feb 14, 2024
56e22b7
CH-100 Add finer grain port handling
aranega Feb 14, 2024
336b558
CH-100 Change way port is exposed to outside world
aranega Feb 15, 2024
a004ffb
CH-100 Fix issue with env var quoting
aranega Feb 15, 2024
f73108c
CH-100 Add special behavior to produce allvalues.yaml
aranega Feb 15, 2024
2370b20
CH-100 Add actual docker-compose.yaml generation in harness-deployment
aranega Feb 15, 2024
5ed630d
CH-100 Add first dedicated templates for postgres
aranega Feb 15, 2024
111a4f3
CH-100 Add volumes for db
aranega Feb 15, 2024
ce4596a
CH-100 Add first template for events
aranega Feb 16, 2024
3868b56
CH-100 Refactor templates for the db
aranega Feb 16, 2024
a0476d6
CH-100 Add /etc/hosts generation
aranega Feb 16, 2024
bd3e423
CH-100 Add specific varenvs by container
aranega Feb 16, 2024
8851c48
CH-100 Rename some templates
aranega Feb 20, 2024
ced7cd2
CH-100 Add first traeffik configuration
aranega Feb 20, 2024
f7ebeb0
CH-100 Fix bad indentation in docker-compose.yaml
aranega Feb 20, 2024
8fdcba6
CH-100 Remove exposition of ports
aranega Feb 20, 2024
428a619
CH-100 Add post-process mechanism to generate files
aranega Feb 21, 2024
9d6c8b2
CH-100 Add new templates
aranega Feb 21, 2024
ae7cf19
CH-100 Add new templates (not modified yet)
aranega Feb 21, 2024
7acc7f5
CH-100 Add generation of resources files
aranega Feb 22, 2024
571c2ab
CH-100 Add dependency between service and db
aranega Feb 22, 2024
9c8c19e
CH-100 Add secret handling
aranega Feb 23, 2024
f6d0c67
CH-100 Remove argo from dependencies
aranega Feb 23, 2024
4fd6dee
CH-100 Change from pyyaml to ruamel
aranega Feb 23, 2024
86c0e4f
CH-100 Remove tmp "events" from deps
aranega Feb 23, 2024
a5909ce
CH-100 Add back sc.yaml
aranega Feb 23, 2024
4379252
CH-100 Add first handling of NFS volume
aranega Feb 23, 2024
46ee140
CH-100 Add volumes conditionnally
aranega Feb 26, 2024
e135c6a
CH-100 Add first tutorial about docker compose
aranega Feb 26, 2024
0f70146
CH-100 Add first real config for gatekeeper
aranega Feb 29, 2024
6bbef64
CH-100 Add reverse proxy config for gatekeeper
aranega Feb 29, 2024
3b437cf
CH-100 Fix path to generated resources
aranega Feb 29, 2024
1135b99
CH-100 Fix bad GK configuration
aranega Mar 1, 2024
b23f03b
CH-100 Adapt gk configuration
aranega Mar 1, 2024
361ca46
CH-100 Fix gk configuration
aranega Mar 1, 2024
74d074e
CH-100 Comment unused "ports"
aranega Mar 1, 2024
fec25be
CH-100 Fix issue with service names in dependencies
aranega Mar 15, 2024
0db12d8
CH-100 Fix issue with db-volumes
aranega Mar 15, 2024
f8d4c84
CH-100 Fix health check for account services
aranega Mar 15, 2024
4121180
CH-100 Fix issue with dependencies
aranega Mar 15, 2024
d81abc2
Merge branch 'develop' of github.com:MetaCell/cloud-harness into feat…
aranega Mar 20, 2024
5bf5532
CH-100 Change tagPolicy for docker-compose target
aranega Mar 26, 2024
319352b
CH-100 Add first information for the docker compose target
aranega Mar 26, 2024
7ec48e1
CH-100 Update documentation
aranega Mar 27, 2024
d85389a
Merge branch 'develop' into feature/CH-100-merge
aranega Mar 27, 2024
7edfcc4
#CH-100 improve documentation
filippomc Mar 27, 2024
e5d56b7
CH-100 First refactoring
aranega Apr 1, 2024
368725a
CH-100 Clean imports/comments
aranega Apr 1, 2024
a4cd813
CH-100 Refactor helm test
aranega Apr 1, 2024
1d63bc4
CH-100 Add tests for docker compose target
aranega Apr 1, 2024
b125dfc
CH-100 Add tests for docker compose
aranega Apr 1, 2024
891b237
Merge branch 'feature/CH-100' of github.com:MetaCell/cloud-harness in…
aranega Apr 1, 2024
2c7e264
CH-100 Fix type hinting for Python 3.9
aranega Apr 1, 2024
866dee9
CH-100 Add conditional test for docker compose if "helm" is installed
aranega Apr 1, 2024
f226829
CH-100 Update scripts
aranega Apr 2, 2024
ac4b863
CH-100 Fix imports of harness-deployment
aranega Apr 2, 2024
9b4dcaa
CH-100 Fix issue with TAG policy in skaffold for docker compose
aranega Apr 18, 2024
10f2c0f
CH-100 Update configuration for db in docker compose
aranega Apr 19, 2024
83d9b8a
CH-100 Add support to link databases with service in docker compose
aranega Apr 19, 2024
e5361ca
CH-100 Change location of traefik config files
aranega Apr 19, 2024
4c5d369
CH-100 Add specific option to expose locally a DB
aranega Apr 20, 2024
6cf0a83
Merge branch 'develop' of github.com:MetaCell/cloud-harness into feat…
filippomc Jul 30, 2024
fba11c6
Merge branch 'develop' of github.com:MetaCell/cloud-harness into feat…
filippomc Sep 12, 2024
4f5f34c
CH-110 fix dc resources mapping when not numbers
filippomc Sep 12, 2024
bbc57d2
chore: remove unneded dependencies
filippomc Sep 12, 2024
2a87ba5
CH-110 small fixes + tests
filippomc Sep 13, 2024
5adab28
CH-110 chore: ignore generated compose file
filippomc Sep 13, 2024
c10719e
CH-126 update python client generation
filippomc Sep 13, 2024
b344129
CH-110 improve output on error
filippomc Sep 13, 2024
1ddd023
CH-126 improve code generation
filippomc Sep 13, 2024
97ff173
CH-110 improve output on error
filippomc Sep 13, 2024
a5477a9
CH-110 fix tests for docker-compose
filippomc Sep 13, 2024
e5fb656
Merge branch 'develop' of github.com:MetaCell/cloud-harness into feat…
filippomc Sep 13, 2024
501ad71
Merge branch 'feature/CH-147-lint' of github.com:MetaCell/cloud-harne…
filippomc Sep 13, 2024
f69b4dd
Merge branch 'develop' of github.com:MetaCell/cloud-harness into feat…
filippomc Sep 13, 2024
8bdb619
CH-66 change secrets in configmap
filippomc Sep 16, 2024
ea20917
Fix merge issues
filippomc Sep 16, 2024
4fe5c4c
Remove wrong dependency
filippomc Sep 16, 2024
b9c3979
CH-147 fix linting issue
filippomc Sep 16, 2024
e838008
CH-17 fix some dependencies
filippomc Sep 16, 2024
4a04180
CH-17 fix python backend debug
filippomc Sep 16, 2024
5a4700f
Update test CI/CD
filippomc Sep 16, 2024
65bcc2b
CH-17 fix build issue
filippomc Sep 16, 2024
1562e95
CH-17 fix broken API tests
filippomc Sep 16, 2024
0f88e07
Improve testing docs
filippomc Sep 16, 2024
2535a16
Improve cookie auth automations
filippomc Sep 16, 2024
18c47cd
Lint fixes
filippomc Sep 17, 2024
0eae79b
Lint fixes
filippomc Sep 17, 2024
3529200
CH-110 small changes to docker compose generation
filippomc Sep 17, 2024
08b9645
CH-100 refactoring, small fixes
filippomc Sep 17, 2024
7eb8ca3
Linting fix
filippomc Sep 17, 2024
8bb9a1b
Linting fix
filippomc Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ __pycache__
/application-templates
/deployment-configuration
/cloud-harness
.openapi-generator
.openapi-generator
docker-compose.yaml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ node_modules
.coverage
*.DS_Store
deployment/helm
deployment/compose
docker-compose.yaml
*.egg-info
*.idea
/build
Expand Down
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<img src="https://github.com/MetaCell/cloud-harness/blob/develop/cloudharness.png?raw=true" alt="drawing" width="200"/>
</p>

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

What building your cloud solution with CloudHarness gives to you:
- Common framework and utilities to develop and deploy micro-service application
- Common framework and utilities to develop and deploy micro-service application
- Helm chart automatic generation
- deployments
- services
Expand All @@ -17,6 +17,12 @@ What building your cloud solution with CloudHarness gives to you:
- access gatekeepers configuration
- secrets
- templated config maps from files
- Docker compose configuration generation
- services
- traefik configuration
- databases (postgreql)
- access gatekeepers configuration
- secrets and configmaps
* Automatic build and push of images
* REST-API scaffolding building based on OpenApi
* Continuous deployment script generation
Expand Down Expand Up @@ -46,17 +52,18 @@ In particular, these questions may rise:
- How to manage databases without being locked to a specific vendor solution?
- How to perform database backups?
- How to manage secret data?
- What about having a precounfigured account management application?
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
- What about having a precounfigured account management application?
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?

# Command line tools

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

* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
* `harness-deployment` - generate the helm chart to deploy on Kubernetes.
* `harness-application` - create a new CloudHarness REST application.
* `harness-generate` - generates server and client code for all CloudHarness REST applications.
* `harness-test` - run end to end tests

# Get started

## Prerequisites
Expand All @@ -67,13 +74,13 @@ Cloudharness can be used on all major operative systems.
- Linux: supported and tested
- MacOS: supported and tested
- Windows/WSL2: supported and tested
- Windows native: mostly working, unsupported
- Windows native: mostly working, unsupported

### Python
Python 3.9 must be installed.

It is recommended to setup a virtual environment.
With conda:
With conda:
```bash
conda create --name ch python=3.12
conda activate ch
Expand All @@ -94,6 +101,10 @@ conda activate ch

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

### Docker compose

[Docker Compose](https://docs.docker.com/compose/) is required if the docker compose system is the target (instead of Kubernetes).

### Node environment

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

# Extend CloudHarness to build your solution
CloudHarness is born to be extended. In order to extend CloudHarness you just need to mirror the folder structure:
* **applications**: place here your custom applications, or override default ones
* **deployment-configuration**: override the helm chart default values and templates
* **infrastructure**: define base images to use in your application
# Extend CloudHarness to build your project

CloudHarness is born to be extended.

The quickest way to start is to install Cloud Harness, copy the *blueprint* folder and build from that with the cli tools, such as
`harness-application`, `harness-generate`, `harness-deployment`.

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

# Build and deploy

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

With your solution folder structure looking like
With your project folder structure looking like

```
applications
Expand All @@ -152,7 +164,7 @@ infrastructure
cloud-harness
```

run
run

```
harness-deployment cloud-harness . [PARAMS]
Expand Down
6 changes: 4 additions & 2 deletions application-templates/flask-server/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
connexion[swagger-ui]==2.14.2
swagger-ui-bundle >= 0.0.2
Flask == 2.2.5
swagger-ui-bundle==0.0.9
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask<3.0.0


7 changes: 4 additions & 3 deletions application-templates/flask-server/backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# http://pypi.python.org/pypi/setuptools

REQUIRES = [
"connexion>=2.0.2",
"swagger-ui-bundle>=0.0.2",
"connexion[swagger-ui]<3.0.0",
"Flask>=2.2.5",
"python_dateutil>=2.6.0",
"pyjwt>=2.6.0",
"cloudharness"
"swagger-ui-bundle>=0.0.2",
"cloudharness",
]

setup(
Expand Down
97 changes: 97 additions & 0 deletions applications/events/deploy/templates-compose/deployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{{- define "events.deployment" }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it doesn't work, better remove it

events:
networks:
- ch
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
ports:
- "9094:9092"
expose:
- 5555
- 9094
- 9092
environment:
- CLASSPATH=/opt/kafka/libs/extensions/*
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
- JMX_PORT=5555
command:
- "./bin/kafka-server-start.sh"
- "/etc/kafka/server.properties"
- "--override"
- "default.replication.factor=1"
- "--override"
- "min.insync.replicas=1"
- "--override"
- "offsets.topic.replication.factor=1"
- "--override"
- "offsets.topic.num.partitions=1"
depends_on:
events-kafka-init:
condition: service_completed_successfully

events-kafka-init:
networks:
- ch
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
command:
- "/bin/bash"
- "/etc/kafka-configmap/init.sh"
environment:

pzoo:
networks:
- ch
expose:
- 2181
- 2888
- 3888
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
command:
- "./bin/zookeeper-server-start.sh"
- "/etc/kafka/zookeeper.properties"
environment:
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
depends_on:
events-pzoo-init:
condition: service_completed_successfully

events-pzoo-init:
networks:
- ch
expose:
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
command:
- "/bin/bash"
- "/etc/kafka-configmap/init.sh"
environment:
- PZOO_REPLICAS=1
- ZOO_REPLICAS=0

zoo:
networks:
- ch
expose:
- 2181
- 2888
- 3888
image: solsson/kafka:2.3.0@sha256:b59603a8c0645f792fb54e9571500e975206352a021d6a116b110945ca6c3a1d
command:
- "./bin/zookeeper-server-start.sh"
- "/etc/kafka/zookeeper.properties"
environment:
- KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/etc/kafka/log4j.properties
depends_on:
events-zoo-init:
condition: service_completed_successfully

events-zoo-init:
networks:
- ch
image: solsson/kafka-initutils@sha256:f6d9850c6c3ad5ecc35e717308fddb47daffbde18eb93e98e031128fe8b899ef
command:
- "/bin/bash"
- "/etc/kafka-configmap/init.sh"
environment:
- PZOO_REPLICAS=1
- ZOO_REPLICAS=0
- ID_OFFSET=2
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# load the config object (satisfies linters)
from z2jh import (
get_config,
get_name,
get_name_env,
get_secret_value,
set_config_if_not_none,
)

c = get_config() # noqa

import glob
Expand All @@ -31,6 +25,14 @@
configuration_directory = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, configuration_directory)

from z2jh import ( # noqa
get_config,
get_name,
get_name_env,
get_secret_value,
set_config_if_not_none,
)


def camelCaseify(s):
"""convert snake_case to camelCase
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- define "nfsserver.deployment" }}
aranega marked this conversation as resolved.
Show resolved Hide resolved
{{- with .apps.nfsserver}}

{{ .name }}:
image: {{ .harness.deployment.image }}
environment:
# NFS useDNS? {{ .nfs.useDNS }}
{{- if .nfs.useDNS }}
- NFS_SERVER={{ printf "nfs-server.%s.svc.cluster.local" .namespace }}
{{- end }}
- NFS_PATH={{ .nfs.path }}
- PROVISIONER_NAME={{ printf "%s-nfs-provisioner" .namespace }}

volumes:
- type: volume
source: {{ .nfs.volumeName }}
target: {{ .nfs.path }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions applications/samples/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ paths:
description: This won't happen
"500":
description: Sentry entry should come!
deprecated: true
operationId: error
summary: test sentry is working
x-openapi-router-controller: samples.controllers.test_controller
Expand Down Expand Up @@ -231,13 +230,11 @@ paths:
schema:
type: object
description: Operation result
deprecated: true
operationId: submit_sync
summary: Send a synchronous operation
x-openapi-router-controller: samples.controllers.workflows_controller
/operation_sync_results:
get:
deprecated: true
tags:
- workflows
parameters:
Expand Down
14 changes: 3 additions & 11 deletions applications/samples/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
connexion[swagger-ui] >= 2.6.0; python_version>="3.6"
# 2.3 is the last version that supports python 3.4-3.5
connexion[swagger-ui] <= 2.3.0; python_version=="3.5" or python_version=="3.4"
# connexion requires werkzeug but connexion < 2.4.0 does not install werkzeug
# we must peg werkzeug versions below to fix connexion
# https://github.com/zalando/connexion/pull/1044
werkzeug == 0.16.1; python_version=="3.5" or python_version=="3.4"
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0
Flask == 2.1.1
connexion[swagger-ui]==2.14.2
Flask == 2.2.5
swagger-ui-bundle==0.0.9
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def valid_token(): # noqa: E501

:rtype: List[Valid]
"""
from cloudharness.middleware import get_authentication_token
token = get_authentication_token()
return 'OK!'


Expand All @@ -24,4 +26,8 @@ def valid_cookie(): # noqa: E501

:rtype: List[Valid]
"""
return 'OK!'
from cloudharness.middleware import get_authentication_token
from cloudharness.auth import decode_token
token = get_authentication_token()
assert decode_token(token)
return 'OK'
7 changes: 5 additions & 2 deletions applications/samples/backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
# http://pypi.python.org/pypi/setuptools

REQUIRES = [
"connexion>=2.0.2",
"connexion[swagger-ui]==2.14.2",
"Flask >= 2.2.5",
"python_dateutil>=2.6.0",
"pyjwt>=2.6.0",
"cloudharness"
"swagger-ui-bundle>=0.0.2",
"cloudharness",

]

setup(
Expand Down
2 changes: 0 additions & 2 deletions applications/samples/deploy/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ harness:
soft:
- workflows
- events
- accounts
- common
- nfsserver
- jupyterhub
accounts:
roles:
Expand Down
Loading
Loading