New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HA: multiple instance replicas #85
Conversation
When HA enabled call all the endpoints to make sure all instances stay in sync
kubernetes.js
Outdated
@@ -306,6 +306,12 @@ const createDeployment = async (project, options) => { | |||
localPod.spec.containers[0].resources.limits.cpu = `${stack.cpu * 10}m` | |||
} | |||
|
|||
const ha = await project.getSetting('ha') | |||
console.log(ha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(ha) | |
console.log(ha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor tidy up of commented out code - and an observation on the status endpoint. Would like a follow-up task to be raised to review gathering status of all instances, not just one.
@@ -727,6 +748,7 @@ module.exports = { | |||
(details.body.status?.conditions[0].type === 'Available' || | |||
(details.body.status?.conditions[0].type === 'Progressing' && details.body.status?.conditions[0].reason === 'NewReplicaSetAvailable') | |||
)) { | |||
// not calling all endpoints for HA as they should be the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a little risky - in case one instance has hit a hang or other unpleasantness that goes unnoticed.
For an initial iteration, we can go with this, but will need to look at next week.
kubernetes.js
Outdated
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | ||
// if (await project.getSetting('ha')) { | ||
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | ||
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | ||
// const commands = [] | ||
// for (const address in addresses) { | ||
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { | ||
// json: { | ||
// cmd: 'stop' | ||
// } | ||
// })) | ||
// } | ||
// await Promise.all(commands) | ||
// } else { | ||
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { | ||
// json: { | ||
// cmd: 'stop' | ||
// } | ||
// }) | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | |
// if (await project.getSetting('ha')) { | |
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | |
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | |
// const commands = [] | |
// for (const address in addresses) { | |
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { | |
// json: { | |
// cmd: 'stop' | |
// } | |
// })) | |
// } | |
// await Promise.all(commands) | |
// } else { | |
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { | |
// json: { | |
// cmd: 'stop' | |
// } | |
// }) | |
// } |
kubernetes.js
Outdated
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | ||
// if (project.getSetting('ha')) { | ||
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | ||
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | ||
// const commands = [] | ||
// for (const address in addresses) { | ||
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { | ||
// json: { | ||
// cmd: 'restart' | ||
// } | ||
// })) | ||
// } | ||
// await Promise.all(commands) | ||
// } else { | ||
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { | ||
// json: { | ||
// cmd: 'restart' | ||
// } | ||
// }) | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | |
// if (project.getSetting('ha')) { | |
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | |
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | |
// const commands = [] | |
// for (const address in addresses) { | |
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { | |
// json: { | |
// cmd: 'restart' | |
// } | |
// })) | |
// } | |
// await Promise.all(commands) | |
// } else { | |
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { | |
// json: { | |
// cmd: 'restart' | |
// } | |
// }) | |
// } |
kubernetes.js
Outdated
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | ||
// if (project.getSetting('ha')) { | ||
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | ||
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | ||
// const commands = [] | ||
// for (const address in addresses) { | ||
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { // logout:nodered(step-4) | ||
// json: { | ||
// cmd: 'logout', | ||
// token | ||
// } | ||
// })) | ||
// } | ||
// Promise.all(commands).catch(error => { | ||
// this._app.log.error(`[k8s] Project ${project.id} - error in 'revokeUserToken': ${error.stack}`) | ||
// }) | ||
// } else { | ||
// try { | ||
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { // logout:nodered(step-4) | ||
// json: { | ||
// cmd: 'logout', | ||
// token | ||
// } | ||
// }) | ||
// } catch (error) { | ||
// this._app.log.error(`[k8s] Project ${project.id} - error in 'revokeUserToken': ${error.stack}`) | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// const prefix = project.safeName.match(/^[0-9]/) ? 'srv-' : '' | |
// if (project.getSetting('ha')) { | |
// const endpoints = await this._k8sApi.readNamespacedEndpoints(`${prefix}${project.safeName}`, this._namespace) | |
// const addresses = endpoints.body.subsets[0].addresses.map(a => { return a.ip }) | |
// const commands = [] | |
// for (const address in addresses) { | |
// commands.push(got.post(`http://${addresses[address]}:2880/flowforge/command`, { // logout:nodered(step-4) | |
// json: { | |
// cmd: 'logout', | |
// token | |
// } | |
// })) | |
// } | |
// Promise.all(commands).catch(error => { | |
// this._app.log.error(`[k8s] Project ${project.id} - error in 'revokeUserToken': ${error.stack}`) | |
// }) | |
// } else { | |
// try { | |
// await got.post(`http://${prefix}${project.safeName}.${this._namespace}:2880/flowforge/command`, { // logout:nodered(step-4) | |
// json: { | |
// cmd: 'logout', | |
// token | |
// } | |
// }) | |
// } catch (error) { | |
// this._app.log.error(`[k8s] Project ${project.id} - error in 'revokeUserToken': ${error.stack}`) | |
// } | |
// } |
Description
Sets the correct number of replicas on the Deployment object
Also has support for merging the logs from multiple replicas
To do:
Related Issue(s)
FlowFuse/flowfuse#2156
Checklist
flowforge.yml
?flowforge/helm
to update ConfigMap Templateflowforge/CloudProject
to update values for Staging/ProductionLabels
backport
labelarea:migration
label