Skip to content

Commit 231de56

Browse files
authored
Merge pull request #366 from MetaCell/release/0.4.0
Release/0.4.0
2 parents 1ebd027 + 4f61a55 commit 231de56

99 files changed

Lines changed: 2063 additions & 650 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.

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2021, 2022 MetaCell LLC, Ltd.
4+
http://metacell.us
5+
6+
All rights reserved. This program and the accompanying materials
7+
are made available under the terms of the MIT License
8+
which accompanies this distribution, and is available at
9+
http://opensource.org/licenses/MIT
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a copy
12+
of this software and associated documentation files (the "Software"), to deal
13+
in the Software without restriction, including without limitation the rights
14+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
copies of the Software, and to permit persons to whom the Software is
16+
furnished to do so, subject to the following conditions:
17+
18+
The above copyright notice and this permission notice shall be included in all
19+
copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
27+
USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ What building your cluster application with CloudHarness gives to you:
1515
* Log in and user management - based on Keycloak
1616
* Submit batch and asynchronous workflows - based on Argo
1717
* Orchestrate Micro-services - based on Kafka
18+
19+
## Why CloudHarness?
20+
21+
The micro-service architecture is a great to get code separation and flexible development, but may not be of easy
22+
implementation, especially for small development teams/projects.
23+
In particular, these questions may rise:
24+
- How do I create a deployment for my microservices?
25+
- How do I orchestrate my microservices?
26+
- How to create consistent api documentation?
27+
- Do I need to be an experienced devops to create a micro-service based application?
28+
- Wouldn't it be nice to develop a plain database/backend/frontend application without infrastructure boilerplate but still be able to configure everything I want when needed?
29+
- How to run batch operations like ETL processes easily and efficiently in a cloud environment?
30+
- How to manage databases without being locked to a specific vendor solution?
31+
- How to perform database backups?
32+
- How to manage secret data?
33+
- What about having a precounfigured account management application?
34+
- Sooner rather than later I'll need an orchestration queue. Why not have that just ready to use?
1835

1936
## Command line tools
2037

@@ -29,6 +46,7 @@ CloudHarness provides the following command line tools to help application scaff
2946

3047
### Prerequisites
3148

49+
#### Python
3250
Python 3.7+ must be installed.
3351

