Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
373ec05e2c | |||
9de86bd382 | |||
bec47150a3 | |||
6d818b4b36 | |||
21903acbbe | |||
4b7bf5fde4 | |||
51903eff5b | |||
d812e21b50 |
71
.gitea/workflows/docker_nottags.yaml
Normal file
71
.gitea/workflows/docker_nottags.yaml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
name: Docker (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_LOGIN_DOCKER_GITEA: ${{ github.server_url }}|${{ gitea.repository_owner }}|${{ secrets.GITEA_TOKEN }}
|
||||||
|
NPMCI_LOGIN_DOCKER_DOCKERREGISTRY: ${{ secrets.NPMCI_LOGIN_DOCKER_DOCKERREGISTRY }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci npm prepare
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci command npm run build
|
106
.gitea/workflows/docker_tags.yaml
Normal file
106
.gitea/workflows/docker_tags.yaml
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
name: Docker (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_LOGIN_DOCKER_GITEA: ${{ github.server_url }}|${{ gitea.repository_owner }}|${{ secrets.GITEA_TOKEN }}
|
||||||
|
NPMCI_LOGIN_DOCKER_DOCKERREGISTRY: ${{ secrets.NPMCI_LOGIN_DOCKER_DOCKERREGISTRY }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci command npm run build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: code.foss.global/hosttoday/ht-docker-dbase:npmci
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci docker login
|
||||||
|
npmci docker build
|
||||||
|
npmci docker test
|
||||||
|
# npmci docker push
|
||||||
|
npmci docker push
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,6 @@
|
|||||||
# artifacts
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
|
||||||
|
|
||||||
# installs
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
@ -17,4 +16,4 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
dist_*/
|
dist_*/
|
||||||
|
|
||||||
# custom
|
#------# custom
|
10
Dockerfile
10
Dockerfile
@ -1,6 +1,6 @@
|
|||||||
# gitzone dockerfile_service
|
# gitzone dockerfile_service
|
||||||
## STAGE 1 // BUILD
|
## STAGE 1 // BUILD
|
||||||
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node1
|
FROM code.foss.global/host.today/ht-docker-node:npmci as node1
|
||||||
COPY ./ /app
|
COPY ./ /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG NPMCI_TOKEN_NPM2
|
ARG NPMCI_TOKEN_NPM2
|
||||||
@ -12,7 +12,7 @@ RUN pnpm run build
|
|||||||
|
|
||||||
# gitzone dockerfile_service
|
# gitzone dockerfile_service
|
||||||
## STAGE 2 // install production
|
## STAGE 2 // install production
|
||||||
FROM registry.gitlab.com/hosttoday/ht-docker-node:npmci as node2
|
FROM code.foss.global/host.today/ht-docker-node:npmci as node2
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=node1 /app /app
|
COPY --from=node1 /app /app
|
||||||
RUN rm -rf .pnpm-store
|
RUN rm -rf .pnpm-store
|
||||||
@ -24,7 +24,7 @@ RUN rm -rf node_modules/ && pnpm install --prod
|
|||||||
|
|
||||||
|
|
||||||
## STAGE 3 // rebuild dependencies for alpine
|
## STAGE 3 // rebuild dependencies for alpine
|
||||||
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpinenpmci as node3
|
FROM code.foss.global/host.today/ht-docker-node:alpinenpmci as node3
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=node2 /app /app
|
COPY --from=node2 /app /app
|
||||||
ARG NPMCI_TOKEN_NPM2
|
ARG NPMCI_TOKEN_NPM2
|
||||||
@ -34,12 +34,12 @@ RUN pnpm config set store-dir .pnpm-store
|
|||||||
RUN pnpm rebuild -r
|
RUN pnpm rebuild -r
|
||||||
|
|
||||||
## STAGE 4 // the final production image with all dependencies in place
|
## STAGE 4 // the final production image with all dependencies in place
|
||||||
FROM registry.gitlab.com/hosttoday/ht-docker-node:alpine as node4
|
FROM code.foss.global/host.today/ht-docker-node:alpine as node4
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=node3 /app /app
|
COPY --from=node3 /app /app
|
||||||
|
|
||||||
### Healthchecks
|
### Healthchecks
|
||||||
RUN pnpm install -g @serve.zone/healthy
|
RUN pnpm install -g @servezone/healthy
|
||||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD [ "healthy" ]
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 CMD [ "healthy" ]
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
36
changelog.md
Normal file
36
changelog.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-12-29 - 1.1.0 - feat(.gitea/workflows)
|
||||||
|
Add GitHub Actions workflows for Docker build and test
|
||||||
|
|
||||||
|
- Added .gitea/workflows/docker_nottags.yaml for handling Docker builds on non-tagged commits.
|
||||||
|
- Added .gitea/workflows/docker_tags.yaml for handling Docker builds on tagged commits.
|
||||||
|
- Both workflows include steps for security audits, testing, and build preparation.
|
||||||
|
|
||||||
|
## 2024-12-29 - 1.0.135 - fix(core)
|
||||||
|
Fix image retrieval and service deployment process for workload services
|
||||||
|
|
||||||
|
- Updated the handling of internal and external registry images when provisioning workload services.
|
||||||
|
- Refined the image pulling logic to accommodate both internal and external sources.
|
||||||
|
- Ensured proper secret management during service deployment.
|
||||||
|
- Corrected and optimized key function parameters and API calls for clarity and functionality.
|
||||||
|
|
||||||
|
## 2024-12-20 - 1.0.134 - fix(core)
|
||||||
|
Updated dependencies and refactored ClusterManager and CloudlyConnector for improved Docker management.
|
||||||
|
|
||||||
|
- Updated `@push.rocks/tswatch` and `@push.rocks/tapbundle` to latest versions in devDependencies.
|
||||||
|
- Refactored `ClusterManager` to remove unused subscriptions and improve network and service management.
|
||||||
|
- Refactored `CloudlyConnector` to use `CloudlyApiClient` for improved cloud configuration management.
|
||||||
|
- Added logging for network and Docker service configurations.
|
||||||
|
|
||||||
|
## 2024-11-18 - 1.0.133 - fix(dockerfile)
|
||||||
|
Update Docker base images to use code.foss.global instead of registry.gitlab.com
|
||||||
|
|
||||||
|
- Updated Docker base images to use `code.foss.global` instead of `registry.gitlab.com`.
|
||||||
|
- Changed the global installation path for `@serve.zone/healthy` to `@servezone/healthy` in Dockerfile.
|
||||||
|
- Adjusted logging system from `lole-log` to `smartlog` for enhanced log context output.
|
||||||
|
|
||||||
|
## 2024-05-09 - 1.0.130 to 1.0.132 - Maintenance Release
|
||||||
|
Regular updates and maintenance tasks.
|
||||||
|
|
||||||
|
- Fixed core functionality issues in versions 1.0.130 and 1.0.131.
|
@ -13,12 +13,12 @@
|
|||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "service",
|
"projectType": "service",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "losslessone/services/servezone",
|
"gitscope": "serve.zone",
|
||||||
"gitrepo": "coreflow",
|
"gitrepo": "coreflow",
|
||||||
"description": "A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.",
|
"description": "A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.",
|
||||||
"npmPackagename": "@serve.zone/coreflow",
|
"npmPackagename": "@serve.zone/coreflow",
|
||||||
"license": "UNLICENSED",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Docker",
|
"Docker",
|
||||||
"Service scaling",
|
"Service scaling",
|
||||||
@ -31,13 +31,19 @@
|
|||||||
"Web services",
|
"Web services",
|
||||||
"Container management",
|
"Container management",
|
||||||
"Cluster configuration",
|
"Cluster configuration",
|
||||||
"DevOps tools",
|
"DevOps",
|
||||||
"Cloud services integration",
|
"Cloud integration",
|
||||||
"Security management",
|
"Security",
|
||||||
"High availability services",
|
"High availability",
|
||||||
"Multi-cloud orchestration",
|
"Multi-cloud",
|
||||||
"Service discovery",
|
"Service discovery",
|
||||||
"Distributed systems"
|
"Distributed systems",
|
||||||
|
"Docker Swarm",
|
||||||
|
"Traffic management",
|
||||||
|
"Service provisioning",
|
||||||
|
"Monitoring",
|
||||||
|
"Observability",
|
||||||
|
"TypeScript"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
64
package.json
64
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/coreflow",
|
"name": "@serve.zone/coreflow",
|
||||||
"version": "1.0.132",
|
"version": "1.1.0",
|
||||||
"description": "A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.",
|
"description": "A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@ -9,6 +9,7 @@
|
|||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"start": "(node --max_old_space_size=500 ./cli.js)",
|
"start": "(node --max_old_space_size=500 ./cli.js)",
|
||||||
"startTs": "(node cli.ts.js)",
|
"startTs": "(node cli.ts.js)",
|
||||||
|
"watch": "(tswatch service)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
@ -17,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://gitlab.com/pushrocks/coreflow.git"
|
"url": "https://code.foss.global/serve.zone/coreflow.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Docker",
|
"Docker",
|
||||||
@ -31,50 +32,57 @@
|
|||||||
"Web services",
|
"Web services",
|
||||||
"Container management",
|
"Container management",
|
||||||
"Cluster configuration",
|
"Cluster configuration",
|
||||||
"DevOps tools",
|
"DevOps",
|
||||||
"Cloud services integration",
|
"Cloud integration",
|
||||||
"Security management",
|
"Security",
|
||||||
"High availability services",
|
"High availability",
|
||||||
"Multi-cloud orchestration",
|
"Multi-cloud",
|
||||||
"Service discovery",
|
"Service discovery",
|
||||||
"Distributed systems"
|
"Distributed systems",
|
||||||
|
"Docker Swarm",
|
||||||
|
"Traffic management",
|
||||||
|
"Service provisioning",
|
||||||
|
"Monitoring",
|
||||||
|
"Observability",
|
||||||
|
"TypeScript"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/coreflow/issues"
|
"url": "https://gitlab.com/losslessone/services/servezone/coreflow/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/coreflow#readme",
|
"homepage": "https://gitlab.com/losslessone/services/servezone/coreflow#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^2.2.0",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@git.zone/tstest": "^1.0.90",
|
"@git.zone/tstest": "^1.0.90",
|
||||||
"@git.zone/tswatch": "^2.0.7",
|
"@git.zone/tswatch": "^2.0.37",
|
||||||
"@push.rocks/tapbundle": "^5.0.23"
|
"@push.rocks/tapbundle": "^5.5.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@api.global/typedrequest": "^3.0.23",
|
"@api.global/typedrequest": "^3.1.10",
|
||||||
"@api.global/typedsocket": "^3.0.1",
|
"@api.global/typedsocket": "^3.0.1",
|
||||||
"@apiclient.xyz/docker": "^1.0.112",
|
"@apiclient.xyz/docker": "^1.3.0",
|
||||||
"@push.rocks/early": "^4.0.3",
|
"@push.rocks/early": "^4.0.3",
|
||||||
"@push.rocks/lik": "^6.0.15",
|
"@push.rocks/lik": "^6.1.0",
|
||||||
"@push.rocks/projectinfo": "^5.0.1",
|
"@push.rocks/projectinfo": "^5.0.1",
|
||||||
"@push.rocks/qenv": "^6.0.5",
|
"@push.rocks/qenv": "^6.1.0",
|
||||||
"@push.rocks/smartcli": "^4.0.10",
|
"@push.rocks/smartcli": "^4.0.11",
|
||||||
"@push.rocks/smartdelay": "^3.0.1",
|
"@push.rocks/smartdelay": "^3.0.1",
|
||||||
"@push.rocks/smartlog": "^3.0.2",
|
"@push.rocks/smartlog": "^3.0.7",
|
||||||
"@push.rocks/smartnetwork": "3.0.2",
|
"@push.rocks/smartnetwork": "3.0.2",
|
||||||
"@push.rocks/smartpath": "^5.0.18",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.2",
|
"@push.rocks/smartpromise": "^4.0.4",
|
||||||
"@push.rocks/smartrequest": "^2.0.22",
|
"@push.rocks/smartrequest": "^2.0.23",
|
||||||
"@push.rocks/smartrx": "^3.0.2",
|
"@push.rocks/smartrx": "^3.0.2",
|
||||||
"@push.rocks/smartstate": "^2.0.6",
|
"@push.rocks/smartstate": "^2.0.19",
|
||||||
|
"@push.rocks/smartstream": "^3.2.5",
|
||||||
"@push.rocks/smartstring": "^4.0.15",
|
"@push.rocks/smartstring": "^4.0.15",
|
||||||
"@push.rocks/taskbuffer": "^3.0.10",
|
"@push.rocks/taskbuffer": "^3.0.10",
|
||||||
"@serve.zone/api": "^2.0.28",
|
"@serve.zone/api": "^4.10.0",
|
||||||
"@serve.zone/interfaces": "^1.0.51",
|
"@serve.zone/interfaces": "^4.10.0",
|
||||||
"@tsclass/tsclass": "^4.0.54",
|
"@tsclass/tsclass": "^4.2.0",
|
||||||
"@types/node": "20.12.11"
|
"@types/node": "22.10.2"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"files": [
|
"files": [
|
||||||
|
11124
pnpm-lock.yaml
generated
11124
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
256
readme.md
256
readme.md
@ -1,21 +1,28 @@
|
|||||||
# @serve.zone/coreflow
|
# @serve.zone/coreflow
|
||||||
|
|
||||||
A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.
|
A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
To install @serve.zone/coreflow, you can use npm with the following command:
|
To install @serve.zone/coreflow, you can use npm with the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install @serve.zone/coreflow --save
|
npm install @serve.zone/coreflow --save
|
||||||
```
|
```
|
||||||
|
|
||||||
Given that this is a private package, make sure you have access to the required npm registry and that you are authenticated properly.
|
Given that this is a private package, make sure you have access to the required npm registry and that you are authenticated properly.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Coreflow is designed as an advanced tool for managing Docker-based applications and services, enabling efficient scaling across servers, and handling multiple aspects of service provisioning and network traffic management. Below are examples and explanations to illustrate its capabilities and how you can leverage Coreflow in your infrastructure. Note that these examples are based on TypeScript and use ESM syntax.
|
Coreflow is designed as an advanced tool for managing Docker-based applications and services, enabling efficient scaling across servers, and handling multiple aspects of service provisioning and network traffic management. Below are examples and explanations to illustrate its capabilities and how you can leverage Coreflow in your infrastructure. Note that these examples are based on TypeScript and use ESM syntax.
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
Before you start, ensure you have Docker and Docker Swarm configured in your environment as Coreflow operates on top of these technologies. Additionally, verify that your environment variables are properly set up for accessing Coreflow's functionalities.
|
Before you start, ensure you have Docker and Docker Swarm configured in your environment as Coreflow operates on top of these technologies. Additionally, verify that your environment variables are properly set up for accessing Coreflow's functionalities.
|
||||||
|
|
||||||
### Setting Up Coreflow
|
### Setting Up Coreflow
|
||||||
To get started, you need to import and initialize coreflow within your application. Here's an example of how to do this in a TypeScript module:
|
|
||||||
|
To get started, you need to import and initialize Coreflow within your application. Here's an example of how to do this in a TypeScript module:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { Coreflow } from '@serve.zone/coreflow';
|
import { Coreflow } from '@serve.zone/coreflow';
|
||||||
@ -35,14 +42,22 @@ coreflowInstance.handleDockerEvents().then(() => {
|
|||||||
await coreflowInstance.stop();
|
await coreflowInstance.stop();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In the above example:
|
||||||
|
|
||||||
|
- The Coreflow instance is initialized.
|
||||||
|
- Coreflow is started, which internally initializes various managers and connectors.
|
||||||
|
- The method `handleDockerEvents` is used to handle Docker events.
|
||||||
|
- Finally, Coreflow is stopped gracefully.
|
||||||
|
|
||||||
### Configuring Service Connections
|
### Configuring Service Connections
|
||||||
|
|
||||||
Coreflow manages applications and services, often requiring direct interactions with other services like a database, message broker, or external API. Coreflow simplifies these connections through its configuration and service discovery layers.
|
Coreflow manages applications and services, often requiring direct interactions with other services like a database, message broker, or external API. Coreflow simplifies these connections through its configuration and service discovery layers.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Assuming coreflowInstance is already started as per previous examples
|
// Assuming coreflowInstance is already started as per previous examples
|
||||||
const serviceConnection = coreflowInstance.createServiceConnection({
|
const serviceConnection = coreflowInstance.createServiceConnection({
|
||||||
serviceName: "myDatabaseService",
|
serviceName: 'myDatabaseService',
|
||||||
servicePort: 3306
|
servicePort: 3306,
|
||||||
});
|
});
|
||||||
|
|
||||||
serviceConnection.connect().then(() => {
|
serviceConnection.connect().then(() => {
|
||||||
@ -51,11 +66,12 @@ serviceConnection.connect().then(() => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Scaling Your Application
|
### Scaling Your Application
|
||||||
|
|
||||||
Coreflow excels in scaling applications across multiple servers. This involves not just replicating services, but also ensuring they are properly networked, balanced, and monitored.
|
Coreflow excels in scaling applications across multiple servers. This involves not just replicating services, but also ensuring they are properly networked, balanced, and monitored.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const scalingPolicy = {
|
const scalingPolicy = {
|
||||||
serviceName: "apiService",
|
serviceName: 'apiService',
|
||||||
replicaCount: 5, // Target number of replicas
|
replicaCount: 5, // Target number of replicas
|
||||||
maxReplicaCount: 10, // Maximum number of replicas
|
maxReplicaCount: 10, // Maximum number of replicas
|
||||||
minReplicaCount: 2, // Minimum number of replicas
|
minReplicaCount: 2, // Minimum number of replicas
|
||||||
@ -66,17 +82,23 @@ coreflowInstance.applyScalingPolicy(scalingPolicy).then(() => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In the above example:
|
||||||
|
|
||||||
|
- A scaling policy is defined with target, maximum, and minimum replica counts for the `apiService`.
|
||||||
|
- The `applyScalingPolicy` method of the Coreflow instance is used to apply this scaling policy.
|
||||||
|
|
||||||
### Managing Network Traffic
|
### Managing Network Traffic
|
||||||
|
|
||||||
One of Coreflow's key features is its ability to manage network traffic, ensuring that it is efficiently distributed among various services based on load, priority, and other custom rules.
|
One of Coreflow's key features is its ability to manage network traffic, ensuring that it is efficiently distributed among various services based on load, priority, and other custom rules.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { TrafficRule } from '@serve.zone/coreflow';
|
import { TrafficRule } from '@serve.zone/coreflow';
|
||||||
|
|
||||||
const rule: TrafficRule = {
|
const rule: TrafficRule = {
|
||||||
serviceName: "webService",
|
serviceName: 'webService',
|
||||||
externalPort: 80,
|
externalPort: 80,
|
||||||
internalPort: 3000,
|
internalPort: 3000,
|
||||||
protocol: "http",
|
protocol: 'http',
|
||||||
};
|
};
|
||||||
|
|
||||||
coreflowInstance.applyTrafficRule(rule).then(() => {
|
coreflowInstance.applyTrafficRule(rule).then(() => {
|
||||||
@ -84,14 +106,20 @@ coreflowInstance.applyTrafficRule(rule).then(() => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In the above example:
|
||||||
|
|
||||||
|
- A traffic rule is defined for the `webService`, redirecting external traffic from port 80 to the service's internal port 3000.
|
||||||
|
- The `applyTrafficRule` method is used to enforce this rule.
|
||||||
|
|
||||||
### Continuous Deployment
|
### Continuous Deployment
|
||||||
|
|
||||||
Coreflow integrates continuous integration and deployment processes, allowing seamless updates and rollbacks for your services:
|
Coreflow integrates continuous integration and deployment processes, allowing seamless updates and rollbacks for your services:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const deploymentConfig = {
|
const deploymentConfig = {
|
||||||
serviceName: "userAuthService",
|
serviceName: 'userAuthService',
|
||||||
image: "myregistry.com/userauthservice:latest",
|
image: 'myregistry.com/userauthservice:latest',
|
||||||
updatePolicy: "rolling" // or "recreate"
|
updatePolicy: 'rolling', // or "recreate"
|
||||||
};
|
};
|
||||||
|
|
||||||
coreflowInstance.deployService(deploymentConfig).then(() => {
|
coreflowInstance.deployService(deploymentConfig).then(() => {
|
||||||
@ -99,14 +127,218 @@ coreflowInstance.deployService(deploymentConfig).then(() => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In the above example:
|
||||||
|
|
||||||
|
- A deployment configuration is created for the `userAuthService` using the latest image from the specified registry.
|
||||||
|
- The `deployService` method is then used to deploy the service using the specified update policy (e.g., rolling updates or recreating the service).
|
||||||
|
|
||||||
### Observability and Monitoring
|
### Observability and Monitoring
|
||||||
To keep track of your applications' health and performances, Coreflow provides tools for logging, monitoring, and alerting.
|
|
||||||
|
To keep track of your applications' health and performance, Coreflow provides tools for logging, monitoring, and alerting.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
coreflowInstance.monitorService("webService").on('serviceHealthUpdate', (healthStatus) => {
|
coreflowInstance.monitorService('webService').on('serviceHealthUpdate', (healthStatus) => {
|
||||||
console.log(`Received health update for webService: ${healthStatus}`);
|
console.log(`Received health update for webService: ${healthStatus}`);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
By following these examples, you can utilize Coreflow to manage Docker-based applications, ensuring scalability, reliability, and efficiency across your infrastructure.
|
In the above example:
|
||||||
|
|
||||||
|
- The `monitorService` method is used to monitor the health status of the `webService`.
|
||||||
|
- When a health update event is received, it is logged to the console.
|
||||||
|
|
||||||
|
### Detailed Example: Setting Up and Managing Coreflow
|
||||||
|
|
||||||
|
Here is a detailed example that covers various features, from setup to scaling and traffic management.
|
||||||
|
|
||||||
|
#### Step 1: Initialize Coreflow
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Coreflow } from '@serve.zone/coreflow';
|
||||||
|
|
||||||
|
const coreflowInstance = new Coreflow();
|
||||||
|
|
||||||
|
async function initializeCoreflow() {
|
||||||
|
await coreflowInstance.start();
|
||||||
|
console.log('Coreflow initialized.');
|
||||||
|
await manageServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeCoreflow().catch((error) => {
|
||||||
|
console.error('Error initializing Coreflow:', error);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 2: Handling Docker Events
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
coreflowInstance.handleDockerEvents().then(() => {
|
||||||
|
console.log('Docker events are being handled.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 3: Configuring and Connecting to a Service
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const serviceConnection = coreflowInstance.createServiceConnection({
|
||||||
|
serviceName: 'databaseService',
|
||||||
|
servicePort: 5432,
|
||||||
|
});
|
||||||
|
|
||||||
|
serviceConnection.connect().then(() => {
|
||||||
|
console.log('Successfully connected to the database service.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 4: Applying a Scaling Policy
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const scalingPolicy = {
|
||||||
|
serviceName: 'microserviceA',
|
||||||
|
replicaCount: 3, // Starting with 3 replicas
|
||||||
|
maxReplicaCount: 10, // Allowing up to 10 replicas
|
||||||
|
minReplicaCount: 2, // Ensuring at least 2 replicas
|
||||||
|
};
|
||||||
|
|
||||||
|
coreflowInstance.applyScalingPolicy(scalingPolicy).then(() => {
|
||||||
|
console.log('Scaling policy applied for microserviceA');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 5: Managing Network Traffic
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { TrafficRule } from '@serve.zone/coreflow';
|
||||||
|
|
||||||
|
const trafficRules: TrafficRule[] = [
|
||||||
|
{
|
||||||
|
serviceName: 'frontendService',
|
||||||
|
externalPort: 80,
|
||||||
|
internalPort: 3000,
|
||||||
|
protocol: 'http',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
serviceName: 'apiService',
|
||||||
|
externalPort: 443,
|
||||||
|
internalPort: 4000,
|
||||||
|
protocol: 'https',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
Promise.all(trafficRules.map((rule) => coreflowInstance.applyTrafficRule(rule))).then(() => {
|
||||||
|
console.log('Traffic rules applied.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 6: Deploying a Service
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const deploymentConfig = {
|
||||||
|
serviceName: 'authService',
|
||||||
|
image: 'myregistry.com/authservice:latest',
|
||||||
|
updatePolicy: 'rolling', // Performing rolling updates
|
||||||
|
};
|
||||||
|
|
||||||
|
coreflowInstance.deployService(deploymentConfig).then(() => {
|
||||||
|
console.log('AuthService deployed successfully.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 7: Monitoring a Service
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
coreflowInstance.monitorService('frontendService').on('serviceHealthUpdate', (healthStatus) => {
|
||||||
|
console.log(`Health update for frontendService: ${healthStatus}`);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Usage: Task Scheduling and Traffic Configuration
|
||||||
|
|
||||||
|
In more complex scenarios, you might want to leverage Coreflow's ability to schedule tasks and manage traffic configurations.
|
||||||
|
|
||||||
|
#### Scheduling Tasks
|
||||||
|
|
||||||
|
Coreflow supports scheduling updates and other tasks using the `taskBuffer` API.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Task } from '@push.rocks/taskbuffer';
|
||||||
|
|
||||||
|
const checkinTask = new Task({
|
||||||
|
name: 'checkin',
|
||||||
|
buffered: true,
|
||||||
|
taskFunction: async () => {
|
||||||
|
console.log('Running checkin task...');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const taskManager = coreflowInstance.taskManager;
|
||||||
|
taskManager.addAndScheduleTask(checkinTask, '0 * * * * *'); // Scheduling task to run every minute
|
||||||
|
taskManager.start().then(() => {
|
||||||
|
console.log('Task manager started.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Managing Traffic Routing
|
||||||
|
|
||||||
|
Coreflow can manage complex traffic routing scenarios, such as configuring reverse proxies for different services.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { CoretrafficConnector } from '@serve.zone/coreflow';
|
||||||
|
|
||||||
|
// Assume coreflowInstance is already started
|
||||||
|
const coretrafficConnector = new CoretrafficConnector(coreflowInstance);
|
||||||
|
|
||||||
|
const reverseProxyConfigs = [
|
||||||
|
{
|
||||||
|
hostName: 'example.com',
|
||||||
|
destinationIp: '192.168.1.100',
|
||||||
|
destinationPort: '3000',
|
||||||
|
privateKey: '<your-private-key>',
|
||||||
|
publicKey: '<your-public-key>',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hostName: 'api.example.com',
|
||||||
|
destinationIp: '192.168.1.101',
|
||||||
|
destinationPort: '4000',
|
||||||
|
privateKey: '<your-private-key>',
|
||||||
|
publicKey: '<your-public-key>',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
coretrafficConnector.setReverseConfigs(reverseProxyConfigs).then(() => {
|
||||||
|
console.log('Reverse proxy configurations applied.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Integrating with Cloudly
|
||||||
|
|
||||||
|
Coreflow is designed to integrate seamlessly with Cloudly, a configuration management and orchestration tool.
|
||||||
|
|
||||||
|
#### Starting the Cloudly Connector
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const cloudlyConnector = coreflowInstance.cloudlyConnector;
|
||||||
|
|
||||||
|
cloudlyConnector.start().then(() => {
|
||||||
|
console.log('Cloudly connector started.');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Retrieving and Applying Configurations from Cloudly
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
cloudlyConnector.getConfigFromCloudly().then((config) => {
|
||||||
|
console.log('Received configuration from Cloudly:', config);
|
||||||
|
|
||||||
|
coreflowInstance.clusterManager.provisionWorkloadServices(config).then(() => {
|
||||||
|
console.log('Workload services provisioned based on Cloudly config.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
Coreflow is a powerful and flexible tool for managing Docker-based applications, scaling services, configuring network traffic, handling continuous deployments, and ensuring observability of your infrastructure. The examples provided aim to give a comprehensive understanding of how to use Coreflow in various scenarios, ensuring it meets your DevOps and CI/CD needs.
|
||||||
|
|
||||||
|
By leveraging Coreflow's rich feature set, you can optimize your infrastructure for high availability, scalability, and efficient operation across multiple servers and environments.
|
||||||
undefined
|
undefined
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/coreflow',
|
name: '@serve.zone/coreflow',
|
||||||
version: '1.0.132',
|
version: '1.1.0',
|
||||||
description: 'A comprehensive solution for managing Docker and scaling applications across servers, handling tasks from service provisioning to network traffic management.'
|
description: 'A comprehensive tool for managing Docker-based applications and services, enabling efficient scaling, network management, and integration with cloud services.'
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import { Coreflow } from './coreflow.classes.coreflow.js';
|
|||||||
|
|
||||||
export class ClusterManager {
|
export class ClusterManager {
|
||||||
public coreflowRef: Coreflow;
|
public coreflowRef: Coreflow;
|
||||||
public dockerHost: plugins.docker.DockerHost;
|
|
||||||
public configSubscription: plugins.smartrx.rxjs.Subscription;
|
public configSubscription: plugins.smartrx.rxjs.Subscription;
|
||||||
public containerSubscription: plugins.smartrx.rxjs.Subscription;
|
public containerSubscription: plugins.smartrx.rxjs.Subscription;
|
||||||
public containerVersionSubscription: plugins.smartrx.rxjs.Subscription;
|
public containerVersionSubscription: plugins.smartrx.rxjs.Subscription;
|
||||||
@ -20,7 +19,6 @@ export class ClusterManager {
|
|||||||
|
|
||||||
constructor(coreflowRefArg: Coreflow) {
|
constructor(coreflowRefArg: Coreflow) {
|
||||||
this.coreflowRef = coreflowRefArg;
|
this.coreflowRef = coreflowRefArg;
|
||||||
this.dockerHost = new plugins.docker.DockerHost();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,31 +26,15 @@ export class ClusterManager {
|
|||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
const config = await this.coreflowRef.cloudlyConnector.getConfigFromCloudly();
|
const config = await this.coreflowRef.cloudlyConnector.getConfigFromCloudly();
|
||||||
await this.setDockerAuth(config);
|
|
||||||
this.readyDeferred.resolve();
|
this.readyDeferred.resolve();
|
||||||
|
|
||||||
// subscriptions
|
// subscriptions
|
||||||
|
// this subscription is the start point for most updates on the cluster
|
||||||
this.configSubscription =
|
this.configSubscription =
|
||||||
this.coreflowRef.cloudlyConnector.cloudlyClient.configUpdateSubject.subscribe(
|
this.coreflowRef.cloudlyConnector.cloudlyApiClient.configUpdateSubject.subscribe(
|
||||||
async (dataArg) => {
|
|
||||||
await this.setDockerAuth(dataArg.configData);
|
|
||||||
this.coreflowRef.taskManager.updateBaseServicesTask.trigger();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.containerSubscription =
|
|
||||||
this.coreflowRef.cloudlyConnector.cloudlyClient.containerUpdateSubject.subscribe(
|
|
||||||
async (dataArg) => {
|
async (dataArg) => {
|
||||||
this.coreflowRef.taskManager.updateBaseServicesTask.trigger();
|
this.coreflowRef.taskManager.updateBaseServicesTask.trigger();
|
||||||
}
|
},
|
||||||
);
|
|
||||||
this.containerVersionSubscription =
|
|
||||||
this.coreflowRef.cloudlyConnector.cloudlyClient.containerVersionUpdateSubject.subscribe(
|
|
||||||
async (dataArg) => {
|
|
||||||
console.log(
|
|
||||||
`Got a container version update trigger for ${dataArg.dockerImageUrl}@${dataArg.dockerImageVersion}`
|
|
||||||
);
|
|
||||||
this.coreflowRef.taskManager.updateBaseServicesTask.trigger();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,39 +45,48 @@ export class ClusterManager {
|
|||||||
this.configSubscription ? this.configSubscription.unsubscribe() : null;
|
this.configSubscription ? this.configSubscription.unsubscribe() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setDockerAuth(configArg: plugins.servezoneInterfaces.data.IClusterConfig) {
|
|
||||||
await this.dockerHost.auth(configArg.data.registryInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* provisions base services
|
* provisions base services
|
||||||
*/
|
*/
|
||||||
public async provisionBaseServices() {
|
public async provisionBaseServices() {
|
||||||
// swarm should be enabled by lower level serverconfig package
|
// swarm should be enabled by lower level serverconfig package
|
||||||
// get current situation
|
// get current situation
|
||||||
const networks = await this.dockerHost.getNetworks();
|
const networks = await this.coreflowRef.dockerHost.getNetworks();
|
||||||
|
logger.log('info', 'There are currently ' + networks.length + ' networks');
|
||||||
|
for (const network of networks) {
|
||||||
|
logger.log('info', 'Network: ' + network.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure there is a network for the webgateway
|
||||||
let sznWebgatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
let sznWebgatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
this.commonDockerData.networkNames.sznWebgateway
|
this.commonDockerData.networkNames.sznWebgateway,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!sznWebgatewayNetwork) {
|
if (!sznWebgatewayNetwork) {
|
||||||
sznWebgatewayNetwork = await plugins.docker.DockerNetwork.createNetwork(this.dockerHost, {
|
logger.log('info', 'Creating network: ' + this.commonDockerData.networkNames.sznWebgateway);
|
||||||
Name: this.commonDockerData.networkNames.sznWebgateway,
|
sznWebgatewayNetwork = await plugins.docker.DockerNetwork.createNetwork(
|
||||||
});
|
this.coreflowRef.dockerHost,
|
||||||
|
{
|
||||||
|
Name: this.commonDockerData.networkNames.sznWebgateway,
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.log('ok', 'sznWebgateway is already present');
|
logger.log('ok', 'sznWebgateway is already present');
|
||||||
}
|
}
|
||||||
|
|
||||||
// corechat network
|
// corechat network so base services can talk to each other
|
||||||
let sznCorechatNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
let sznCorechatNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
this.commonDockerData.networkNames.sznCorechat
|
this.commonDockerData.networkNames.sznCorechat,
|
||||||
);
|
);
|
||||||
if (!sznCorechatNetwork) {
|
if (!sznCorechatNetwork) {
|
||||||
sznCorechatNetwork = await plugins.docker.DockerNetwork.createNetwork(this.dockerHost, {
|
sznCorechatNetwork = await plugins.docker.DockerNetwork.createNetwork(
|
||||||
Name: this.commonDockerData.networkNames.sznCorechat,
|
this.coreflowRef.dockerHost,
|
||||||
});
|
{
|
||||||
|
Name: this.commonDockerData.networkNames.sznCorechat,
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.log('ok', 'sznCorechat is already present');
|
logger.log('ok', 'sznCorechat is already present');
|
||||||
}
|
}
|
||||||
@ -108,21 +99,31 @@ export class ClusterManager {
|
|||||||
// Images
|
// Images
|
||||||
logger.log('info', `now updating docker images of base services...`);
|
logger.log('info', `now updating docker images of base services...`);
|
||||||
|
|
||||||
const coretrafficImage = await plugins.docker.DockerImage.createFromRegistry(this.dockerHost, {
|
const coretrafficImage = await plugins.docker.DockerImage.createFromRegistry(
|
||||||
imageUrl: 'registry.gitlab.com/losslessone/services/servezone/coretraffic',
|
this.coreflowRef.dockerHost,
|
||||||
});
|
{
|
||||||
|
creationObject: {
|
||||||
|
imageUrl: 'code.foss.global/serve.zone/coretraffic',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const corelogImage = await plugins.docker.DockerImage.createFromRegistry(this.dockerHost, {
|
const corelogImage = await plugins.docker.DockerImage.createFromRegistry(
|
||||||
imageUrl: 'registry.gitlab.com/losslessone/services/servezone/corelog',
|
this.coreflowRef.dockerHost,
|
||||||
});
|
{
|
||||||
|
creationObject: {
|
||||||
|
imageUrl: 'code.foss.global/serve.zone/corelog',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// SERVICES
|
// SERVICES
|
||||||
// lets deploy the base services
|
// lets deploy the base services
|
||||||
// coretraffic
|
// coretraffic
|
||||||
let coretrafficService: plugins.docker.DockerService;
|
let coretrafficService: plugins.docker.DockerService;
|
||||||
coretrafficService = await plugins.docker.DockerService.getServiceByName(
|
coretrafficService = await plugins.docker.DockerService.getServiceByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
'coretraffic'
|
'coretraffic',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (coretrafficService && (await coretrafficService.needsUpdate())) {
|
if (coretrafficService && (await coretrafficService.needsUpdate())) {
|
||||||
@ -134,19 +135,22 @@ export class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!coretrafficService) {
|
if (!coretrafficService) {
|
||||||
coretrafficService = await plugins.docker.DockerService.createService(this.dockerHost, {
|
coretrafficService = await plugins.docker.DockerService.createService(
|
||||||
image: coretrafficImage,
|
this.coreflowRef.dockerHost,
|
||||||
labels: {},
|
{
|
||||||
name: 'coretraffic',
|
image: coretrafficImage,
|
||||||
networks: [sznCorechatNetwork, sznWebgatewayNetwork],
|
labels: {},
|
||||||
networkAlias: 'coretraffic',
|
name: 'coretraffic',
|
||||||
ports: ['80:7999', '443:8000'],
|
networks: [sznCorechatNetwork, sznWebgatewayNetwork],
|
||||||
secrets: [],
|
networkAlias: 'coretraffic',
|
||||||
resources: {
|
ports: ['80:7999', '443:8000'],
|
||||||
memorySizeMB: 1100,
|
secrets: [],
|
||||||
volumeMounts: [],
|
resources: {
|
||||||
|
memorySizeMB: 1100,
|
||||||
|
volumeMounts: [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.log('ok', 'coretraffic service is already present');
|
logger.log('ok', 'coretraffic service is already present');
|
||||||
}
|
}
|
||||||
@ -156,8 +160,8 @@ export class ClusterManager {
|
|||||||
// corelog
|
// corelog
|
||||||
let corelogService: plugins.docker.DockerService;
|
let corelogService: plugins.docker.DockerService;
|
||||||
corelogService = await plugins.docker.DockerService.getServiceByName(
|
corelogService = await plugins.docker.DockerService.getServiceByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
'corelog'
|
'corelog',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (corelogService && (await corelogService.needsUpdate())) {
|
if (corelogService && (await corelogService.needsUpdate())) {
|
||||||
@ -168,19 +172,22 @@ export class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!corelogService) {
|
if (!corelogService) {
|
||||||
corelogService = await plugins.docker.DockerService.createService(this.dockerHost, {
|
corelogService = await plugins.docker.DockerService.createService(
|
||||||
image: corelogImage,
|
this.coreflowRef.dockerHost,
|
||||||
labels: {},
|
{
|
||||||
name: 'corelog',
|
image: corelogImage,
|
||||||
networks: [sznCorechatNetwork],
|
labels: {},
|
||||||
networkAlias: 'corelog',
|
name: 'corelog',
|
||||||
ports: [],
|
networks: [sznCorechatNetwork],
|
||||||
secrets: [],
|
networkAlias: 'corelog',
|
||||||
resources: {
|
ports: [],
|
||||||
memorySizeMB: 120,
|
secrets: [],
|
||||||
volumeMounts: [],
|
resources: {
|
||||||
|
memorySizeMB: 120,
|
||||||
|
volumeMounts: [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.log('ok', 'corelog service is already present');
|
logger.log('ok', 'corelog service is already present');
|
||||||
}
|
}
|
||||||
@ -188,37 +195,86 @@ export class ClusterManager {
|
|||||||
await plugins.smartdelay.delayFor(10000);
|
await plugins.smartdelay.delayFor(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public async provisionWorkloadService(
|
||||||
* provision services obtained from cloudly
|
serviceArgFromCloudly: plugins.servezoneInterfaces.data.IService,
|
||||||
*/
|
|
||||||
public async provisionWorkloadServices(configData: plugins.servezoneInterfaces.data.IClusterConfig) {
|
|
||||||
for (const containerConfig of configData.data.containers) {
|
|
||||||
await this.provisionSpecificWorkloadService(containerConfig);
|
|
||||||
}
|
|
||||||
logger.log('ok', 'Waiting for scheduled workload services to settle');
|
|
||||||
await plugins.smartdelay.delayFor(10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async provisionSpecificWorkloadService(
|
|
||||||
containerConfigArg: plugins.servezoneInterfaces.data.IClusterConfigContainer
|
|
||||||
) {
|
) {
|
||||||
const containerImage = await plugins.docker.DockerImage.createFromRegistry(this.dockerHost, {
|
logger.log(
|
||||||
imageUrl: containerConfigArg.image,
|
'info',
|
||||||
});
|
`deploying service ${serviceArgFromCloudly.data.name}@${serviceArgFromCloudly.data.imageVersion}...`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// get the image from cloudly
|
||||||
|
logger.log(
|
||||||
|
'info',
|
||||||
|
`getting image for ${serviceArgFromCloudly.data.name}@${serviceArgFromCloudly.data.imageVersion}`,
|
||||||
|
);
|
||||||
|
const containerImageFromCloudly =
|
||||||
|
await this.coreflowRef.cloudlyConnector.cloudlyApiClient.image.getImageById(
|
||||||
|
serviceArgFromCloudly.data.imageId,
|
||||||
|
);
|
||||||
|
let localDockerImage: plugins.docker.DockerImage;
|
||||||
|
|
||||||
|
// lets get the docker image for the service
|
||||||
|
if (containerImageFromCloudly.data.location.internal) {
|
||||||
|
const imageStream = await containerImageFromCloudly.pullImageVersion(
|
||||||
|
serviceArgFromCloudly.data.imageVersion,
|
||||||
|
);
|
||||||
|
localDockerImage = await plugins.docker.DockerImage.createFromTarStream(
|
||||||
|
this.coreflowRef.dockerHost,
|
||||||
|
{
|
||||||
|
creationObject: {
|
||||||
|
imageUrl: containerImageFromCloudly.id,
|
||||||
|
imageTag: serviceArgFromCloudly.data.imageVersion,
|
||||||
|
},
|
||||||
|
tarStream:
|
||||||
|
plugins.smartstream.nodewebhelpers.convertWebReadableToNodeReadable(imageStream),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
containerImageFromCloudly.data.location.externalRegistryId &&
|
||||||
|
containerImageFromCloudly.data.location.externalImageTag
|
||||||
|
) {
|
||||||
|
const externalRegistry =
|
||||||
|
await this.coreflowRef.cloudlyConnector.cloudlyApiClient.externalRegistry.getRegistryById(
|
||||||
|
containerImageFromCloudly.data.location.externalRegistryId,
|
||||||
|
);
|
||||||
|
// Lets authenticate against the external registry
|
||||||
|
// TODO: deduplicate this, check wether we are already authenticated
|
||||||
|
await this.coreflowRef.dockerHost.auth({
|
||||||
|
username: externalRegistry.data.username,
|
||||||
|
password: externalRegistry.data.password,
|
||||||
|
serveraddress: externalRegistry.data.url,
|
||||||
|
});
|
||||||
|
localDockerImage = await plugins.docker.DockerImage.createFromRegistry(
|
||||||
|
this.coreflowRef.dockerHost,
|
||||||
|
{
|
||||||
|
creationObject: {
|
||||||
|
imageUrl: containerImageFromCloudly.id,
|
||||||
|
imageTag: serviceArgFromCloudly.data.imageVersion,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await localDockerImage.pullLatestImageFromRegistry();
|
||||||
|
} else {
|
||||||
|
throw new Error('Invalid image location');
|
||||||
|
}
|
||||||
|
|
||||||
let containerService = await plugins.docker.DockerService.getServiceByName(
|
let containerService = await plugins.docker.DockerService.getServiceByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
containerConfigArg.name
|
serviceArgFromCloudly.data.name,
|
||||||
);
|
);
|
||||||
|
this.coreflowRef.cloudlyConnector.cloudlyApiClient;
|
||||||
|
|
||||||
|
const dockerSecretName = `${serviceArgFromCloudly.id}_${serviceArgFromCloudly.data.name}_Secret`;
|
||||||
let containerSecret = await plugins.docker.DockerSecret.getSecretByName(
|
let containerSecret = await plugins.docker.DockerSecret.getSecretByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
`${containerConfigArg.name}Secret`
|
dockerSecretName,
|
||||||
);
|
);
|
||||||
|
|
||||||
// existing network to connect to
|
// existing network to connect to
|
||||||
const webGatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
const webGatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
this.commonDockerData.networkNames.sznWebgateway
|
this.commonDockerData.networkNames.sznWebgateway,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (containerService && (await containerService.needsUpdate())) {
|
if (containerService && (await containerService.needsUpdate())) {
|
||||||
@ -232,39 +288,56 @@ export class ClusterManager {
|
|||||||
|
|
||||||
if (!containerService) {
|
if (!containerService) {
|
||||||
containerSecret = await plugins.docker.DockerSecret.getSecretByName(
|
containerSecret = await plugins.docker.DockerSecret.getSecretByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
`${containerConfigArg.name}Secret`
|
dockerSecretName,
|
||||||
);
|
);
|
||||||
if (containerSecret) {
|
if (containerSecret) {
|
||||||
await containerSecret.remove();
|
await containerSecret.remove();
|
||||||
}
|
}
|
||||||
containerSecret = await plugins.docker.DockerSecret.createSecret(this.dockerHost, {
|
|
||||||
name: `${containerConfigArg.name}Secret`,
|
const secretBundle =
|
||||||
contentArg: JSON.stringify(containerConfigArg.secrets),
|
await this.coreflowRef.cloudlyConnector.cloudlyApiClient.secretbundle.getSecretBundleById(
|
||||||
labels: {},
|
serviceArgFromCloudly.data.secretBundleId,
|
||||||
version: await containerImage.getVersion(),
|
);
|
||||||
});
|
|
||||||
containerService = await plugins.docker.DockerService.createService(this.dockerHost, {
|
// lets create the relevant stuff on the docker side
|
||||||
name: containerConfigArg.name,
|
containerSecret = await plugins.docker.DockerSecret.createSecret(
|
||||||
image: containerImage,
|
this.coreflowRef.dockerHost,
|
||||||
networks: [webGatewayNetwork],
|
{
|
||||||
secrets: [containerSecret],
|
name: dockerSecretName,
|
||||||
ports: [],
|
contentArg: JSON.stringify(await secretBundle.getFlatKeyValueObjectForEnvironment()),
|
||||||
labels: {},
|
labels: {},
|
||||||
resources: containerConfigArg.resources,
|
version:
|
||||||
networkAlias: containerConfigArg.name,
|
await containerImageFromCloudly.data.versions[serviceArgFromCloudly.data.imageVersion],
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
containerService = await plugins.docker.DockerService.createService(
|
||||||
|
this.coreflowRef.dockerHost,
|
||||||
|
{
|
||||||
|
name: serviceArgFromCloudly.data.name,
|
||||||
|
image: localDockerImage,
|
||||||
|
networks: [webGatewayNetwork],
|
||||||
|
secrets: [containerSecret],
|
||||||
|
ports: [],
|
||||||
|
labels: {},
|
||||||
|
resources: serviceArgFromCloudly.data.resources,
|
||||||
|
// TODO: introduce a clean name here, that is guaranteed to work with APIs.
|
||||||
|
networkAlias: serviceArgFromCloudly.data.name,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update traffic routing
|
* update traffic routing
|
||||||
*/
|
*/
|
||||||
public async updateTrafficRouting(clusterConfigArg: plugins.servezoneInterfaces.data.IClusterConfig) {
|
public async updateTrafficRouting(
|
||||||
const services = await this.dockerHost.getServices();
|
clusterConfigArg: plugins.servezoneInterfaces.data.IClusterConfig,
|
||||||
|
) {
|
||||||
|
const services = await this.coreflowRef.dockerHost.getServices();
|
||||||
const webGatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
const webGatewayNetwork = await plugins.docker.DockerNetwork.getNetworkByName(
|
||||||
this.dockerHost,
|
this.coreflowRef.dockerHost,
|
||||||
this.commonDockerData.networkNames.sznWebgateway
|
this.commonDockerData.networkNames.sznWebgateway,
|
||||||
);
|
);
|
||||||
const reverseProxyConfigs: plugins.servezoneInterfaces.data.IReverseProxyConfig[] = [];
|
const reverseProxyConfigs: plugins.servezoneInterfaces.data.IReverseProxyConfig[] = [];
|
||||||
|
|
||||||
@ -272,7 +345,7 @@ export class ClusterManager {
|
|||||||
serviceNameArg: string,
|
serviceNameArg: string,
|
||||||
hostNameArg: string,
|
hostNameArg: string,
|
||||||
containerDestinationIp: string,
|
containerDestinationIp: string,
|
||||||
webDestinationPort: string
|
webDestinationPort: string,
|
||||||
) => {
|
) => {
|
||||||
logger.log('ok', `trying to obtain a certificate for ${hostNameArg}`);
|
logger.log('ok', `trying to obtain a certificate for ${hostNameArg}`);
|
||||||
const certificate =
|
const certificate =
|
||||||
@ -286,7 +359,7 @@ export class ClusterManager {
|
|||||||
});
|
});
|
||||||
logger.log(
|
logger.log(
|
||||||
'success',
|
'success',
|
||||||
`pushed routing config for ${hostNameArg} on workload service ${serviceNameArg}`
|
`pushed routing config for ${hostNameArg} on workload service ${serviceNameArg}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -308,7 +381,7 @@ export class ClusterManager {
|
|||||||
if (!containersOfServicesOnNetwork[0]) {
|
if (!containersOfServicesOnNetwork[0]) {
|
||||||
logger.log(
|
logger.log(
|
||||||
'error',
|
'error',
|
||||||
`There seems to be no container available for service ${service.Spec.Name}`
|
`There seems to be no container available for service ${service.Spec.Name}`,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -322,7 +395,7 @@ export class ClusterManager {
|
|||||||
workloadConfig.name,
|
workloadConfig.name,
|
||||||
hostName,
|
hostName,
|
||||||
containerDestinationIp,
|
containerDestinationIp,
|
||||||
webDestinationPort
|
webDestinationPort,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,14 +407,14 @@ export class ClusterManager {
|
|||||||
workloadConfig.name,
|
workloadConfig.name,
|
||||||
customDomainKey,
|
customDomainKey,
|
||||||
containerDestinationIp,
|
containerDestinationIp,
|
||||||
workloadConfig.ports.custom[customDomainKey]
|
workloadConfig.ports.custom[customDomainKey],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
'ok',
|
'ok',
|
||||||
`service ${service.Spec.Name} is not a workload service and won't receive traffic`
|
`service ${service.Spec.Name} is not a workload service and won't receive traffic`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ export class Coreflow {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
|
this.serviceQenv = new plugins.qenv.Qenv('./', './.nogit');
|
||||||
this.dockerHost = new plugins.docker.DockerHost(); // defaults to locally mounted docker sock
|
this.dockerHost = new plugins.docker.DockerHost({}); // defaults to locally mounted docker sock
|
||||||
this.internalServer = new InternalServer(this);
|
this.internalServer = new InternalServer(this);
|
||||||
this.cloudlyConnector = new CloudlyConnector(this);
|
this.cloudlyConnector = new CloudlyConnector(this);
|
||||||
this.corechatConnector = new CoretrafficConnector(this);
|
this.corechatConnector = new CoretrafficConnector(this);
|
||||||
|
@ -11,7 +11,7 @@ export class InternalServer {
|
|||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
this.typedsocketServer = await plugins.typedsocket.TypedSocket.createServer(
|
this.typedsocketServer = await plugins.typedsocket.TypedSocket.createServer(
|
||||||
this.coreflowRef.typedrouter
|
this.coreflowRef.typedrouter,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export class CoreflowTaskmanager {
|
|||||||
await this.updateBaseServicesTask.trigger();
|
await this.updateBaseServicesTask.trigger();
|
||||||
logger.log(
|
logger.log(
|
||||||
'success',
|
'success',
|
||||||
'initial tasks successfully executed! Now handing over to longterm taskmanager!'
|
'initial tasks successfully executed! Now handing over to longterm taskmanager!',
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -7,47 +7,46 @@ import { Coreflow } from './coreflow.classes.coreflow.js';
|
|||||||
|
|
||||||
export class CloudlyConnector {
|
export class CloudlyConnector {
|
||||||
public coreflowRef: Coreflow;
|
public coreflowRef: Coreflow;
|
||||||
public cloudlyClient: plugins.servezoneApi.CloudlyClient;
|
public cloudlyApiClient: plugins.servezoneApi.CloudlyApiClient;
|
||||||
public coreflowJumpCode: string;
|
public coreflowJumpCode: string;
|
||||||
public identity: plugins.servezoneInterfaces.data.IClusterIdentifier;
|
public identity: plugins.servezoneInterfaces.data.IIdentity;
|
||||||
|
|
||||||
constructor(coreflowRefArg: Coreflow) {
|
constructor(coreflowRefArg: Coreflow) {
|
||||||
this.coreflowRef = coreflowRefArg;
|
this.coreflowRef = coreflowRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
this.cloudlyClient = new plugins.servezoneApi.CloudlyClient('coreflow');
|
this.cloudlyApiClient = new plugins.servezoneApi.CloudlyApiClient({
|
||||||
await this.cloudlyClient.start();
|
registerAs: 'coreflow',
|
||||||
|
cloudlyUrl: await this.coreflowRef.serviceQenv.getEnvVarOnDemand('CLOUDLY_URL'),
|
||||||
|
});
|
||||||
|
await this.cloudlyApiClient.start();
|
||||||
this.coreflowJumpCode = await this.coreflowRef.serviceQenv.getEnvVarOnDemand('JUMPCODE');
|
this.coreflowJumpCode = await this.coreflowRef.serviceQenv.getEnvVarOnDemand('JUMPCODE');
|
||||||
|
|
||||||
// get identity and tag connection (second parameter is true -> tags the connection)
|
// get identity and tag connection (second parameter is true -> tags the connection)
|
||||||
this.identity = await this.cloudlyClient.getIdentityByJumpCode(this.coreflowJumpCode, true);
|
this.identity = await this.cloudlyApiClient.getIdentityByToken(this.coreflowJumpCode, {
|
||||||
}
|
statefullIdentity: true,
|
||||||
|
tagConnection: true,
|
||||||
public async stop() {
|
|
||||||
await this.cloudlyClient.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getConfigFromCloudly(): Promise<plugins.servezoneInterfaces.data.IClusterConfig> {
|
|
||||||
const config = await this.cloudlyClient.getClusterConfigFromCloudlyByIdentity(
|
|
||||||
this.identity
|
|
||||||
);
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async triggerConfigEvent() {
|
|
||||||
const config = await this.getConfigFromCloudly();
|
|
||||||
this.cloudlyClient.configUpdateSubject.next({
|
|
||||||
configData: config,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async stop() {
|
||||||
|
await this.cloudlyApiClient.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getConfigFromCloudly(): Promise<plugins.servezoneInterfaces.data.ICluster> {
|
||||||
|
const config = await this.cloudlyApiClient.getClusterConfigFromCloudlyByIdentity(this.identity);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
public async getCertificateForDomainFromCloudly(
|
public async getCertificateForDomainFromCloudly(
|
||||||
domainNameArg: string
|
domainNameArg: string,
|
||||||
): Promise<plugins.tsclass.network.ICert> {
|
): Promise<plugins.tsclass.network.ICert> {
|
||||||
const certificate = await this.cloudlyClient.getCertificateForDomainOverHttps(
|
const certificate = await this.cloudlyApiClient.getCertificateForDomain({
|
||||||
domainNameArg
|
identity: this.identity,
|
||||||
);
|
domainName: domainNameArg,
|
||||||
|
type: 'ssl',
|
||||||
|
});
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,15 @@ export class CoretrafficConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async setReverseConfigs(
|
public async setReverseConfigs(
|
||||||
reverseConfigsArg: plugins.servezoneInterfaces.data.IReverseProxyConfig[]
|
reverseConfigsArg: plugins.servezoneInterfaces.data.IReverseProxyConfig[],
|
||||||
) {
|
) {
|
||||||
await this.start();
|
await this.start();
|
||||||
const reactionRequest =
|
const reactionRequest =
|
||||||
this.coreflowRef.internalServer.typedsocketServer.createTypedRequest<plugins.servezoneInterfaces.requests.routing.IRequest_Coreflow_Coretraffic_RoutingUpdate>(
|
this.coreflowRef.internalServer.typedsocketServer.createTypedRequest<plugins.servezoneInterfaces.requests.routing.IRequest_Coreflow_Coretraffic_RoutingUpdate>(
|
||||||
'updateRouting',
|
'updateRouting',
|
||||||
await this.coreflowRef.internalServer.typedsocketServer.findTargetConnection(
|
await this.coreflowRef.internalServer.typedsocketServer.findTargetConnection(
|
||||||
async (targetConnection) => targetConnection.alias === 'coretraffic'
|
async (targetConnection) => targetConnection.alias === 'coretraffic',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
const response = await reactionRequest.fire({
|
const response = await reactionRequest.fire({
|
||||||
reverseConfigs: reverseConfigsArg,
|
reverseConfigs: reverseConfigsArg,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import * as loleLog from '@losslessone_private/lole-log';
|
import * as plugins from './coreflow.plugins.js';
|
||||||
import { projectInfoNpm } from './coreflow.info.js';
|
import { projectInfoNpm } from './coreflow.info.js';
|
||||||
|
|
||||||
export const logger = loleLog.createLoleLogger({
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
companyUnit: 'Lossless Cloud',
|
logContext: {
|
||||||
containerName: 'coreflow',
|
containerName: 'coreflow',
|
||||||
containerVersion: projectInfoNpm.version,
|
environment: 'production',
|
||||||
sentryAppName: 'coreflow',
|
runtime: 'node',
|
||||||
sentryDsn: 'https://2a449cd768b34a1b9b5ec34845b4bbd0@sentry.io/1762080',
|
zone: 'servezone',
|
||||||
zone: 'servezone',
|
},
|
||||||
});
|
});
|
||||||
logger.enableConsole();
|
logger.enableConsole();
|
||||||
|
@ -2,5 +2,5 @@ import * as plugins from './coreflow.plugins.js';
|
|||||||
|
|
||||||
export const packageDir = plugins.path.join(
|
export const packageDir = plugins.path.join(
|
||||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
'../'
|
'../',
|
||||||
);
|
);
|
||||||
|
@ -28,6 +28,7 @@ import * as smartpromise from '@push.rocks/smartpromise';
|
|||||||
import * as smartrequest from '@push.rocks/smartrequest';
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
import * as smartrx from '@push.rocks/smartrx';
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
import * as smartstate from '@push.rocks/smartstate';
|
import * as smartstate from '@push.rocks/smartstate';
|
||||||
|
import * as smartstream from '@push.rocks/smartstream';
|
||||||
import * as smartstring from '@push.rocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
import * as taskbuffer from '@push.rocks/taskbuffer';
|
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ export {
|
|||||||
smartrequest,
|
smartrequest,
|
||||||
smartrx,
|
smartrx,
|
||||||
smartstate,
|
smartstate,
|
||||||
|
smartstream,
|
||||||
smartstring,
|
smartstring,
|
||||||
taskbuffer,
|
taskbuffer,
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ export const runCli = async () => {
|
|||||||
'info',
|
'info',
|
||||||
`trying to start coreflow@v${projectInfoNpm.version} on ${
|
`trying to start coreflow@v${projectInfoNpm.version} on ${
|
||||||
(await smartnetworkInstance.getPublicIps()).v4
|
(await smartnetworkInstance.getPublicIps()).v4
|
||||||
}`
|
}`,
|
||||||
);
|
);
|
||||||
coreflowInstance = new Coreflow();
|
coreflowInstance = new Coreflow();
|
||||||
await coreflowInstance.start();
|
await coreflowInstance.start();
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist_*/**/*.d.ts"
|
"dist_*/**/*.d.ts"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user