Skip to content

Commit

Permalink
add redis settings for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanfandevops committed Nov 7, 2024
1 parent ec0e42b commit 8a246b9
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 439 deletions.
6 changes: 6 additions & 0 deletions .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const phases = {
"https://dev.loginproxy.gov.bc.ca/auth/realms/standard/.well-known/openid-configuration",
backendKeycloakCertsUrl:
"https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/certs",
redisHost: "lcfs-redis-dev-master.d2bd59-dev.svc.cluster.local",
redisPort: 6379,
celeryCpuRequest: "100m",
celeryCpuLimit: "250m",
celeryMemoryRequest: "1600Mi",
Expand Down Expand Up @@ -133,6 +135,8 @@ const phases = {
"https://test.loginproxy.gov.bc.ca/auth/realms/standard/.well-known/openid-configuration",
backendKeycloakCertsUrl:
"https://test.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/certs",
redisHost: "lcfs-redis-test-master.d2bd59-test.svc.cluster.local",
redisPort: 6379,
celeryCpuRequest: "100m",
celeryCpuLimit: "250m",
celeryMemoryRequest: "1600Mi",
Expand Down Expand Up @@ -209,6 +213,8 @@ const phases = {
"https://loginproxy.gov.bc.ca/auth/realms/standard/.well-known/openid-configuration",
backendKeycloakCertsUrl:
"https://loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/certs",
redisHost: "lcfs-redis-prod-master.d2bd59-prod.svc.cluster.local",
redisPort: 6379,
celeryCpuRequest: "100m",
celeryCpuLimit: "250mm",
celeryMemoryRequest: "1600Mi",
Expand Down
277 changes: 164 additions & 113 deletions .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,90 @@
"use strict";
const { OpenShiftClientX } = require("@bcgov/pipeline-cli");
const path = require("path");
const KeyCloakClient = require('./keycloak');
const KeyCloakClient = require("./keycloak");

module.exports = settings => {
module.exports = (settings) => {
const phases = settings.phases;
const options = settings.options;
const phase = options.env;
const changeId = phases[phase].changeId;
const oc = new OpenShiftClientX(Object.assign({ namespace: phases[phase].namespace }, options));
const oc = new OpenShiftClientX(
Object.assign({ namespace: phases[phase].namespace }, options)
);

const templatesLocalBaseUrl = oc.toFileUrl(path.resolve(__dirname, "../../openshift-v4"));
const templatesLocalBaseUrl = oc.toFileUrl(
path.resolve(__dirname, "../../openshift-v4")
);
var objects = [];

//The deployment of your cool app goes here ▼▼▼

//deploy backend
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/backend/backend-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'ENV_NAME': phases[phase].phase,
'NAMESPACE': phases[phase].namespace,
'VERSION': phases[phase].tag,
'KEYCLOAK_AUDIENCE': phases[phase].backendKeycloakAudience,
'CPU_REQUEST':phases[phase].backendCpuRequest,
'CPU_LIMIT':phases[phase].backendCpuLimit,
'MEMORY_REQUEST':phases[phase].backendMemoryRequest,
'MEMORY_LIMIT':phases[phase].backendMemoryLimit,
'REPLICAS':phases[phase].backendReplicas,
'DB_SERVICE_NAME':phases[phase].dbServiceName,
'WELL_KNOWN_ENDPOINT':phases[phase].backendWellKnownEndpoint,
}
}))

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/backend/backend-dc-others.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'BACKEND_HOST':phases[phase].backendHost
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/backend/backend-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
ENV_NAME: phases[phase].phase,
NAMESPACE: phases[phase].namespace,
VERSION: phases[phase].tag,
KEYCLOAK_AUDIENCE: phases[phase].backendKeycloakAudience,
CPU_REQUEST: phases[phase].backendCpuRequest,
CPU_LIMIT: phases[phase].backendCpuLimit,
MEMORY_REQUEST: phases[phase].backendMemoryRequest,
MEMORY_LIMIT: phases[phase].backendMemoryLimit,
REPLICAS: phases[phase].backendReplicas,
DB_SERVICE_NAME: phases[phase].dbServiceName,
WELL_KNOWN_ENDPOINT: phases[phase].backendWellKnownEndpoint,
REDIS_HOST: phases[phase].redistHost,
REDIS_PORT: phases[phase].redisPort,
},
}
)
);

objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/backend/backend-dc-others.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
BACKEND_HOST: phases[phase].backendHost,
},
}
)
);

//deploy frontend
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/frontend/frontend-dc-docker.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'VERSION': phases[phase].tag,
'NAMESPACE': phases[phase].namespace,
'CPU_REQUEST': phases[phase].frontendCpuRequest,
'CPU_LIMIT': phases[phase].frontendCpuLimit,
'MEMORY_REQUEST': phases[phase].frontendMemoryRequest,
'MEMORY_LIMIT': phases[phase].frontendMemoryLimit,
'REPLICAS':phases[phase].frontendReplicas,
'KEYCLOAK_AUTHORITY':phases[phase].frontendKeycloakAuthority,
'KEYCLOAK_CLIENT_ID':phases[phase].frontendKeycloakClientId,
'KEYCLOAK_CALLBACK_URL':phases[phase].frontendKeycloakCallbackUrl,
'KEYCLOAK_LOGOUT_URL':phases[phase].frontendKeycloakLogoutUrl,
'SITEMINDER_LOGOUT_URL':phases[phase].frontendSiteminderLogoutUrl,
'BACKEND_HOST':phases[phase].backendHost,
'DEBUG_ENABLED':phases[phase].frontendDebugEnabled,
}
}))
/*
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/frontend/frontend-dc-docker.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
VERSION: phases[phase].tag,
NAMESPACE: phases[phase].namespace,
CPU_REQUEST: phases[phase].frontendCpuRequest,
CPU_LIMIT: phases[phase].frontendCpuLimit,
MEMORY_REQUEST: phases[phase].frontendMemoryRequest,
MEMORY_LIMIT: phases[phase].frontendMemoryLimit,
REPLICAS: phases[phase].frontendReplicas,
KEYCLOAK_AUTHORITY: phases[phase].frontendKeycloakAuthority,
KEYCLOAK_CLIENT_ID: phases[phase].frontendKeycloakClientId,
KEYCLOAK_CALLBACK_URL: phases[phase].frontendKeycloakCallbackUrl,
KEYCLOAK_LOGOUT_URL: phases[phase].frontendKeycloakLogoutUrl,
SITEMINDER_LOGOUT_URL: phases[phase].frontendSiteminderLogoutUrl,
BACKEND_HOST: phases[phase].backendHost,
DEBUG_ENABLED: phases[phase].frontendDebugEnabled,
},
}
)
);
/*
//deploy frontend
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/frontend/frontend-dc-docker-others.yaml`, {
'param': {
Expand All @@ -75,75 +96,100 @@ module.exports = settings => {
}))
*/
//deploy celery
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/celery/celery-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'VERSION': phases[phase].tag,
'ENV_NAME': phases[phase].phase,
'NAMESPACE': phases[phase].namespace,
'CPU_REQUEST': phases[phase].celeryCpuRequest,
'CPU_LIMIT': phases[phase].celeryCpuLimit,
'MEMORY_REQUEST': phases[phase].celeryMemoryRequest,
'MEMORY_LIMIT': phases[phase].celeryMemoryLimit,
'DB_SERVICE_NAME':phases[phase].dbServiceName,
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/celery/celery-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
VERSION: phases[phase].tag,
ENV_NAME: phases[phase].phase,
NAMESPACE: phases[phase].namespace,
CPU_REQUEST: phases[phase].celeryCpuRequest,
CPU_LIMIT: phases[phase].celeryCpuLimit,
MEMORY_REQUEST: phases[phase].celeryMemoryRequest,
MEMORY_LIMIT: phases[phase].celeryMemoryLimit,
DB_SERVICE_NAME: phases[phase].dbServiceName,
},
}
)
);