3452
It is recommended to setup a virtual environment.
@@ -37,7 +55,19 @@ With conda:
3755
conda create --name ch python=3.7
3856
conda activate ch
3957
```
58+
#### Docker
59+
[Docker](https://www.docker.com) is required to build on local terminal.
4060

61+
#### Kubernetes command line client
62+
63+
[kubectl](https://kubernetes.io/docs/tasks/tools/)
64+
65+
#### Helm
66+
#### Skaffold
67+
68+
Skaffold
69+
70+
### Install CloudHarness command line client
4171
Install requirements:
4272

4373
```bash
@@ -73,12 +103,7 @@ for instance with a Google Cloud cluster or a local Minikube.
73103
[--registry localhost:5000] [--tag 0.0.1]`
74104
1. Create the namespace `kubectl create ns ch`
75105
1. Create the namespace `kubectl create ns argo-workflows`
76-
1. (Optional) Try the helm chart with `helm install ch deployment/helm -n ch --dry-run`
77-
1. Install or upgrade the helm chart with `helm install ch deployment/helm -n ch --dependency-update` on helm 3)
78-
79-
To upgrade an already existing chart, run
80-
`helm upgrade ch deployment/helm -n ch --install --reset-values`
81-
106+
1. Build images and Install or upgrade the helm chart with `skaffold deploy`
82107

83108
Can also use Skaffold for local build and deploy (see [here](#skaffold)).
84109

applications/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ are automatically generated with the script `utilities/openapi-generate.py`
1919
After generating the codeChange the Dockerfile in order to inherit from the main Docker file:
2020

2121
```dockerfile
22-
ARG REGISTRY
23-
ARG TAG=latest
24-
FROM ${REGISTRY}cloudharness-base:${TAG}
22+
ARG CLOUDHARNESS_BASE
23+
FROM $CLOUDHARNESS_BASE
2524
```
2625

2726
The only code that should be modified shall go inside `src/[PACKAGE_NAME]/controllers`.

applications/common/server/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
ARG REGISTRY
2-
ARG TAG=latest
3-
ARG CLOUDHARNESS_FLASK=${REGISTRY}cloudharness-flask:${TAG}
1+
ARG CLOUDHARNESS_FLASK
42

53
FROM $CLOUDHARNESS_FLASK
64

applications/events/deploy/resources/broker/server.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default.replication.factor=3
1313

1414
min.insync.replicas=2
1515

16-
auto.create.topics.enable=false
16+
auto.create.topics.enable=true
1717

1818
# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
1919
# This value is recommended to be increased for installations with data dirs located in RAID array.

applications/events/deploy/templates/deployments.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ spec:
5858
initialDelaySeconds: 30
5959
periodSeconds: 30
6060
resources:
61-
limits:
62-
cpu: 500m
63-
memory: 600Mi
64-
requests:
65-
cpu: 50m
66-
memory: 100Mi
61+
{{- .Values.apps.events.kafka.resources | toYaml | nindent 10 }}
6762
volumeMounts:
6863
- mountPath: /etc/kafka
6964
name: config
@@ -116,7 +111,7 @@ spec:
116111
- ReadWriteOnce
117112
resources:
118113
requests:
119-
storage: 10Gi
114+
storage: {{ .Values.apps.events.kafka.storage }}
120115
storageClassName: standard
121116
---
122117
apiVersion: apps/v1
@@ -181,11 +176,7 @@ spec:
181176
initialDelaySeconds: 12
182177
periodSeconds: 60
183178
resources:
184-
limits:
185-
memory: 500Mi
186-
requests:
187-
cpu: 10m
188-
memory: 100Mi
179+
{{- .Values.apps.events.pzoo.resources | toYaml | nindent 10 }}
189180
volumeMounts:
190181
- mountPath: /etc/kafka
191182
name: config
@@ -226,7 +217,7 @@ spec:
226217
- ReadWriteOnce
227218
resources:
228219
requests:
229-
storage: 1Gi
220+
storage: {{ .Values.apps.events.pzoo.storage }}
230221
storageClassName: standard
231222
---
232223
apiVersion: apps/v1
@@ -290,12 +281,9 @@ spec:
290281
timeoutSeconds: 3
291282
initialDelaySeconds: 12
292283
periodSeconds: 60
284+
293285
resources:
294-
limits:
295-
memory: 500Mi
296-
requests:
297-
cpu: 10m
298-
memory: 100Mi
286+
{{- .Values.apps.events.zoo.resources | toYaml | nindent 10 }}
299287
volumeMounts:
300288
- mountPath: /etc/kafka
301289
name: config
@@ -338,5 +326,5 @@ spec:
338326
- ReadWriteOnce
339327
resources:
340328
requests:
341-
storage: 1Gi
329+
storage: {{ .Values.apps.events.zoo.storage }}
342330
storageClassName: standard
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kafka:
2+
resources:
3+
limits:
4+
cpu: 500m
5+
memory: 4000Mi
6+
requests:
7+
cpu: 50m
8+
memory: 100Mi

applications/events/deploy/values.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,31 @@ harness:
1010
name: events
1111
env:
1212
- name: ZK_HOSTS
13-
value: zookeeper:2181
13+
value: zookeeper:2181
1414
kafka:
1515
name: bootstrap
16-
port: 9092
16+
port: 9092
17+
storage: 10Gi
18+
resources:
19+
limits:
20+
cpu: 500m
21+
memory: 600Mi
22+
requests:
23+
cpu: 50m
24+
memory: 100Mi
25+
pzoo:
26+
storage: 1Gi
27+
resources:
28+
limits:
29+
memory: 500Mi
30+
requests:
31+
cpu: 10m
32+
memory: 100Mi
33+
zoo:
34+
storage: 1Gi
35+
resources:
36+
limits:
37+
memory: 500Mi
38+
requests:
39+
cpu: 10m
40+
memory: 100Mi

applications/jupyterhub/Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
ARG CLOUDHARNESS_BASE
2+
FROM $CLOUDHARNESS_BASE as base
3+
14
FROM jupyterhub/k8s-hub:0.9.0
25
USER root
36

4-
# COPY deploy/resources/hub/* /etc/jupyterhub/
5-
# COPY src/jupyterhub/jupyterhub/handlers/* /usr/local/lib/python3.6/dist-packages/jupyterhub/handlers/
6-
# COPY ./src/kubespawner /usr/local/lib/python3.6/dist-packages/
7+
COPY --from=base /libraries/cloudharness-common /libraries/cloudharness-common
8+
COPY --from=base /libraries/client/cloudharness_cli /libraries/client/cloudharness_cli
9+
10+
RUN pip install -e /libraries/cloudharness-common
11+
RUN pip install -e /libraries/client/cloudharness_cli
12+
713
COPY src src
814
RUN pip install ./src/harness_jupyter
915
RUN pip install ./src/chauthenticator
16+
1017
RUN chmod 777 /usr/local/lib/python3.6/dist-packages/ -R
1118
USER jovyan
12-
13-
14-
# CMD ["jupyterhub", "--config", "/srv/jupyterhub_config.py"]

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def camelCaseify(s):
282282
('client_secret', None),
283283
('oauth_callback_url', 'callbackUrl'),
284284
)
285-
285+
print("Auth type", auth_type)
286286
if auth_type == 'google':
287287
c.JupyterHub.authenticator_class = 'oauthenticator.GoogleOAuthenticator'
288288
for trait, cfg_key in common_oauth_traits + (
@@ -383,6 +383,29 @@ def camelCaseify(s):
383383
auth_class_name = full_class_name.rsplit('.', 1)[-1]
384384
auth_config = c[auth_class_name]
385385
auth_config.update(get_config('auth.custom.config') or {})
386+
elif auth_type == 'keycloak':
387+
from cloudharness.applications import get_configuration
388+
from cloudharness.utils.config import CloudharnessConfig
389+
from oauthenticator.generic import GenericOAuthenticator
390+
391+
accounts_app = get_configuration('accounts')
392+
393+
accounts_url = accounts_app.get_public_address()
394+
client_id = accounts_app.conf.webclient.id
395+
client_secret = accounts_app.conf.webclient.secret
396+
realm = CloudharnessConfig.get_namespace()
397+
398+
c.JupyterHub.authenticator_class = GenericOAuthenticator
399+
c.Authenticator.auto_login = True
400+
c.OAuthenticator.client_id = client_id
401+
c.OAuthenticator.client_secret = client_secret
402+
403+
c.GenericOAuthenticator.login_service = "CH"
404+
c.GenericOAuthenticator.username_key = "email"
405+
c.GenericOAuthenticator.authorize_url = f"{accounts_url}/auth/realms/{realm}/protocol/openid-connect/auth"
406+
c.GenericOAuthenticator.token_url = f"{accounts_url}/auth/realms/{realm}/protocol/openid-connect/token"
407+
c.GenericOAuthenticator.userdata_url = f"{accounts_url}/auth/realms/{realm}/protocol/openid-connect/userinfo"
408+
c.GenericOAuthenticator.userdata_params = {'state': 'state'}
386409
else:
387410
raise ValueError("Unhandled auth type: %r" % auth_type)
388411

@@ -518,4 +541,5 @@ def camelCaseify(s):
518541
exec(config_py)
519542

520543
c.apps = get_config('apps')
521-
c.registry = get_config('registry')
544+
c.registry = get_config('registry')
545+
c.domain = get_config('root.domain')

0 commit comments

Comments
 (0)