underpost 2.8.51 → 2.8.52

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.
@@ -42,6 +42,7 @@
42
42
  "Itemledger",
43
43
  "jsonld",
44
44
  "lampp",
45
+ "letsencrypt",
45
46
  "loadingio",
46
47
  "Longname",
47
48
  "metanarrative",
package/bin/index.js CHANGED
@@ -88,6 +88,7 @@ program
88
88
  .option('--mongodb', 'Init with mongodb statefulset')
89
89
  .option('--valkey', 'Init with valkey service')
90
90
  .option('--contour', 'Init with project contour base HTTPProxy and envoy')
91
+ .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
91
92
  .option('--info', 'Get all kinds objects deployed')
92
93
  .option('--full', 'Init with all statefulsets and services available')
93
94
  .option('--ns-use <ns-name>', 'Switches current context to namespace')
@@ -136,7 +137,8 @@ program
136
137
  .argument('<deploy-id>', 'Deploy configuration id')
137
138
  .argument('[env]', 'Optional environment, for default is development')
138
139
  .argument('[path]', 'Absolute or relative directory, for default is current')
139
- .option('--image-archive', 'Only load tar image from /images')
140
+ .option('--image-archive', 'Only load tar image from ./images')
141
+ .option('--podman-save', 'Save image from podman to ./images')
140
142
  .description('Build image from Dockerfile')
141
143
  .action(Underpost.image.dockerfile.build);
142
144
 
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.51'
61
+ engine.version: '2.8.52'
62
62
  networks:
63
63
  - load-balancer
64
64
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.51",
5
+ "version": "2.8.52",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
@@ -2,12 +2,23 @@ import { timer } from '../client/components/core/CommonJs.js';
2
2
  import { cliSpinner } from '../server/conf.js';
3
3
  import { loggerFactory } from '../server/logger.js';
4
4
  import { shellExec } from '../server/process.js';
5
+ import UnderpostDeploy from './deploy.js';
5
6
 
6
7
  const logger = loggerFactory(import.meta);
7
8
 
