Skip to content

Commit

Permalink
Update pathfinder to be a parameter (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuanfandevops authored Oct 6, 2020
1 parent fc2f1e9 commit 5ac0c78
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 63 deletions.
7 changes: 4 additions & 3 deletions .jenkins/.pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ const options= require('@bcgov/pipeline-cli').Util.parseArguments()
const changeId = options.pr //aka pull-request
const version = '1.0.0'
const name = 'jenkins'
const ocpName = 'pathfinder'

const phases = {
build: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'build' , changeId:changeId, suffix: `-build-${changeId}` , instance: `${name}-build-${changeId}` , version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`},
dev: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev-${changeId}` , instance: `${name}-dev-${changeId}` , version:`${version}-${changeId}`, tag:`dev-${version}-${changeId}`},
prod: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'prod' , changeId:changeId, suffix: `-prod` , instance: `${name}-prod` , version:`${version}`, tag:`prod-${version}`},
build: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'build' , changeId:changeId, suffix: `-build-${changeId}` , instance: `${name}-build-${changeId}` , version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`, ocpName: `${ocpName}`},
dev: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev-${changeId}` , instance: `${name}-dev-${changeId}` , version:`${version}-${changeId}`, tag:`dev-${version}-${changeId}`, ocpName: `${ocpName}`},
prod: {namespace:'tbiwaq-tools' , name: `${name}`, phase: 'prod' , changeId:changeId, suffix: `-prod` , instance: `${name}-prod` , version:`${version}`, tag:`prod-${version}`, ocpName: `${ocpName}`},
};

// This callback forces the node process to exit as failure.
Expand Down
2 changes: 1 addition & 1 deletion .jenkins/.pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = (settings)=>{
'SUFFIX': phases[phase].suffix,
'VERSION': phases[phase].tag,
'ENV_NAME': phases[phase].phase,
'ROUTE_HOST': `${phases[phase].name}${phases[phase].suffix}-${phases[phase].namespace}.pathfinder.gov.bc.ca`
'ROUTE_HOST': `${phases[phase].name}${phases[phase].suffix}-${phases[phase].namespace}.${ocpName}.gov.bc.ca`
}
}))

Expand Down
3 changes: 3 additions & 0 deletions .jenkins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Github Webhooks are only created during the PROD deployment.

Windows users can just do the `cd` manually to the root folder of their repo and remove `$(git rev-parse --show-toplevel)/` from the commands below.

# Update OCP Name
Replace pathfinder with proper name in docker/contrib/jenkins/configuration/config.xml

