jac-scale 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jac_scale-0.1.0/PKG-INFO +658 -0
- jac_scale-0.1.0/README.md +640 -0
- jac_scale-0.1.0/jac_scale/__init__.py +0 -0
- jac_scale-0.1.0/jac_scale/abstractions/config/app_config.jac +30 -0
- jac_scale-0.1.0/jac_scale/abstractions/config/base_config.jac +26 -0
- jac_scale-0.1.0/jac_scale/abstractions/database_provider.jac +51 -0
- jac_scale-0.1.0/jac_scale/abstractions/deployment_target.jac +64 -0
- jac_scale-0.1.0/jac_scale/abstractions/image_registry.jac +54 -0
- jac_scale-0.1.0/jac_scale/abstractions/logger.jac +20 -0
- jac_scale-0.1.0/jac_scale/abstractions/models/deployment_result.jac +27 -0
- jac_scale-0.1.0/jac_scale/abstractions/models/resource_status.jac +38 -0
- jac_scale-0.1.0/jac_scale/config_loader.jac +31 -0
- jac_scale-0.1.0/jac_scale/context.jac +14 -0
- jac_scale-0.1.0/jac_scale/factories/database_factory.jac +43 -0
- jac_scale-0.1.0/jac_scale/factories/deployment_factory.jac +43 -0
- jac_scale-0.1.0/jac_scale/factories/registry_factory.jac +32 -0
- jac_scale-0.1.0/jac_scale/factories/utility_factory.jac +34 -0
- jac_scale-0.1.0/jac_scale/impl/config_loader.impl.jac +131 -0
- jac_scale-0.1.0/jac_scale/impl/context.impl.jac +24 -0
- jac_scale-0.1.0/jac_scale/impl/memory_hierarchy.main.impl.jac +63 -0
- jac_scale-0.1.0/jac_scale/impl/memory_hierarchy.mongo.impl.jac +239 -0
- jac_scale-0.1.0/jac_scale/impl/memory_hierarchy.redis.impl.jac +186 -0
- jac_scale-0.1.0/jac_scale/impl/serve.impl.jac +1805 -0
- jac_scale-0.1.0/jac_scale/jserver/__init__.py +0 -0
- jac_scale-0.1.0/jac_scale/jserver/impl/jfast_api.impl.jac +683 -0
- jac_scale-0.1.0/jac_scale/jserver/impl/jserver.impl.jac +79 -0
- jac_scale-0.1.0/jac_scale/jserver/jfast_api.jac +161 -0
- jac_scale-0.1.0/jac_scale/jserver/jserver.jac +101 -0
- jac_scale-0.1.0/jac_scale/memory_hierarchy.jac +138 -0
- jac_scale-0.1.0/jac_scale/plugin.jac +218 -0
- jac_scale-0.1.0/jac_scale/plugin_config.jac +175 -0
- jac_scale-0.1.0/jac_scale/providers/database/kubernetes_mongo.jac +137 -0
- jac_scale-0.1.0/jac_scale/providers/database/kubernetes_redis.jac +110 -0
- jac_scale-0.1.0/jac_scale/providers/registry/dockerhub.jac +64 -0
- jac_scale-0.1.0/jac_scale/serve.jac +148 -0
- jac_scale-0.1.0/jac_scale/targets/kubernetes/kubernetes_config.jac +215 -0
- jac_scale-0.1.0/jac_scale/targets/kubernetes/kubernetes_target.jac +841 -0
- jac_scale-0.1.0/jac_scale/targets/kubernetes/utils/kubernetes_utils.impl.jac +519 -0
- jac_scale-0.1.0/jac_scale/targets/kubernetes/utils/kubernetes_utils.jac +85 -0
- jac_scale-0.1.0/jac_scale/tests/__init__.py +0 -0
- jac_scale-0.1.0/jac_scale/tests/conftest.py +29 -0
- jac_scale-0.1.0/jac_scale/tests/fixtures/test_api.jac +159 -0
- jac_scale-0.1.0/jac_scale/tests/fixtures/todo_app.jac +68 -0
- jac_scale-0.1.0/jac_scale/tests/test_abstractions.py +88 -0
- jac_scale-0.1.0/jac_scale/tests/test_deploy_k8s.py +265 -0
- jac_scale-0.1.0/jac_scale/tests/test_examples.py +484 -0
- jac_scale-0.1.0/jac_scale/tests/test_factories.py +149 -0
- jac_scale-0.1.0/jac_scale/tests/test_file_upload.py +444 -0
- jac_scale-0.1.0/jac_scale/tests/test_k8s_utils.py +156 -0
- jac_scale-0.1.0/jac_scale/tests/test_memory_hierarchy.py +247 -0
- jac_scale-0.1.0/jac_scale/tests/test_serve.py +1835 -0
- jac_scale-0.1.0/jac_scale/tests/test_sso.py +711 -0
- jac_scale-0.1.0/jac_scale/utilities/loggers/standard_logger.jac +56 -0
- jac_scale-0.1.0/jac_scale/utils.jac +16 -0
- jac_scale-0.1.0/jac_scale.egg-info/PKG-INFO +658 -0
- jac_scale-0.1.0/jac_scale.egg-info/SOURCES.txt +60 -0
- jac_scale-0.1.0/jac_scale.egg-info/dependency_links.txt +1 -0
- jac_scale-0.1.0/jac_scale.egg-info/entry_points.txt +3 -0
- jac_scale-0.1.0/jac_scale.egg-info/requires.txt +11 -0
- jac_scale-0.1.0/jac_scale.egg-info/top_level.txt +1 -0
- jac_scale-0.1.0/pyproject.toml +34 -0
- jac_scale-0.1.0/setup.cfg +4 -0
jac_scale-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jac-scale
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Author-email: Jason Mars <jason@mars.ninja>
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: jaclang>=0.9.9
|
|
8
|
+
Requires-Dist: python-dotenv<2.0.0,>=1.2.1
|
|
9
|
+
Requires-Dist: docker<8.0.0,>=7.1.0
|
|
10
|
+
Requires-Dist: kubernetes<35.0.0,>=34.1.0
|
|
11
|
+
Requires-Dist: pymongo<5.0.0,>=4.15.4
|
|
12
|
+
Requires-Dist: redis<8.0.0,>=7.1.0
|
|
13
|
+
Requires-Dist: fastapi<0.122.0,>=0.121.3
|
|
14
|
+
Requires-Dist: uvicorn<0.39.0,>=0.38.0
|
|
15
|
+
Requires-Dist: pyjwt
|
|
16
|
+
Requires-Dist: fastapi-sso<1.0.0,>=0.18.0
|
|
17
|
+
Requires-Dist: python-multipart<1.0.0,>=0.0.21
|
|
18
|
+
|
|
19
|
+
# JAC Scale Deployment Guide
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
`jac start --scale` is a comprehensive deployment and scaling solution for JAC applications that provides three powerful capabilities:
|
|
24
|
+
|
|
25
|
+
### 1. Multi-Layer Memory Architecture
|
|
26
|
+
|
|
27
|
+
- **Caching Layer**: Redis for high-speed data access and session management
|
|
28
|
+
- **Persistence Storage**: MongoDB for reliable, long-term data storage
|
|
29
|
+
- **Optimized Performance**: Intelligent caching strategy to minimize database load and maximize response times
|
|
30
|
+
|
|
31
|
+
### 2. FastAPI Integration with Swagger Documentation
|
|
32
|
+
|
|
33
|
+
- Automatically converts JAC walkers and functions into RESTful FastAPI endpoints
|
|
34
|
+
- Built-in Swagger/OpenAPI documentation for easy API exploration and testing
|
|
35
|
+
- Interactive API interface accessible at `/docs` endpoint
|
|
36
|
+
|
|
37
|
+
### 3. Kubernetes Deployment & Auto-Scaling
|
|
38
|
+
|
|
39
|
+
- **Easy Deployment**: One-command deployment to Kubernetes clusters
|
|
40
|
+
- **Auto-Scaling**: Scale your application based on demand
|
|
41
|
+
- **Database Auto-Provisioning**: Automatically spawns and configures Redis and MongoDB instances
|
|
42
|
+
- **Production-Ready**: Built-in health checks, persistent storage, and service discovery
|
|
43
|
+
|
|
44
|
+
Whether you're developing locally with `jac start` or deploying to production with `jac start --scale`, you get the same powerful features with the flexibility to choose your deployment strategy.
|
|
45
|
+
|
|
46
|
+
## Prerequisites
|
|
47
|
+
|
|
48
|
+
- kubenetes(K8s) installed
|
|
49
|
+
- [Minikube Kubernetes](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fwindows%2Fx86-64%2Fstable%2F.exe+download/) (for Windows/Linux)
|
|
50
|
+
- [Docker Desktop with Kubernetes](https://www.docker.com/resources/kubernetes-and-docker/) (alternative for Windows - easier setup)
|
|
51
|
+
|
|
52
|
+
**Note:** Kubernetes is only needed if you are planning to use `jac start --scale`. If you only want to use `jac start`, Kubernetes is not required.
|
|
53
|
+
|
|
54
|
+
## Quick Start: Running the Travel Planner Demo Application
|
|
55
|
+
|
|
56
|
+
Follow these steps to set up and test the Travel Planner JAC application
|
|
57
|
+
|
|
58
|
+
### 1. Clone the Jaseci Repository
|
|
59
|
+
|
|
60
|
+
First, clone the main Jaseci repository which contains JAC and JAC-Scale:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/jaseci-labs/jaseci.git
|
|
64
|
+
cd jaseci
|
|
65
|
+
git submodule update --init --recursive
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Create Python Virtual Environment
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
python -m venv venv
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 3. Activate the Virtual Environment
|
|
75
|
+
|
|
76
|
+
**Linux/Mac:**
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
source venv/bin/activate
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Windows:**
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
venv\Scripts\activate
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 4. Install JAC and JAC-Scale
|
|
89
|
+
|
|
90
|
+
Install both packages in editable mode from the cloned repository:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install -e ./jac
|
|
94
|
+
pip install -e ./jac-scale
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 5. Download the Demo Application
|
|
98
|
+
|
|
99
|
+
Download the Travel Planner demo application from GitHub:
|
|
100
|
+
|
|
101
|
+
**Option A: Using Git Clone (Recommended)**
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Navigate back to parent directory or choose a location
|
|
105
|
+
cd ..
|
|
106
|
+
|
|
107
|
+
# Clone the entire repository
|
|
108
|
+
git clone https://github.com/jaseci-labs/Agentic-AI.git
|
|
109
|
+
|
|
110
|
+
# Navigate to the Travel Planner backend and rename
|
|
111
|
+
mv Agentic-AI/Travel_planner/BE traveller
|
|
112
|
+
cd traveller
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Option B: Download Specific Folder**
|
|
116
|
+
|
|
117
|
+
If you only want the Travel Planner backend:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Navigate back to parent directory
|
|
121
|
+
cd ..
|
|
122
|
+
|
|
123
|
+
# Install GitHub CLI if not already installed
|
|
124
|
+
# For Linux/Mac with Homebrew:
|
|
125
|
+
brew install gh
|
|
126
|
+
|
|
127
|
+
# For Windows with Chocolatey:
|
|
128
|
+
choco install gh
|
|
129
|
+
|
|
130
|
+
# Clone only the specific folder
|
|
131
|
+
gh repo clone jaseci-labs/Agentic-AI
|
|
132
|
+
mv Agentic-AI/Travel_planner/BE traveller
|
|
133
|
+
cd traveller
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Option C: Manual Download**
|
|
137
|
+
|
|
138
|
+
1. Go to https://github.com/jaseci-labs/Agentic-AI/tree/main/Travel_planner/BE
|
|
139
|
+
2. Click on the green "Code" button
|
|
140
|
+
3. Select "Download ZIP"
|
|
141
|
+
4. Extract the ZIP file
|
|
142
|
+
5. Rename the `BE` folder to `traveller`
|
|
143
|
+
6. Navigate into the folder:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
cd traveller
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 6. Configure Environment Variables
|
|
150
|
+
|
|
151
|
+
You should now be in the `traveller` folder. Create a `.env` file:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Verify you're in the correct directory
|
|
155
|
+
pwd # Should show path ending in /traveller
|
|
156
|
+
|
|
157
|
+
# Create .env file
|
|
158
|
+
touch .env # Linux/Mac
|
|
159
|
+
# OR
|
|
160
|
+
type nul > .env # Windows CMD
|
|
161
|
+
# OR
|
|
162
|
+
New-Item .env # Windows PowerShell
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Add the following to your `.env` file:
|
|
166
|
+
|
|
167
|
+
```env
|
|
168
|
+
OPENAI_API_KEY=your-openai-api-key-here
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 7. Install Demo Application Requirements
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
pip install byllm python-dotenv
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 8. Run the Application with JAC Start
|
|
178
|
+
|
|
179
|
+
To run your application using FastAPI with ShelfStorage (no Kubernetes required):
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
jac start main.jac
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**What this does:**
|
|
186
|
+
|
|
187
|
+
- Starts your JAC application as a FastAPI server
|
|
188
|
+
- Uses ShelfStorage for persisting anchors (lightweight, file-based storage)
|
|
189
|
+
- No database setup required
|
|
190
|
+
- Ideal for development and testing
|
|
191
|
+
|
|
192
|
+
**Access your application:**
|
|
193
|
+
|
|
194
|
+
- Application: http://localhost:8000
|
|
195
|
+
- Swagger Documentation: http://localhost:8000/docs
|
|
196
|
+
|
|
197
|
+
### 9. Set Up Kubernetes (For JAC Scale)
|
|
198
|
+
|
|
199
|
+
To use `jac start --scale`, you need Kubernetes installed on your machine.
|
|
200
|
+
|
|
201
|
+
**Option A: MicroK8s (Windows/Linux/Mac)**
|
|
202
|
+
|
|
203
|
+
- [Official MicroK8s installation guide](https://microk8s.io/)
|
|
204
|
+
- [ubunutu installation guide](https://www.digitalocean.com/community/tutorials/how-to-setup-a-microk8s-kubernetes-cluster-on-ubuntu-22-04)
|
|
205
|
+
|
|
206
|
+
**Option B: Docker Desktop with Kubernetes (Windows - Recommended)**
|
|
207
|
+
|
|
208
|
+
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
|
209
|
+
- Enable Kubernetes in Docker Desktop settings (easier setup)
|
|
210
|
+
|
|
211
|
+
### 10. Deploy with JAC Scale
|
|
212
|
+
|
|
213
|
+
Once Kubernetes is running, you have two deployment methods:
|
|
214
|
+
|
|
215
|
+
#### Method A: Deploy Without Building (Faster)
|
|
216
|
+
|
|
217
|
+
Deploy your application to Kubernetes without building a Docker image:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
jac start main.jac --scale
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**What this does:**
|
|
224
|
+
|
|
225
|
+
- Deploys your JAC application to Kubernetes
|
|
226
|
+
- Automatically provisions Redis and MongoDB as persistence storage
|
|
227
|
+
- Creates necessary Kubernetes resources (Deployments, Services, StatefulSets)
|
|
228
|
+
- Exposes your application via NodePort
|
|
229
|
+
|
|
230
|
+
**Access your application:**
|
|
231
|
+
|
|
232
|
+
- Application: http://localhost:30001
|
|
233
|
+
- Swagger Documentation: http://localhost:30001/docs
|
|
234
|
+
|
|
235
|
+
**Use this when:**
|
|
236
|
+
|
|
237
|
+
- You want faster deployments without rebuilding
|
|
238
|
+
- You're testing configuration changes
|
|
239
|
+
- You're in development mode
|
|
240
|
+
|
|
241
|
+
#### Method B: Build, Push, and Deploy (Production)
|
|
242
|
+
|
|
243
|
+
Build your application as a Docker container and deploy it:
|
|
244
|
+
|
|
245
|
+
**Prerequisites:**
|
|
246
|
+
|
|
247
|
+
1. Create a `Dockerfile` in your `traveller` directory
|
|
248
|
+
2. Add Docker credentials to your `.env` file:
|
|
249
|
+
|
|
250
|
+
```env
|
|
251
|
+
OPENAI_API_KEY=your-openai-api-key-here
|
|
252
|
+
DOCKER_USERNAME=your-dockerhub-username
|
|
253
|
+
DOCKER_PASSWORD=your-dockerhub-password-or-token
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Deploy with build:**
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
jac start main.jac --scale --build
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**What this does:**
|
|
263
|
+
|
|
264
|
+
- Builds a Docker image of your JAC application
|
|
265
|
+
- Pushes the image to DockerHub
|
|
266
|
+
- Deploys the image to Kubernetes
|
|
267
|
+
- Sets up Redis and MongoDB for persistence
|
|
268
|
+
|
|
269
|
+
**Access your application:**
|
|
270
|
+
|
|
271
|
+
- Application: http://localhost:30001
|
|
272
|
+
- Swagger Documentation: http://localhost:30001/docs
|
|
273
|
+
|
|
274
|
+
**Use this when:**
|
|
275
|
+
|
|
276
|
+
- Deploying to production
|
|
277
|
+
- You want to version and host your Docker image
|
|
278
|
+
- Sharing your application with others
|
|
279
|
+
- Creating reproducible deployments
|
|
280
|
+
|
|
281
|
+
### 11. Clean Up Kubernetes Resources
|
|
282
|
+
|
|
283
|
+
When you're done testing, remove all created Kubernetes resources:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
jac destroy main.jac
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**What this does:**
|
|
290
|
+
|
|
291
|
+
- Deletes all Kubernetes deployments, services, and StatefulSets
|
|
292
|
+
- Removes persistent volumes and claims
|
|
293
|
+
- Cleans up the namespace (if custom namespace was used)
|
|
294
|
+
|
|
295
|
+
## Quick Start: Running Todo application with frontend
|
|
296
|
+
|
|
297
|
+
Follow these steps to set up and test the Todo application with frontend
|
|
298
|
+
|
|
299
|
+
### 1. Clone the Jaseci Repository
|
|
300
|
+
|
|
301
|
+
First, clone the main Jaseci repository which contains JAC and JAC-Scale:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
git clone https://github.com/jaseci-labs/jaseci.git
|
|
305
|
+
cd jaseci
|
|
306
|
+
git submodule update --init --recursive
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 2. Create Python Virtual Environment
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
python -m venv venv
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### 3. Activate the Virtual Environment
|
|
316
|
+
|
|
317
|
+
**Linux/Mac:**
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
source venv/bin/activate
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Windows:**
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
venv\Scripts\activate
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 4. Install JAC, JAC-Scale and JAC-Client
|
|
330
|
+
|
|
331
|
+
Install the packages in editable mode from the cloned repository:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
pip install -e ./jac
|
|
335
|
+
pip install -e ./jac-scale
|
|
336
|
+
pip install -e ./jac-client
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### 5. Create Todo application using jac-client
|
|
340
|
+
|
|
341
|
+
Lets create the todo application using jac client.For that lets run following command
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
jac create_jac_app todo
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Then lets copy the todo fully implemented jac code available inside jac-scale/examples/todo to our newly created /todo folder
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
cp jac-scale/examples/todo/app.jac todo/app.jac
|
|
351
|
+
cd todo
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### 8. Run the Application Locally
|
|
355
|
+
|
|
356
|
+
To run your application run the following command
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
jac start app.jac
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Access your application:**
|
|
363
|
+
|
|
364
|
+
- Frontend: http://localhost:8000/cl/app
|
|
365
|
+
- Backend: http://localhost:8000
|
|
366
|
+
- Swagger Documentation: http://localhost:8000/docs
|
|
367
|
+
|
|
368
|
+
you can add new todo tasks
|
|
369
|
+
from the frontend at http://localhost:8000/cl/app
|
|
370
|
+
|
|
371
|
+
### 9. Set Up Kubernetes (For JAC Scale)
|
|
372
|
+
|
|
373
|
+
To use `jac start --scale`, you need Kubernetes installed on your machine.
|
|
374
|
+
|
|
375
|
+
**Option A: MicroK8 (Windows/Linux/Mac)**
|
|
376
|
+
|
|
377
|
+
- [Official MicroK8 installation guide](https://microk8s.io/)
|
|
378
|
+
- [ubunutu installation guide](https://www.digitalocean.com/community/tutorials/how-to-setup-a-microk8s-kubernetes-cluster-on-ubuntu-22-04)
|
|
379
|
+
|
|
380
|
+
**Option B: Docker Desktop with Kubernetes (Windows - Recommended)**
|
|
381
|
+
|
|
382
|
+
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
|
383
|
+
- Enable Kubernetes in Docker Desktop settings (easier setup)
|
|
384
|
+
|
|
385
|
+
### 10. Deploy with JAC Scale
|
|
386
|
+
|
|
387
|
+
Once Kubernetes is running, you have two deployment methods:
|
|
388
|
+
|
|
389
|
+
#### Method A: Deploy Without Building (Faster)
|
|
390
|
+
|
|
391
|
+
Deploy your application to Kubernetes without building a Docker image:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
jac start app.jac --scale
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Access your application:**
|
|
398
|
+
|
|
399
|
+
- Frontend: http://localhost:30001/cl/app
|
|
400
|
+
- Backend: http://localhost:30001
|
|
401
|
+
- Swagger Documentation: http://localhost:30001/docs
|
|
402
|
+
|
|
403
|
+
**Use this when:**
|
|
404
|
+
|
|
405
|
+
- You want faster deployments without rebuilding
|
|
406
|
+
- You're testing configuration changes
|
|
407
|
+
- You're in development mode
|
|
408
|
+
|
|
409
|
+
#### Method B: Build, Push, and Deploy (Production)
|
|
410
|
+
|
|
411
|
+
To Build your application as a Docker container and deploy it you can run
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
jac start app.jac --scale --build
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Access your application:**
|
|
418
|
+
|
|
419
|
+
- Frontend: http://localhost:30001/cl/app
|
|
420
|
+
- Backend: http://localhost:30001
|
|
421
|
+
- Swagger Documentation: http://localhost:30001/docs
|
|
422
|
+
|
|
423
|
+
**Use this when:**
|
|
424
|
+
|
|
425
|
+
- Deploying to production
|
|
426
|
+
- You want to version and host your Docker image
|
|
427
|
+
- Sharing your application with others
|
|
428
|
+
- Creating reproducible deployments
|
|
429
|
+
|
|
430
|
+
### 11. Clean Up Kubernetes Resources
|
|
431
|
+
|
|
432
|
+
When you're done testing, remove all created Kubernetes resources:
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
jac destroy app.jac
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**What this does:**
|
|
439
|
+
|
|
440
|
+
- Deletes all Kubernetes deployments, services, and StatefulSets
|
|
441
|
+
- Removes persistent volumes and claims
|
|
442
|
+
- Cleans up the namespace (if custom namespace was used)
|
|
443
|
+
|
|
444
|
+
## Async Walkers
|
|
445
|
+
|
|
446
|
+
JAC Scale supports async walkers for non-blocking operations like external API calls, database queries, and file I/O.
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
import asyncio;
|
|
450
|
+
|
|
451
|
+
async walker FetchData {
|
|
452
|
+
has url: str;
|
|
453
|
+
|
|
454
|
+
async can fetch with `root entry {
|
|
455
|
+
report {"status": "fetching"};
|
|
456
|
+
await asyncio.sleep(0.1); # Simulate API call
|
|
457
|
+
report {"status": "completed", "data": "result"};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
## Configuration Options
|
|
463
|
+
|
|
464
|
+
### Optional Environment Variables
|
|
465
|
+
|
|
466
|
+
| Parameter | Description | Default |
|
|
467
|
+
|-----------|-------------|---------|
|
|
468
|
+
| `APP_NAME` | Name of your JAC application | `jaseci` |
|
|
469
|
+
| `DOCKER_USERNAME` | DockerHub username for pushing the image | - |
|
|
470
|
+
| `DOCKER_PASSWORD` | DockerHub password or access token | - |
|
|
471
|
+
| `K8s_NAMESPACE` | Kubernetes namespace to deploy the application | `default` |
|
|
472
|
+
| `K8s_NODE_PORT` | Port in which your local kubernetes application will run on| `30001` |
|
|
473
|
+
| `K8s_CPU_REQUEST` | CPU request for the application container | - |
|
|
474
|
+
| `K8s_CPU_LIMIT` | CPU limit for the application container | - |
|
|
475
|
+
| `K8s_MEMORY_REQUEST` | Memory request for the application container | - |
|
|
476
|
+
| `K8s_MEMORY_LIMIT` | Memory limit for the application container | - |
|
|
477
|
+
| `K8s_READINESS_INITIAL_DELAY` | Seconds before readiness probe first checks the pod | `10` |
|
|
478
|
+
| `K8s_READINESS_PERIOD` | Seconds between readiness probe checks | `20` |
|
|
479
|
+
| `K8s_LIVENESS_INITIAL_DELAY` | Seconds before liveness probe first checks the pod | `10` |
|
|
480
|
+
| `K8s_LIVENESS_PERIOD` | Seconds between liveness probe checks | `20` |
|
|
481
|
+
| `K8s_LIVENESS_FAILURE_THRESHOLD` | Consecutive liveness probe failures before restart | `80` |
|
|
482
|
+
| `K8s_MONGODB` | Whether MongoDB is needed (`True`/`False`) | `True` |
|
|
483
|
+
| `K8s_REDIS` | Whether Redis is needed (`True`/`False`) | `True` |
|
|
484
|
+
| `MONGODB_URI` | URL of MongoDB database | - |
|
|
485
|
+
| `REDIS_URL` | URL of Redis database | - |
|
|
486
|
+
| `JWT_EXP_DELTA_DAYS` | Number of days until JWT token expires | `7` |
|
|
487
|
+
| `JWT_SECRET` | Secret key used for JWT token signing and verification | `'supersecretkey'` |
|
|
488
|
+
| `JWT_ALGORITHM` | Algorithm used for JWT token encoding/decoding | `'HS256'` |
|
|
489
|
+
| `SSO_HOST` | SSO host URL | `'http://localhost:8000/sso'` |
|
|
490
|
+
| `SSO_GOOGLE_CLIENT_ID` | Google OAuth client ID | - |
|
|
491
|
+
| `SSO_GOOGLE_CLIENT_SECRET` | Google OAuth client secret | - |
|
|
492
|
+
|
|
493
|
+
## Deployment Modes
|
|
494
|
+
|
|
495
|
+
### Mode 1: Deploy Without Building (Default)
|
|
496
|
+
|
|
497
|
+
Deploys your JAC application to Kubernetes without building a Docker image.
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
jac start main.jac --scale
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Use this when:**
|
|
504
|
+
|
|
505
|
+
- You want faster deployments without rebuilding
|
|
506
|
+
- You're testing configuration changes
|
|
507
|
+
- You're in development mode
|
|
508
|
+
|
|
509
|
+
### Mode 2: Build, Push, and Deploy
|
|
510
|
+
|
|
511
|
+
Builds a new Docker image, pushes it to DockerHub, then deploys to Kubernetes.
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
jac start main.jac --scale --build
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
**Requirements for Build Mode:**
|
|
518
|
+
|
|
519
|
+
- A `Dockerfile` in your application directory
|
|
520
|
+
- Environment variables set:
|
|
521
|
+
- `DOCKER_USERNAME` - Your DockerHub username
|
|
522
|
+
- `DOCKER_PASSWORD` - Your DockerHub password/access token
|
|
523
|
+
|
|
524
|
+
**Use this when:**
|
|
525
|
+
|
|
526
|
+
- Deploying to production
|
|
527
|
+
- You want to version and host your Docker image
|
|
528
|
+
- Sharing your application with others
|
|
529
|
+
|
|
530
|
+
## Important Notes
|
|
531
|
+
|
|
532
|
+
### Implementation
|
|
533
|
+
|
|
534
|
+
- The jac-scale plugin is implemented using **Python and Kubernetes Python client libraries**
|
|
535
|
+
- **No custom Kubernetes controllers** are used → easier to deploy and maintain
|
|
536
|
+
|
|
537
|
+
### Database Provisioning
|
|
538
|
+
|
|
539
|
+
- Databases are created as **StatefulSets** with persistent storage
|
|
540
|
+
- Databases are **only created on the first run**
|
|
541
|
+
- Subsequent `jac start --scale` calls only update application deployments
|
|
542
|
+
- This ensures persistent storage and avoids recreating databases unnecessarily
|
|
543
|
+
|
|
544
|
+
### Performance
|
|
545
|
+
|
|
546
|
+
- **First-time deployment** may take longer due to database provisioning and image downloading
|
|
547
|
+
- **Subsequent deployments** are faster since:
|
|
548
|
+
- Only the application's final Docker layer is pushed and pulled
|
|
549
|
+
- Only deployments are updated (databases remain unchanged)
|
|
550
|
+
|
|
551
|
+
## Deployment Process
|
|
552
|
+
|
|
553
|
+
When you run `jac start --scale`, the following steps are executed:
|
|
554
|
+
|
|
555
|
+
### 1. Create JAC Application Docker Image
|
|
556
|
+
|
|
557
|
+
- Build the application image from the source directory
|
|
558
|
+
- Tag the image with DockerHub repository
|
|
559
|
+
|
|
560
|
+
### 2. Push Docker Image to DockerHub (Build Mode Only)
|
|
561
|
+
|
|
562
|
+
- Authenticate using `DOCKER_USERNAME` and `DOCKER_PASSWORD`
|
|
563
|
+
- Push the image to DockerHub
|
|
564
|
+
- Subsequent pushes are faster since only the final image layer is pushed
|
|
565
|
+
|
|
566
|
+
### 3. Deploy to Kubernetes
|
|
567
|
+
|
|
568
|
+
- Create or update Kubernetes namespace
|
|
569
|
+
- Deploy Redis and MongoDB (first run only)
|
|
570
|
+
- Create application deployment
|
|
571
|
+
- Create services and expose via NodePort
|
|
572
|
+
|
|
573
|
+
## Architecture
|
|
574
|
+
|
|
575
|
+
### K8s pods structure
|
|
576
|
+
|
|
577
|
+

|
|
578
|
+
|
|
579
|
+
## Troubleshooting
|
|
580
|
+
|
|
581
|
+
### Common Issues
|
|
582
|
+
|
|
583
|
+
**Kubernetes cluster not accessible:**
|
|
584
|
+
|
|
585
|
+
- Ensure Kubernetes is running: `kubectl cluster-info`
|
|
586
|
+
- Check your kubeconfig: `kubectl config view`
|
|
587
|
+
|
|
588
|
+
**DockerHub authentication fails:**
|
|
589
|
+
|
|
590
|
+
- Verify your `DOCKER_USERNAME` and `DOCKER_PASSWORD` are correct
|
|
591
|
+
- Ensure you're using an access token (not password) if 2FA is enabled
|
|
592
|
+
|
|
593
|
+
**Namespace doesn't exist:**
|
|
594
|
+
|
|
595
|
+
- The plugin creates namespaces automatically
|
|
596
|
+
- If using a custom namespace, ensure proper permissions
|
|
597
|
+
|
|
598
|
+
**Database connection issues:**
|
|
599
|
+
|
|
600
|
+
- Verify StatefulSets are running: `kubectl get statefulsets -n <namespace>`
|
|
601
|
+
- Check pod logs: `kubectl logs <pod-name> -n <namespace>`
|
|
602
|
+
- Ensure persistent volumes are bound: `kubectl get pvc -n <namespace>`
|
|
603
|
+
|
|
604
|
+
**Application not accessible:**
|
|
605
|
+
|
|
606
|
+
- Check service exposure: `kubectl get svc -n <namespace>`
|
|
607
|
+
- Verify NodePort is not blocked by firewall
|
|
608
|
+
- For Minikube, use: `minikube service <service-name> -n <namespace>`
|
|
609
|
+
|
|
610
|
+
**Build failures:**
|
|
611
|
+
|
|
612
|
+
- Ensure Dockerfile exists in your application directory
|
|
613
|
+
- Check Docker daemon is running
|
|
614
|
+
- Verify sufficient disk space for image building
|
|
615
|
+
|
|
616
|
+
### Getting Help
|
|
617
|
+
|
|
618
|
+
If you encounter issues:
|
|
619
|
+
|
|
620
|
+
1. Check pod status: `kubectl get pods -n <namespace>`
|
|
621
|
+
2. View pod logs: `kubectl logs <pod-name> -n <namespace>`
|
|
622
|
+
3. Describe resources: `kubectl describe <resource-type> <resource-name> -n <namespace>`
|
|
623
|
+
|
|
624
|
+
## Tested Examples
|
|
625
|
+
|
|
626
|
+
You can find more working examples in the examples directory:
|
|
627
|
+
|
|
628
|
+
<!-- - [basic](../jac-client/jac_client/examples/basic/) - Minimal JAC application -->
|
|
629
|
+
<!-- - [basic-full-stack](../jac-client/jac_client/examples/basic-full-stack/) - Basic full-stack application -->
|
|
630
|
+
- [all-in-one](../jac-client/jac_client/examples/all-in-one/) - Complete example with all features
|
|
631
|
+
- [with-router](../jac-client/jac_client/examples/with-router/) - Application with routing
|
|
632
|
+
<!-- - [nested-folders/nested-basic](../jac-client/jac_client/examples/nested-folders/nested-basic/) - Basic nested folder structure -->
|
|
633
|
+
- [nested-folders/nested-advance](../jac-client/jac_client/examples/nested-folders/nested-advance/) - Advanced nested folder structure
|
|
634
|
+
- [basic-auth](../jac-client/jac_client/examples/basic-auth/) - Basic authentication
|
|
635
|
+
- [basic-auth-with-router](../jac-client/jac_client/examples/basic-auth-with-router/) - Authentication with routing
|
|
636
|
+
<!-- - [full-stack-with-auth](../jac-client/jac_client/examples/full-stack-with-auth/) - Full-stack app with authentication -->
|
|
637
|
+
- [css-styling/js-styling](../jac-client/jac_client/examples/css-styling/js-styling/) - JavaScript styling example
|
|
638
|
+
- [css-styling/material-ui](../jac-client/jac_client/examples/css-styling/material-ui/) - Material-UI styling example
|
|
639
|
+
- [css-styling/pure-css](../jac-client/jac_client/examples/css-styling/pure-css/) - Pure CSS styling example
|
|
640
|
+
- [css-styling/sass-example](../jac-client/jac_client/examples/css-styling/sass-example/) - SASS styling example
|
|
641
|
+
- [css-styling/styled-components](../jac-client/jac_client/examples/css-styling/styled-components/) - Styled Components example
|
|
642
|
+
- [css-styling/tailwind-example](../jac-client/jac_client/examples/css-styling/tailwind-example/) - Tailwind CSS example
|
|
643
|
+
- [asset-serving/css-with-image](../jac-client/jac_client/examples/asset-serving/css-with-image/) - CSS with image assets
|
|
644
|
+
- [asset-serving/image-asset](../jac-client/jac_client/examples/asset-serving/image-asset/) - Image asset serving
|
|
645
|
+
- [asset-serving/import-alias](../jac-client/jac_client/examples/asset-serving/import-alias/) - Import alias example
|
|
646
|
+
<!-- - [little-x](../jac-client/jac_client/examples/little-x/) - Little X application example -->
|
|
647
|
+
|
|
648
|
+
Each example includes complete source code and can be run with `jac start`.
|
|
649
|
+
|
|
650
|
+
## Next Steps
|
|
651
|
+
|
|
652
|
+
After successfully running the demo:
|
|
653
|
+
|
|
654
|
+
- **For local development (`jac start`)**: Access your application at http://localhost:8000 and explore the Swagger documentation at http://localhost:8000/docs
|
|
655
|
+
- **For Kubernetes (`jac start --scale`)**: Access your application at http://localhost:30001 and explore the Swagger documentation at http://localhost:30001/docs
|
|
656
|
+
- Modify the JAC application and redeploy
|
|
657
|
+
- Experiment with different configuration options
|
|
658
|
+
- Try deploying to a production Kubernetes cluster
|