8
9
  class UnderpostCluster {
9
10
  static API = {
10
- async init(options = { valkey: false, mariadb: false, valkey: false, full: false, info: false, nsUse: '' }) {
11
+ async init(
12
+ options = {
13
+ valkey: false,
14
+ mariadb: false,
15
+ valkey: false,
16
+ full: false,
17
+ info: false,
18
+ certManager: false,
19
+ nsUse: '',
20
+ },
21
+ ) {
11
22
  if (options.nsUse) {
12
23
  shellExec(`kubectl config set-context --current --namespace=${options.nsUse}`);
13
24
  return;
@@ -40,6 +51,7 @@ class UnderpostCluster {
40
51
  logger.info('----------------------------------------------------------------');
41
52
  shellExec(`kubectl get secrets --all-namespaces -o wide`);
42
53
  shellExec(`docker secret ls`);
54
+ shellExec(`kubectl get crd --all-namespaces -o wide`);
43
55
  return;
44
56
  }
45
57
  const testClusterInit = shellExec(`kubectl get pods --all-namespaces -o wide`, {
@@ -88,14 +100,7 @@ class UnderpostCluster {
88
100
  const monitor = async () => {
89
101
  cliSpinner(1000, `[cluster.js] `, ` Load mongodb instance`, 'yellow', 'material');
90
102
  await timer(1000);
91
- if (
92
- shellExec(`kubectl get pods --all-namespaces -o wide`, {
93
- silent: true,
94
- stdout: true,
95
- disableLog: true,
96
- }).match(`mongodb-1 1/1 Running`)
97
- )
98
- return resolve();
103
+ if (UnderpostDeploy.API.getPods('mongodb-1').find((p) => p.STATUS === 'Running')) return resolve();
99
104
  return monitor();
100
105
  };
101
106
  await monitor();
@@ -119,6 +124,23 @@ class UnderpostCluster {
119
124
 
120
125
  if (options.full || options.contour)
121
126
  shellExec(`kubectl apply -f https://projectcontour.io/quickstart/contour.yaml`);
127
+
128
+ if (options.full || options.certManager) {
129
+ if (!UnderpostDeploy.API.getPods('cert-manager').find((p) => p.STATUS === 'Running')) {
130
+ shellExec(`helm repo add jetstack https://charts.jetstack.io --force-update`);
131
+ shellExec(
132
+ `helm install cert-manager jetstack/cert-manager \
133
+ --namespace cert-manager \
134
+ --create-namespace \
135
+ --version v1.17.0 \
136
+ --set crds.enabled=true`,
137
+ );
138
+ }
139
+
140
+ const letsEncName = 'letsencrypt-prod';
141
+ shellExec(`sudo kubectl delete ClusterIssuer ${letsEncName}`);
142
+ shellExec(`sudo kubectl apply -f ./manifests/${letsEncName}.yaml`);
143
+ }
122
144
  },
123
145
  reset() {
124
146
  shellExec(`kind get clusters | xargs -t -n1 kind delete cluster --name`);
package/src/cli/deploy.js CHANGED
@@ -205,12 +205,19 @@ spec:
205
205
  const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'));
206
206
  for (const host of Object.keys(confServer)) {
207
207
  shellExec(`sudo kubectl delete HTTPProxy ${host}`);
208
+ if (env === 'production') shellExec(`sudo kubectl delete Certificate ${host}`);
208
209
  if (!options.remove === true && env === 'development') concatHots += ` ${host}`;
209
210
  }
210
211
 
212
+ const manifestsPath =
213
+ env === 'production'
214
+ ? `engine-private/conf/${deployId}/build/production`
215
+ : `manifests/deployment/${deployId}-${env}`;
216
+
211
217
  if (!options.remove === true) {
212
- shellExec(`sudo kubectl apply -f ./manifests/deployment/${deployId}-${env}/deployment.yaml`);
213
- shellExec(`sudo kubectl apply -f ./manifests/deployment/${deployId}-${env}/proxy.yaml`);
218
+ shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
219
+ shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
220
+ if (env === 'production') shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
214
221
  }
215
222
 
216
223
  let renderHosts;
package/src/cli/image.js CHANGED
@@ -13,11 +13,18 @@ class UnderpostImage {
13
13
  pullBaseImages() {
14
14
  shellExec(`sudo podman pull docker.io/library/debian:buster`);
15
15
  },
16
- build(deployId = 'default', env = 'development', path = '.', options = { imageArchive: false }) {
16
+ build(
17
+ deployId = 'default',
18
+ env = 'development',
19
+ path = '.',
20
+ options = { imageArchive: false, podmanSave: false },
21
+ ) {
17
22
  const imgName = `${deployId}-${env}:${Underpost.version}`;
18
23
  const podManImg = `localhost/${imgName}`;
19
- const imagesStoragePath = `./images`;
20
- const tarFile = `${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
24
+ const imagesStoragePath = `/images`;
25
+ if (!fs.existsSync(`${path}${imagesStoragePath}`))
26
+ fs.mkdirSync(`${path}${imagesStoragePath}`, { recursive: true });
27
+ const tarFile = `.${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
21
28
 
22
29
  let secrets = ' ';
23
30
  let secretDockerInput = '';
@@ -36,8 +43,9 @@ class UnderpostImage {
36
43
  `cd ${path}${secrets}&& sudo podman build -f ./Dockerfile -t ${imgName} --pull=never --cap-add=CAP_AUDIT_WRITE${secretDockerInput}`,
37
44
  );
38
45
  fs.removeSync(`${path}/.env.underpost`);
39
- shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
40
46
  }
47
+ if (options.imageArchive !== true || options.podmanSave === true)
48
+ shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
41
49
  shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
42
50
  },
43
51
  async script(deployId = 'default', env = 'development', options = { run: false }) {
@@ -101,12 +109,12 @@ class UnderpostImage {
101
109
  shellExec(`node bin/deploy conf ${deployId} ${env}`);
102
110
  shellExec(`node bin/deploy build-full-client ${deployId}`);
103
111
  if (options.run === true) {
104
- const runCmd = env === 'production' ? 'prod-img' : 'dev-img';
112
+ const runCmd = env === 'production' ? 'start' : 'run dev-img';
105
113
  if (fs.existsSync(`./engine-private/replica`)) {
106
114
  const replicas = await fs.readdir(`./engine-private/replica`);
107
115
  for (const replica of replicas) {
108
116
  shellExec(`node bin/deploy conf ${replica} ${env}`);
109
- shellExec(`npm run ${runCmd} ${replica} deploy`, { async: true });
117
+ shellExec(`npm ${runCmd} ${replica} deploy`, { async: true });
110
118
  fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
111
119
  const monitor = async () => {
112
120
  await timer(1000);
@@ -116,7 +124,7 @@ class UnderpostImage {
116
124
  }
117
125
  shellExec(`node bin/deploy conf ${deployId} ${env}`);
118
126
  }
119
- shellExec(`npm run ${runCmd} ${deployId} deploy`);
127
+ shellExec(`npm ${runCmd} ${deployId} deploy`);
120
128
  }
121
129
  },
122
130
  },
package/src/index.js CHANGED
@@ -27,7 +27,7 @@ class Underpost {
27
27
  * @type {String}
28
28
  * @memberof Underpost
29
29
  */
30
- static version = 'v2.8.51';
30
+ static version = 'v2.8.52';
31
31
  /**
32
32
  * Repository cli API
33
33
  * @static