# Build
```
( cd "$(git rev-parse --show-toplevel)/.jenkins/.pipeline" && npm run build -- --pr=0 --dev-mode=true )
Expand Down
21 changes: 11 additions & 10 deletions .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,46 @@ const options= require('@bcgov/pipeline-cli').Util.parseArguments()
const changeId = options.pr //aka pull-request
const version = '1.0.0'
const name = 'zeva'
const ocpName = 'pathfinder'

const phases = {

build: {namespace:'tbiwaq-tools' , transient:true, name: `${name}`, phase: 'build',
changeId:`${changeId}`, suffix: `-build-${changeId}` , instance: `${name}-build-${changeId}`,
version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`},
version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`, ocpName: `${ocpName}`},

dev: {namespace:'tbiwaq-dev', transient:true, name: `${name}`, ssoSuffix:'-dev',
ssoName:'sso-dev', phase: 'dev' , changeId:`${changeId}`, suffix: `-dev-${changeId}`,
instance: `${name}-dev-${changeId}` , version:`${version}-${changeId}`, tag:`dev-${version}-${changeId}`,
host: `zeva-dev-${changeId}.pathfinder.gov.bc.ca`, djangoDebug: 'True',
host: `zeva-dev-${changeId}.${ocpName}.gov.bc.ca`, djangoDebug: 'True',
frontendCpuRequest: '100m', frontendCpuLimit: '700m', frontendMemoryRequest: '300M', frontendMemoryLimit: '4G', frontendReplicas: 1,
backendCpuRequest: '300m', backendCpuLimit: '400m', backendMemoryRequest: '1G', backendMemoryLimit: '2G', backendHealthCheckDelay: 30, backendHost: `zeva-backend-dev-${changeId}.pathfinder.gov.bc.ca`, backendReplicas: 1,
backendCpuRequest: '300m', backendCpuLimit: '600m', backendMemoryRequest: '1G', backendMemoryLimit: '2G', backendHealthCheckDelay: 30, backendHost: `zeva-backend-dev-${changeId}.${ocpName}.gov.bc.ca`, backendReplicas: 1,
minioCpuRequest: '100m', minioCpuLimit: '200m', minioMemoryRequest: '200M', minioMemoryLimit: '500M', minioPvcSize: '1G',
schemaspyCpuRequest: '50m', schemaspyCpuLimit: '200m', schemaspyMemoryRequest: '150M', schemaspyMemoryLimit: '300M', schemaspyHealthCheckDelay: 160,
rabbitmqCpuRequest: '250m', rabbitmqCpuLimit: '700m', rabbitmqMemoryRequest: '500M', rabbitmqMemoryLimit: '1G', rabbitmqPvcSize: '1G', rabbitmqReplica: 1, rabbitmqPostStartSleep: 120, storageClass: 'netapp-block-standard',
patroniCpuRequest: '200m', patroniCpuLimit: '400m', patroniMemoryRequest: '250M', patroniMemoryLimit: '500M', patroniPvcSize: '2G', patroniReplica: 1, storageClass: 'netapp-block-standard'},
patroniCpuRequest: '200m', patroniCpuLimit: '400m', patroniMemoryRequest: '250M', patroniMemoryLimit: '500M', patroniPvcSize: '2G', patroniReplica: 1, storageClass: 'netapp-block-standard', ocpName: `${ocpName}`},

test: {namespace:'tbiwaq-test', name: `${name}`, ssoSuffix:'-test',
ssoName:'sso-test', phase: 'test' , changeId:`${changeId}`, suffix: `-test`,
instance: `${name}-test`, version:`${version}`, tag:`test-${version}`,
host: 'zeva-test.pathfinder.gov.bc.ca', djangoDebug: 'False',
host: 'zeva-test.${ocpName}.gov.bc.ca', djangoDebug: 'False',
frontendCpuRequest: '300m', frontendCpuLimit: '600m', frontendMemoryRequest: '500M', frontendMemoryLimit: '1G', frontendReplicas: 2, frontendMinReplicas: 2, frontendMaxReplicas: 5,
backendCpuRequest: '100m', backendCpuLimit: '500m', backendMemoryRequest: '500M', backendMemoryLimit: '700M', backendHealthCheckDelay: 30, backendReplicas: 1, backendMinReplicas: 2, backendMaxReplicas: 5, backendHost: `zeva-backend-test.pathfinder.gov.bc.ca`,
backendCpuRequest: '100m', backendCpuLimit: '500m', backendMemoryRequest: '500M', backendMemoryLimit: '700M', backendHealthCheckDelay: 30, backendReplicas: 1, backendMinReplicas: 2, backendMaxReplicas: 5, backendHost: `zeva-backend-test.${ocpName}.gov.bc.ca`,
minioCpuRequest: '100m', minioCpuLimit: '300m', minioMemoryRequest: '500M', minioMemoryLimit: '700M', minioPvcSize: '5G',
schemaspyCpuRequest: '20m', schemaspyCpuLimit: '200m', schemaspyMemoryRequest: '150M', schemaspyMemoryLimit: '300M', schemaspyHealthCheckDelay: 160,
rabbitmqCpuRequest: '250m', rabbitmqCpuLimit: '700m', rabbitmqMemoryRequest: '500M', rabbitmqMemoryLimit: '700M', rabbitmqPvcSize: '1G', rabbitmqReplica: 2, rabbitmqPostStartSleep: 120, storageClass: 'netapp-block-standard',
patroniCpuRequest: '500m', patroniCpuLimit: '1000m', patroniMemoryRequest: '500M', patroniMemoryLimit: '1G', patroniPvcSize: '5G', patroniReplica: 2, storageClass: 'netapp-block-standard'},
patroniCpuRequest: '500m', patroniCpuLimit: '1000m', patroniMemoryRequest: '500M', patroniMemoryLimit: '1G', patroniPvcSize: '5G', patroniReplica: 2, storageClass: 'netapp-block-standard', ocpName: `${ocpName}`},

prod: {namespace:'tbiwaq-prod', name: `${name}`, ssoSuffix:'',
ssoName:'sso', phase: 'prod' , changeId:`${changeId}`, suffix: `-prod`,
instance: `${name}-prod`, version:`${version}`, tag:`prod-${version}`,
host: 'zeroemissionvehicles.pathfinder.gov.bc.ca', djangoDebug: 'False',
host: 'zeroemissionvehicles.${ocpName}.gov.bc.ca', djangoDebug: 'False',
frontendCpuRequest: '300m', frontendCpuLimit: '600m', frontendMemoryRequest: '1G', frontendMemoryLimit: '2G', frontendReplicas: 2, frontendMinReplicas: 2, frontendMaxReplicas: 5,
backendCpuRequest: '200m', backendCpuLimit: '700m', backendMemoryRequest: '1G', backendMemoryLimit: '2G', backendHealthCheckDelay: 30, backendReplicas: 1, backendMinReplicas: 2, backendMaxReplicas: 5, backendHost: `zeva-backend-prod.pathfinder.gov.bc.ca`,
backendCpuRequest: '200m', backendCpuLimit: '700m', backendMemoryRequest: '1G', backendMemoryLimit: '2G', backendHealthCheckDelay: 30, backendReplicas: 1, backendMinReplicas: 2, backendMaxReplicas: 5, backendHost: `zeva-backend-prod.${ocpName}.gov.bc.ca`,
minioCpuRequest: '100m', minioCpuLimit: '300m', minioMemoryRequest: '500M', minioMemoryLimit: '700M', minioPvcSize: '10G',
schemaspyCpuRequest: '50m', schemaspyCpuLimit: '400m', schemaspyMemoryRequest: '150M', schemaspyMemoryLimit: '300M', schemaspyHealthCheckDelay: 160,
rabbitmqCpuRequest: '250m', rabbitmqCpuLimit: '700m', rabbitmqMemoryRequest: '500M', rabbitmqMemoryLimit: '1G', rabbitmqPvcSize: '5G', rabbitmqReplica: 3, rabbitmqPostStartSleep: 120, storageClass: 'netapp-block-standard',
patroniCpuRequest: '500m', patroniCpuLimit: '1000m', patroniMemoryRequest: '1G', patroniMemoryLimit: '2G', patroniPvcSize: '40G', patroniReplica: 3, storageClass: 'netapp-block-standard'},
patroniCpuRequest: '500m', patroniCpuLimit: '1000m', patroniMemoryRequest: '1G', patroniMemoryLimit: '2G', patroniPvcSize: '40G', patroniReplica: 3, storageClass: 'netapp-block-standard', ocpName: `${ocpName}`},

};

Expand Down
7 changes: 4 additions & 3 deletions .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = settings => {
const oc = new OpenShiftClientX(Object.assign({namespace: phases[phase].namespace}, options));

//add Valid Redirect URIs for the pull request to keycloak
//for example: https://zeva-dev-79.pathfinder.gov.bc.ca/*
if(phase === 'dev') {
const kc = new KeyCloakClient(settings, oc);
kc.addUris();
Expand All @@ -32,7 +31,8 @@ module.exports = settings => {
'BACKEND_HOST_NAME': phases[phase].backendHost,
'SSO_NAME': phases[phase].ssoName,
'KEYCLOAK_REALM': 'rzh2zkjq',
'DJANGO_DEBUG': phases[phase].djangoDebug
'DJANGO_DEBUG': phases[phase].djangoDebug,
'OCP_NAME': phases[phase].ocpName
}
}))

Expand Down Expand Up @@ -164,7 +164,8 @@ module.exports = settings => {
'CPU_LIMIT': phases[phase].schemaspyCpuLimit,
'MEMORY_REQUEST': phases[phase].schemaspyMemoryRequest,
'MEMORY_LIMIT': phases[phase].schemaspyMemoryLimit,
'HEALTH_CHECK_DELAY': phases[phase].schemaspyHealthCheckDelay
'HEALTH_CHECK_DELAY': phases[phase].schemaspyHealthCheckDelay,
'OCP_NAME': phases[phase].ocpName
}
}))

Expand Down
2 changes: 0 additions & 2 deletions frontend/Caddyfile

This file was deleted.

4 changes: 2 additions & 2 deletions openshift/templates/backup-container-2.0.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Following are the instructions for running the backups and a restore.
## Storage
*Before we get too far into the the details, we're going to take a moment to discuss the most important part of the whole process - **The Storage**.* The backup container uses two volumes, one for storing the backups and the other for restore/verification testing. The deployment template separates them intentionally.

The following sections on storage discuss the recommendations and limitations of the storage classes created specifically for the BC Government's [PathFinder](https://console.pathfinder.gov.bc.ca:8443/) environment.
The following sections on storage discuss the recommendations and limitations of the storage classes created specifically for the BC Government's environment.


### Backup Storage Volume
Expand Down Expand Up @@ -249,7 +249,7 @@ The [backup script](./docker/backup.sh) supports running manual or scheduled ver

The Webhook integration feature is enabled by specifying the webhook URL, `WEBHOOK_URL`, in your configuration. It's recommended that you also provide values for `ENVIRONMENT_FRIENDLY_NAME` and `ENVIRONMENT_NAME`, so you can better identify the environment from which the messages originate and do things like produce links to the environment.

The Webhook integration feature was built with Rocket.Chat in mind and an integration script for Rocket.Chat can be found in [rocket.chat.integration.js](./scripts/rocket.chat.integration.js). This script was developed to support the BC OpenShift Pathfinder environment and will format the notifications from the backup script into Rocket.Chat messages (examples below). If you provide values for the environment name (`ENVIRONMENT_FRIENDLY_NAME` and `ENVIRONMENT_NAME`) hyperlinks will be added to the messages to link you to the pathfinder project console.
The Webhook integration feature was built with Rocket.Chat in mind and an integration script for Rocket.Chat can be found in [rocket.chat.integration.js](./scripts/rocket.chat.integration.js). This script was developed to support the BC OpenShift environment and will format the notifications from the backup script into Rocket.Chat messages (examples below). If you provide values for the environment name (`ENVIRONMENT_FRIENDLY_NAME` and `ENVIRONMENT_NAME`) hyperlinks will be added to the messages to link you to the project console.

Sample Message:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Settings:
- mongo=identity-kit-db-bc/identity_kit_db
- FTP server: not configured
- Webhook Endpoint: https://chat.pathfinder.gov.bc.ca/hooks/***
- Webhook Endpoint: https://chat.[ocp name].gov.bc.ca/hooks/***
- Environment Friendly Name: Verifiable Organizations Network (mongo-test)
- Environment Name (Id): devex-von-test
Expand Down
20 changes: 12 additions & 8 deletions openshift/templates/config/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ parameters:
displayName: django debug value
description: django debug value
required: true
- name: OCP_NAME
displayName: Openshift cluster name
description: Openshift cluster name
required: true
objects:
- apiVersion: v1
kind: ConfigMap
Expand All @@ -58,19 +62,19 @@ objects:
email_sending_enabled: 'False'
env_name: ${ENV_NAME}
keycloak_audience: zeva
keycloak_authority: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_certs_url: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs
keycloak_authority: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_certs_url: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs
keycloak_client_id: zeva
keycloak_issuer: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_issuer: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_logout_redirect_url: https://logontest.gov.bc.ca/clp-cgi/logoff.cgi?returl=https%3A%2F%2F${HOST_NAME}%2F
keycloak_realm_name: ${KEYCLOAK_REALM}
keycloak_realm_url: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_realm: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_sa_baseurl: https://${SSO_NAME}.pathfinder.gov.bc.ca
keycloak_realm_url: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_realm: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth/realms/${KEYCLOAK_REALM}
keycloak_sa_baseurl: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca
keycloak_sa_client_id: zeva-django-sa
keycloak_sa_realm: ${KEYCLOAK_REALM}
keycloak_url: https://${SSO_NAME}.pathfinder.gov.bc.ca/auth
minio_endpoint: zeva-minio-${ENV_NAME}.pathfinder.gov.bc.ca
keycloak_url: https://${SSO_NAME}.${OCP_NAME}.gov.bc.ca/auth
minio_endpoint: zeva-minio-${ENV_NAME}.${OCP_NAME}.gov.bc.ca
postgresql_service_host: patroni-master${SUFFIX}.tbiwaq-${ENV_NAME}.svc.cluster.local
postgresql_service_port: '5432'
rabbitmq_enabled: 'False'
Expand Down
2 changes: 1 addition & 1 deletion openshift/templates/keycloak/keycloak-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
description:
required: true
- name: host
description: host is sso host name, such as sso-dev.pathfinder.gov.bc.ca,sso-test.pathfinder.gov.bc.ca and sso.pathfinder.gov.bc.ca
description: host is sso host name, such as sso-dev.[ocp name].gov.bc.ca,sso-test.[ocp name].gov.bc.ca and sso.[ocp name].gov.bc.ca
required: true
objects:
- apiVersion: v1
Expand Down
6 changes: 3 additions & 3 deletions openshift/templates/minio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
### One minio instance serve all PRs on Dev

oc process -f ./minio-dc.yaml \
NAME=zeva SUFFIX=-dev \
NAME=zeva SUFFIX=-dev OCP_NAME=pathfinder\
| oc create -f - -n tbiwaq-dev

#### Test and Prod Minio setup

oc process -f ./minio-dc.yaml \
NAME=zeva SUFFIX=-test \
NAME=zeva SUFFIX=-test OCP_NAME=pathfinder \
| oc create -f - -n tbiwaq-test


oc process -f ./minio-dc.yaml \
NAME=zeva SUFFIX=-prod \
NAME=zeva SUFFIX=-prod OCP_NAME=pathfinder\
| oc create -f - -n tbiwaq-prod
8 changes: 6 additions & 2 deletions openshift/templates/minio/minio-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ parameters:
from: "[a-zA-Z0-9]{16}"
generate: expression
required: true
objects:
- name: OCP_NAME
displayName: Openshift Name
description: Openshift Name
required: true
Objects:
- apiVersion: v1
kind: Secret
metadata:
Expand Down Expand Up @@ -106,7 +110,7 @@ objects:
env: ${ENV_NAME}
name: ${NAME}-minio${SUFFIX}
spec:
host: ${NAME}-minio${SUFFIX}.pathfinder.gov.bc.ca
host: ${NAME}-minio${SUFFIX}.${OCP_NAME}.gov.bc.ca
port:
targetPort: 9000-tcp
tls:
Expand Down
8 changes: 6 additions & 2 deletions openshift/templates/nagios/nagios-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ parameters:
displayName: Memory upper limit
description: Memory upper limit
required: true
- name: OCP_NAME
displayName: Openshift Name
description: Openshift Name
required: true
objects:
- apiVersion: v1
kind: PersistentVolumeClaim
Expand Down Expand Up @@ -89,7 +93,7 @@ objects:
app: nagios
name: nagios
spec:
host: nagios-${NAME}-${ENV_NAME}.pathfinder.gov.bc.ca
host: nagios-${NAME}-${ENV_NAME}.${OCP_NAME}.gov.bc.ca
path: /
port:
targetPort: 8080-tcp
Expand Down Expand Up @@ -156,7 +160,7 @@ objects:
name: ${NAME}-${ENV_NAME}-rabbitmq-cluster-secret
key: password
- name: MINIO_ENDPOINT
value: docs-mem-${NAME}-${ENV_NAME}.pathfinder.gov.bc.ca:443
value: docs-mem-${NAME}-${ENV_NAME}.${OCP_NAME}.gov.bc.ca:443
- name: MINIO_USE_SSL
value: "true"
- name: MINIO_ACCESS_KEY
Expand Down
10 changes: 5 additions & 5 deletions openshift/templates/nsp/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

### Apply to name spaces before anything else

* oc process -f ./nsp-tools.yaml | oc create -f - -n tbiwaq-tools
* oc process -f ./quickstart-nsp.yaml | oc create -f - -n tbiwaq-tools
* oc process -f ./quickstart-nsp.yaml | oc create -f - -n tbiwaq-dev
* oc process -f ./quickstart-nsp.yaml | oc create -f - -n tbiwaq-test
* oc process -f ./quickstart-nsp.yaml | oc create -f - -n tbiwaq-prod
* oc process -f ./nsp-tools.yaml OCP_NAME=pathfinder | oc create -f - -n tbiwaq-tools
* oc process -f ./quickstart-nsp.yaml ENV_NAME=tools OCP_NAME=pathfinder | oc create -f - -n tbiwaq-tools
* oc process -f ./quickstart-nsp.yaml ENV_NAME=dev OCP_NAME=pathfinder | oc create -f - -n tbiwaq-dev
* oc process -f ./quickstart-nsp.yaml ENV_NAME=test OCP_NAME=pathfinder | oc create -f - -n tbiwaq-test
* oc process -f ./quickstart-nsp.yaml ENV_NAME=prod OCP_NAME=pathfinder | oc create -f - -n tbiwaq-prod

### Add role to users, check if the settings already exist before run the grant

Expand Down
Loading

0 comments on commit 5ac0c78

Please sign in to comment.