-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from Backendless/stage
Stage -> master
- Loading branch information
Showing
15 changed files
with
318 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { k8sAppsV1Api, k8sCoreV1Api } from '../../k8s/k8s' | ||
import { installStatus } from '../install-status' | ||
import { Logger } from '../../../logger' | ||
import { getMountPathFromDeployment } from '../../get-mount-path' | ||
import { NodeServerConfig } from '../../k8s/config/node-server-config' | ||
import { consul } from '../../consul' | ||
import { k8sConfig } from '../../../config/k8s-config' | ||
|
||
const logger = Logger('install-bl-node-server') | ||
|
||
export async function installNodeServer({ | ||
mountPath, | ||
version | ||
}) { | ||
if (!mountPath) { | ||
logger.info('mountPath is not provided, will get from bl-server') | ||
const repoMountPath = await getMountPathFromDeployment({ | ||
workloadName: 'bl-server', | ||
volumeName: 'repo' | ||
}) | ||
logger.info(`repo path for bl-server is [${repoMountPath}]`) | ||
mountPath = repoMountPath.replace('/repo', '') | ||
logger.info(`mount path will be [${mountPath}]`) | ||
|
||
} | ||
|
||
const nodeServerConfig = new NodeServerConfig() | ||
installStatus.info('installing bl-node-server...') | ||
const workload = nodeServerConfig.workload | ||
workload.spec.template.spec.containers[0].image = `backendless/bl-node-server:${version}` | ||
workload.spec.template.spec.volumes.push({ | ||
hostPath: { | ||
path: `${mountPath}/repo`, | ||
type: 'DirectoryOrCreate' | ||
}, | ||
name: 'repo' | ||
}) | ||
|
||
workload.spec.template.spec.volumes.push({ | ||
hostPath: { | ||
path: `${mountPath}/logs/bl-node-server/`, | ||
type: 'DirectoryOrCreate' | ||
}, | ||
name: 'logs' | ||
}) | ||
|
||
installStatus.info('creating deployment for bl-node-server') | ||
logger.verbose(`creating workload for bl-node-server with config: ${JSON.stringify(workload)}`) | ||
const createStatefulSetResult = await k8sAppsV1Api.createNamespacedDeployment(await k8sConfig.getNamespace(), workload) | ||
installStatus.info('creating service for bl-node-server') | ||
const createServiceResult = await k8sCoreV1Api.createNamespacedService(await k8sConfig.getNamespace(), nodeServerConfig.service) | ||
|
||
logger.info(`add config to consul`) | ||
await consul.put('config/nodeServer/internalAddress', 'http://bl-node-server:4000') | ||
|
||
return { | ||
createStatefulSetResult, | ||
createServiceResult | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
export class NodeServerConfig { | ||
workload = { | ||
'apiVersion': 'apps/v1', | ||
'kind': 'Deployment', | ||
'metadata': { | ||
'annotations': { | ||
'name': 'bl-node-server' | ||
}, | ||
'name': 'bl-node-server' | ||
}, | ||
'spec': { | ||
'progressDeadlineSeconds': 60, | ||
'replicas': 1, | ||
'selector': { | ||
'matchLabels': { | ||
'app': 'bl-node-server' | ||
} | ||
}, | ||
'strategy': { | ||
'rollingUpdate': { | ||
'maxSurge': 1, | ||
'maxUnavailable': 0 | ||
}, | ||
'type': 'RollingUpdate' | ||
}, | ||
'template': { | ||
'metadata': { | ||
'labels': { | ||
'app': 'bl-node-server' | ||
} | ||
}, | ||
'spec': { | ||
'containers': [ | ||
{ | ||
'args': [ | ||
'play' | ||
], | ||
'env': [ | ||
{ | ||
'name': 'BL_CONSUL_PORT', | ||
'valueFrom': { | ||
'configMapKeyRef': { | ||
'key': 'BL_CONSUL_PORT', | ||
'name': 'bl-env', | ||
'optional': false | ||
} | ||
} | ||
}, | ||
{ | ||
'name': 'BL_HOST_IP', | ||
'valueFrom': { | ||
'fieldRef': { | ||
'fieldPath': 'status.hostIP' | ||
} | ||
} | ||
}, | ||
{ | ||
'name': 'BL_CONSUL_HOST', | ||
'valueFrom': { | ||
'configMapKeyRef': { | ||
'key': 'BL_CONSUL_HOST', | ||
'name': 'bl-env', | ||
'optional': false | ||
} | ||
} | ||
}, | ||
{ | ||
'name': 'BL_CONFIG_PROVIDER', | ||
'valueFrom': { | ||
'configMapKeyRef': { | ||
'key': 'BL_CONFIG_PROVIDER', | ||
'name': 'bl-env', | ||
'optional': false | ||
} | ||
} | ||
}, | ||
{ | ||
'name': 'BL_CONTAINER_IP', | ||
'valueFrom': { | ||
'fieldRef': { | ||
'apiVersion': 'v1', | ||
'fieldPath': 'status.podIP' | ||
} | ||
} | ||
} | ||
], | ||
'image': 'backendless/bl-node-server', | ||
'imagePullPolicy': 'IfNotPresent', | ||
'name': 'bl-node-server', | ||
'startupProbe': { | ||
'failureThreshold': 80, | ||
'periodSeconds': 10, | ||
'httpGet': { | ||
'path': '/health', | ||
'port': 4000, | ||
'scheme': 'HTTP' | ||
} | ||
}, | ||
'livenessProbe': { | ||
'failureThreshold': 6, | ||
'httpGet': { | ||
'path': '/health', | ||
'port': 4000, | ||
'scheme': 'HTTP' | ||
}, | ||
'initialDelaySeconds': 60, | ||
'periodSeconds': 2, | ||
'successThreshold': 1, | ||
'timeoutSeconds': 10 | ||
}, | ||
'readinessProbe': { | ||
'failureThreshold': 60, | ||
'httpGet': { | ||
'path': '/health', | ||
'port': 4000, | ||
'scheme': 'HTTP' | ||
}, | ||
'initialDelaySeconds': 10, | ||
'periodSeconds': 1, | ||
'successThreshold': 2, | ||
'timeoutSeconds': 1 | ||
}, | ||
'ports': [ | ||
{ | ||
'containerPort': 4000, | ||
'name': 'bl-node-server', | ||
'protocol': 'TCP' | ||
} | ||
], | ||
'volumeMounts': [ | ||
{ | ||
'mountPath': '/opt/backendless/repo', | ||
'name': 'repo' | ||
}, | ||
{ | ||
'mountPath': '/opt/backendless/logs', | ||
'name': 'logs' | ||
} | ||
] | ||
} | ||
], | ||
'restartPolicy': 'Always', | ||
'volumes': [ | ||
|
||
] | ||
} | ||
} | ||
} | ||
} | ||
service = { | ||
'apiVersion': 'v1', | ||
'kind': 'Service', | ||
'metadata': { | ||
'name': 'bl-node-server', | ||
'labels': { | ||
'app': 'bl-node-server' | ||
} | ||
}, | ||
'spec': { | ||
'type': 'ClusterIP', | ||
'ports': [ | ||
{ | ||
'port': 4000, | ||
'targetPort': 4000, | ||
'name': 'bl-node-server', | ||
} | ||
], | ||
'selector': { | ||
'app': 'bl-node-server' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/services/manage/configuration/domain/public-host-changed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { consul } from '../../../consul' | ||
import { Logger } from '../../../../logger' | ||
|
||
const logger = Logger('ingress-load-balancer') | ||
|
||
export async function publicHostChanged({ type }) { | ||
logger.info(`public host changed for ${type}`) | ||
if (type === 'api') { | ||
const host = await consul.get('config/server/publicHost') | ||
const port = await consul.get('config/server/publicPort') | ||
const protocol = await consul.get('config/server/publicProtocol') | ||
|
||
const portSubstitution = port === '80' || port === 443 ? '' : ':' + port | ||
|
||
const oauthRedirectURL = `${protocol}://${host}${portSubstitution}/integration/oauth/callback` | ||
logger.info(`changing redirect url for integrations to ${oauthRedirectURL}`) | ||
await consul.put('config/integration/redirectURI', oauthRedirectURL) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/services/manage/configuration/domain/restart-services-for-domain-configuration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { manageService } from '../../manage-service' | ||
import { Logger } from '../../../../logger' | ||
|
||
const logger = Logger('restart-services-for-domain-configuration') | ||
|
||
export async function restartServicesForDomainConfiguration() { | ||
logger.info('restarting services for-domain configuration') | ||
await manageService.restartService('bl-server') | ||
await manageService.restartService('bl-web-console') | ||
await manageService.restartService('bl-taskman') | ||
await manageService.restartService('bl-rt-server') | ||
await manageService.restartService('bl-node-server') | ||
await manageService.restartService('bl-automation') | ||
} |
Oops, something went wrong.