//deploy notification server
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/notification/notification-server-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'NAMESPACE': phases[phase].namespace,
'VERSION': phases[phase].tag,
'KEYCLOAK_CERTS_URL': phases[phase].backendKeycloakCertsUrl,
'CPU_REQUEST':phases[phase].notificationServerCpuRequest,
'CPU_LIMIT':phases[phase].notificationServerCpuLimit,
'MEMORY_REQUEST':phases[phase].notificationServerMemoryRequest,
'MEMORY_LIMIT':phases[phase].notificationServerMemoryLimit
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/notification/notification-server-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
NAMESPACE: phases[phase].namespace,
VERSION: phases[phase].tag,
KEYCLOAK_CERTS_URL: phases[phase].backendKeycloakCertsUrl,
CPU_REQUEST: phases[phase].notificationServerCpuRequest,
CPU_LIMIT: phases[phase].notificationServerCpuLimit,
MEMORY_REQUEST: phases[phase].notificationServerMemoryRequest,
MEMORY_LIMIT: phases[phase].notificationServerMemoryLimit,
},
}
)
);

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/notification/notification-server-others-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'FRONTEND_HOST': phases[phase].frontendHost
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/notification/notification-server-others-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
FRONTEND_HOST: phases[phase].frontendHost,
},
}
)
);

//deploy scan coordinator
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/scan-coordinator/scan-coordinator-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'NAMESPACE': phases[phase].namespace,
'VERSION': phases[phase].tag,
'ENV_NAME': phases[phase].phase,
'CPU_REQUEST':phases[phase].scanCoordinatorCpuRequest,
'CPU_LIMIT':phases[phase].scanCoordinatorCpuLimit,
'MEMORY_REQUEST':phases[phase].scanCoordinatorMemoryRequest,
'MEMORY_LIMIT':phases[phase].scanCoordinatorMemoryLimit
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/scan-coordinator/scan-coordinator-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
NAMESPACE: phases[phase].namespace,
VERSION: phases[phase].tag,
ENV_NAME: phases[phase].phase,
CPU_REQUEST: phases[phase].scanCoordinatorCpuRequest,
CPU_LIMIT: phases[phase].scanCoordinatorCpuLimit,
MEMORY_REQUEST: phases[phase].scanCoordinatorMemoryRequest,
MEMORY_LIMIT: phases[phase].scanCoordinatorMemoryLimit,
},
}
)
);

//deploy scan handler
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/scan-handler/scan-handler-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'NAMESPACE': phases[phase].namespace,
'VERSION': phases[phase].tag,
'CPU_REQUEST':phases[phase].scanHandlerCpuRequest,
'CPU_LIMIT':phases[phase].scanHandlerCpuLimit,
'MEMORY_REQUEST':phases[phase].scanHandlerMemoryRequest,
'MEMORY_LIMIT':phases[phase].scanHandlerMemoryLimit,
'DB_SERVICE_NAME':phases[phase].dbServiceName,
}
}))
objects = objects.concat(
oc.processDeploymentTemplate(
`${templatesLocalBaseUrl}/templates/scan-handler/scan-handler-dc.yaml`,
{
param: {
NAME: phases[phase].name,
SUFFIX: phases[phase].suffix,
NAMESPACE: phases[phase].namespace,
VERSION: phases[phase].tag,
CPU_REQUEST: phases[phase].scanHandlerCpuRequest,
CPU_LIMIT: phases[phase].scanHandlerCpuLimit,
MEMORY_REQUEST: phases[phase].scanHandlerMemoryRequest,
MEMORY_LIMIT: phases[phase].scanHandlerMemoryLimit,
DB_SERVICE_NAME: phases[phase].dbServiceName,
},
}
)
);

/*
/*
//only deploy on dev for Tracking PR
if(phases[phase].phase === 'dev') {
Expand Down Expand Up @@ -195,8 +241,13 @@ module.exports = settings => {
phases[phase].name,
phase,
`${changeId}`,
phases[phase].instance,
phases[phase].instance
);
oc.importImageStreams(
objects,
phases[phase].tag,
phases.build.namespace,
phases.build.tag
);
oc.importImageStreams(objects, phases[phase].tag, phases.build.namespace, phases.build.tag);
oc.applyAndDeploy(objects, phases[phase].instance);
};
12 changes: 0 additions & 12 deletions backend/sonar-runner/README.md

This file was deleted.

Loading

0 comments on commit 8a246b9

Please sign in to comment.