From f220d08800558584a4c0c5db3987fdce125614ea Mon Sep 17 00:00:00 2001 From: Eden Kirin Date: Mon, 15 Jan 2024 11:34:48 +0100 Subject: [PATCH] Container replicas --- docker-compose.yml | 24 +- media/demo-overview.excalidraw | 484 ++++++++++++++++++--------------- proxy/envoy.yaml | 7 +- 3 files changed, 280 insertions(+), 235 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 85d27be..cae09de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +version: "3.8" + services: db: build: @@ -28,24 +30,13 @@ services: depends_on: db: condition: service_healthy - products-app-1: - build: - context: ./products - dockerfile: Dockerfile - environment: - - APPPORT=3000 - - DBHOST=db - - DBPORT=5432 - - DBNAME=komponiranje - - DBUSER=pero - - DBPASSWORD=pero.000 - depends_on: - db: - condition: service_healthy - products-app-2: + products-app: build: context: ./products dockerfile: Dockerfile + deploy: + mode: replicated + replicas: 2 environment: - APPPORT=3000 - DBHOST=db @@ -64,5 +55,4 @@ services: - ./proxy/envoy.yaml:/etc/envoy/envoy.yaml depends_on: - machines-app - - products-app-1 - - products-app-2 + - products-app diff --git a/media/demo-overview.excalidraw b/media/demo-overview.excalidraw index 2064fdb..54f3d34 100644 --- a/media/demo-overview.excalidraw +++ b/media/demo-overview.excalidraw @@ -75,7 +75,7 @@ "containerId": "NjKI1N2j0SeaaMS4uiFZX", "originalText": "Proxy Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -239,7 +239,7 @@ "containerId": "6E6wDhNqpJFrTFY11GZ54", "originalText": "Frontend Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -317,7 +317,7 @@ "containerId": "saBhGH3RJvBZz1GlGAQMa", "originalText": "nginx", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -395,7 +395,7 @@ "containerId": "pdbXtWG_f1H-RY-Vk0RNy", "originalText": "frontend app", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -469,7 +469,7 @@ "containerId": "ORueF6Kvlp_qrMcizUQT1", "originalText": "static content\n(html, js, images)", "lineHeight": 1.25, - "baseline": 61 + "baseline": 58 }, { "type": "rectangle", @@ -543,12 +543,12 @@ "containerId": "ai0osAWJ1RBoQ4JBro3L0", "originalText": "Database Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", - "version": 508, - "versionNonce": 2050999093, + "version": 509, + "versionNonce": 1569030326, "isDeleted": false, "id": "wUuH6P3y0n2bIbcULauqL", "fillStyle": "solid", @@ -583,9 +583,13 @@ { "id": "kUvKwE5bb6v-aDmquYB91", "type": "arrow" + }, + { + "id": "EqT0Q5frh1UBL9rxtlgsl", + "type": "arrow" } ], - "updated": 1705272385235, + "updated": 1705314831100, "link": null, "locked": false }, @@ -625,7 +629,7 @@ "containerId": "wUuH6P3y0n2bIbcULauqL", "originalText": "postgres", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "arrow", @@ -1011,7 +1015,7 @@ "containerId": "YPhfkjzNcQxaFwAcVmQUU", "originalText": "Machines Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -1097,7 +1101,7 @@ "containerId": "n75eoynQQIjXOS72X19Jr", "originalText": "machines app", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "text", @@ -1209,7 +1213,7 @@ "containerId": "VwKFGNiRjQbbSavZfiH7u", "originalText": "Products Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", @@ -1337,8 +1341,8 @@ }, { "type": "rectangle", - "version": 715, - "versionNonce": 740626619, + "version": 716, + "versionNonce": 987585270, "isDeleted": false, "id": "4H8oN-ypeQCBWDzOVtVQW", "fillStyle": "cross-hatch", @@ -1347,7 +1351,7 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 4507.424838934794, + "x": 4499.710518343276, "y": -10259.21263273098, "strokeColor": "#1971c2", "backgroundColor": "#a5d8ff", @@ -1367,14 +1371,14 @@ "id": "X4Z5tuXdxKYRPhNP4Q9gb" } ], - "updated": 1705272407799, + "updated": 1705314810785, "link": null, "locked": false }, { "type": "text", - "version": 653, - "versionNonce": 2019115355, + "version": 654, + "versionNonce": 1886549866, "isDeleted": false, "id": "X4Z5tuXdxKYRPhNP4Q9gb", "fillStyle": "cross-hatch", @@ -1383,7 +1387,7 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 4595.935485379204, + "x": 4588.221164787686, "y": -10254.21263273098, "strokeColor": "#1971c2", "backgroundColor": "#a5d8ff", @@ -1395,8 +1399,8 @@ ], "frameId": null, "roundness": null, - "boundElements": null, - "updated": 1705272407799, + "boundElements": [], + "updated": 1705314810785, "link": null, "locked": false, "fontSize": 28, @@ -1407,12 +1411,12 @@ "containerId": "4H8oN-ypeQCBWDzOVtVQW", "originalText": "Products Container", "lineHeight": 1.25, - "baseline": 26 + "baseline": 23 }, { "type": "rectangle", - "version": 666, - "versionNonce": 2051126459, + "version": 668, + "versionNonce": 989402678, "isDeleted": false, "id": "sgmwBqZMfXCJB7d57hCMQ", "fillStyle": "solid", @@ -1421,7 +1425,7 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 4542.9173379611875, + "x": 4535.203017369669, "y": -10180.30181695024, "strokeColor": "#2f9e44", "backgroundColor": "#b2f2bb", @@ -1455,16 +1459,20 @@ { "id": "12ktETjUSPoRsMJk3PXBy", "type": "arrow" + }, + { + "id": "EqT0Q5frh1UBL9rxtlgsl", + "type": "arrow" } ], - "updated": 1705272424719, + "updated": 1705314831099, "link": null, "locked": false }, { "type": "text", - "version": 600, - "versionNonce": 1326260571, + "version": 601, + "versionNonce": 791647606, "isDeleted": false, "id": "EnUpsUDbjeySL8HabFf0F", "fillStyle": "cross-hatch", @@ -1473,7 +1481,7 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 4622.017585293755, + "x": 4614.303264702236, "y": -10129.821019783734, "strokeColor": "#2f9e44", "backgroundColor": "transparent", @@ -1485,8 +1493,8 @@ ], "frameId": null, "roundness": null, - "boundElements": null, - "updated": 1705272612955, + "boundElements": [], + "updated": 1705314810785, "link": null, "locked": false, "fontSize": 28, @@ -1501,8 +1509,8 @@ }, { "type": "text", - "version": 409, - "versionNonce": 1364548411, + "version": 410, + "versionNonce": 1297556714, "isDeleted": false, "id": "u1OuuXnvKcO5rBbQ9og-m", "fillStyle": "cross-hatch", @@ -1511,7 +1519,7 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 4560.876210469552, + "x": 4553.161889878033, "y": -10013.554034815204, "strokeColor": "#1e1e1e", "backgroundColor": "#a5d8ff", @@ -1523,8 +1531,8 @@ ], "frameId": null, "roundness": null, - "boundElements": null, - "updated": 1705272407799, + "boundElements": [], + "updated": 1705314810785, "link": null, "locked": false, "fontSize": 20, @@ -1575,8 +1583,8 @@ }, { "type": "text", - "version": 147, - "versionNonce": 582101749, + "version": 205, + "versionNonce": 659184426, "isDeleted": false, "id": "ZR8aurk5K826Erslgmf7s", "fillStyle": "cross-hatch", @@ -1585,8 +1593,8 @@ "roughness": 2, "opacity": 60, "angle": 0, - "x": 5058.167113867166, - "y": -10658.276875512694, + "x": 5108.239754933882, + "y": -10632.40602369569, "strokeColor": "#1e1e1e", "backgroundColor": "#a5d8ff", "width": 164.0625, @@ -1596,7 +1604,7 @@ "frameId": null, "roundness": null, "boundElements": [], - "updated": 1705272385236, + "updated": 1705314872222, "link": null, "locked": false, "fontSize": 20, @@ -1694,188 +1702,177 @@ "baseline": 19 }, { - "id": "EDr7aM0sLSQAwc4dMr2bn", "type": "text", - "x": 3612.942418000686, - "y": -10916.819587089509, - "width": 70.3125, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", - "fillStyle": "cross-hatch", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 60, - "groupIds": [], - "frameId": null, - "roundness": null, - "seed": 559448917, "version": 29, "versionNonce": 1557811349, "isDeleted": false, - "boundElements": null, + "id": "EDr7aM0sLSQAwc4dMr2bn", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 60, + "angle": 0, + "x": 3612.942418000686, + "y": -10916.819587089509, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 70.3125, + "height": 24, + "seed": 559448917, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], "updated": 1705232159376, "link": null, "locked": false, - "text": ":10000", "fontSize": 20, "fontFamily": 3, + "text": ":10000", "textAlign": "left", "verticalAlign": "top", - "baseline": 19, "containerId": null, "originalText": ":10000", - "lineHeight": 1.2 + "lineHeight": 1.2, + "baseline": 19 }, { - "id": "mexveX3hsuycJnV_xFlwn", "type": "text", - "x": 4219.394331660588, - "y": -11150.082041487154, - "width": 199.21875, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", - "fillStyle": "cross-hatch", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 60, - "groupIds": [], - "frameId": null, - "roundness": null, - "seed": 1039462229, "version": 135, "versionNonce": 2041282741, "isDeleted": false, - "boundElements": null, + "id": "mexveX3hsuycJnV_xFlwn", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 60, + "angle": 0, + "x": 4219.394331660588, + "y": -11150.082041487154, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 199.21875, + "height": 24, + "seed": 1039462229, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], "updated": 1705272532045, "link": null, "locked": false, - "text": "machines-app:3000", "fontSize": 20, "fontFamily": 3, + "text": "machines-app:3000", "textAlign": "left", "verticalAlign": "top", - "baseline": 19, "containerId": null, "originalText": "machines-app:3000", - "lineHeight": 1.2 + "lineHeight": 1.2, + "baseline": 19 }, { - "id": "nWQ6dNawezlmi4uYfgWBy", "type": "text", - "x": 4316.116079608326, - "y": -10700.817169101681, - "width": 222.65625, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", - "fillStyle": "cross-hatch", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 60, - "groupIds": [], - "frameId": null, - "roundness": null, - "seed": 1203968507, "version": 307, "versionNonce": 1772202133, "isDeleted": false, - "boundElements": null, - "updated": 1705272518661, - "link": null, - "locked": false, - "text": "products-app-1:3000", - "fontSize": 20, - "fontFamily": 3, - "textAlign": "left", - "verticalAlign": "top", - "baseline": 19, - "containerId": null, - "originalText": "products-app-1:3000", - "lineHeight": 1.2 - }, - { - "id": "GWChLBYhFI9kdropPUQeG", - "type": "text", - "x": 4153.042614670918, - "y": -10370.13837505832, - "width": 222.65625, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", + "id": "nWQ6dNawezlmi4uYfgWBy", "fillStyle": "cross-hatch", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 2, "opacity": 60, + "angle": 0, + "x": 4316.116079608326, + "y": -10700.817169101681, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 222.65625, + "height": 24, + "seed": 1203968507, "groupIds": [], "frameId": null, "roundness": null, - "seed": 1087064533, + "boundElements": [], + "updated": 1705272518661, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 3, + "text": "products-app-1:3000", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "products-app-1:3000", + "lineHeight": 1.2, + "baseline": 19 + }, + { + "type": "text", "version": 326, "versionNonce": 1726431547, "isDeleted": false, - "boundElements": null, - "updated": 1705272524495, - "link": null, - "locked": false, - "text": "products-app-2:3000", - "fontSize": 20, - "fontFamily": 3, - "textAlign": "left", - "verticalAlign": "top", - "baseline": 19, - "containerId": null, - "originalText": "products-app-2:3000", - "lineHeight": 1.2 - }, - { - "id": "12ktETjUSPoRsMJk3PXBy", - "type": "arrow", - "x": 4137.504982923524, - "y": -10821.943638734365, - "width": 400.6504031289887, - "height": 714.2560698272282, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", + "id": "GWChLBYhFI9kdropPUQeG", "fillStyle": "cross-hatch", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 2, "opacity": 60, + "angle": 0, + "x": 4153.042614670918, + "y": -10370.13837505832, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 222.65625, + "height": 24, + "seed": 1087064533, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1705272524495, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 3, + "text": "products-app-2:3000", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "products-app-2:3000", + "lineHeight": 1.2, + "baseline": 19 + }, + { + "type": "arrow", + "version": 157, + "versionNonce": 2081212475, + "isDeleted": false, + "id": "12ktETjUSPoRsMJk3PXBy", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 60, + "angle": 0, + "x": 4137.504982923524, + "y": -10821.943638734365, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 400.6504031289887, + "height": 714.2560698272282, + "seed": 1850086261, "groupIds": [], "frameId": null, "roundness": { "type": 2 }, - "seed": 1850086261, - "version": 157, - "versionNonce": 2081212475, - "isDeleted": false, - "boundElements": null, + "boundElements": [], "updated": 1705272481940, "link": null, "locked": false, - "points": [ - [ - 0, - 0 - ], - [ - 400.6504031289887, - 714.2560698272282 - ] - ], - "lastCommittedPoint": null, "startBinding": { "elementId": "IdWgQ7K35j_LT3pdoxDq0", "focus": -0.7214192287183446, @@ -1886,67 +1883,78 @@ "focus": -0.8623062595162034, "gap": 4.761951908674746 }, + "lastCommittedPoint": null, "startArrowhead": null, - "endArrowhead": "arrow" + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 400.6504031289887, + 714.2560698272282 + ] + ] }, { - "id": "MRa2-4EMmdkvVd8S4eA5x", "type": "text", - "x": 4019.049003102577, - "y": -10924.507953278779, - "width": 105.46875, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", - "fillStyle": "cross-hatch", - "strokeWidth": 2, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 60, - "groupIds": [], - "frameId": null, - "roundness": null, - "seed": 1901988059, "version": 72, "versionNonce": 2141549179, "isDeleted": false, - "boundElements": null, - "updated": 1705272500062, - "link": null, - "locked": false, - "text": "/machines", - "fontSize": 20, - "fontFamily": 3, - "textAlign": "left", - "verticalAlign": "top", - "baseline": 19, - "containerId": null, - "originalText": "/machines", - "lineHeight": 1.2 - }, - { - "id": "9D7Gw2OyaxH8PvxvmUAw1", - "type": "text", - "x": 4021.137676009853, - "y": -10843.048474889683, - "width": 105.46875, - "height": 24, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#a5d8ff", + "id": "MRa2-4EMmdkvVd8S4eA5x", "fillStyle": "cross-hatch", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 2, "opacity": 60, + "angle": 0, + "x": 4019.049003102577, + "y": -10924.507953278779, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 105.46875, + "height": 24, + "seed": 1901988059, "groupIds": [], "frameId": null, "roundness": null, - "seed": 1419857851, + "boundElements": [], + "updated": 1705272500062, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 3, + "text": "/machines", + "textAlign": "left", + "verticalAlign": "top", + "containerId": null, + "originalText": "/machines", + "lineHeight": 1.2, + "baseline": 19 + }, + { + "type": "text", "version": 46, "versionNonce": 1278607099, "isDeleted": false, + "id": "9D7Gw2OyaxH8PvxvmUAw1", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 60, + "angle": 0, + "x": 4021.137676009853, + "y": -10843.048474889683, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "width": 105.46875, + "height": 24, + "seed": 1419857851, + "groupIds": [], + "frameId": null, + "roundness": null, "boundElements": [ { "id": "fz4-v3BbLpHUlDxmoU9oC", @@ -1956,15 +1964,67 @@ "updated": 1705272581652, "link": null, "locked": false, - "text": "/products", "fontSize": 20, "fontFamily": 3, + "text": "/products", "textAlign": "left", "verticalAlign": "top", - "baseline": 19, "containerId": null, "originalText": "/products", - "lineHeight": 1.2 + "lineHeight": 1.2, + "baseline": 19 + }, + { + "id": "EqT0Q5frh1UBL9rxtlgsl", + "type": "arrow", + "x": 4906.900924831709, + "y": -10109.38787249232, + "width": 251.19780028788045, + "height": 720.2115128111836, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "#a5d8ff", + "fillStyle": "cross-hatch", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "seed": 1208906346, + "version": 136, + "versionNonce": 1524190006, + "isDeleted": false, + "boundElements": null, + "updated": 1705314835726, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + 251.19780028788045, + -720.2115128111836 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "sgmwBqZMfXCJB7d57hCMQ", + "focus": 0.8962818637395497, + "gap": 1.0045081338193995 + }, + "endBinding": { + "elementId": "wUuH6P3y0n2bIbcULauqL", + "focus": 0.8699732884032452, + "gap": 2.5818794988804257 + }, + "startArrowhead": null, + "endArrowhead": "arrow" } ], "appState": { diff --git a/proxy/envoy.yaml b/proxy/envoy.yaml index 702d0e7..8747de1 100644 --- a/proxy/envoy.yaml +++ b/proxy/envoy.yaml @@ -55,12 +55,7 @@ static_resources: - endpoint: address: socket_address: - address: products-app-1 - port_value: 3000 - - endpoint: - address: - socket_address: - address: products-app-2 + address: products-app port_value: 3000 admin: access_log_path: "/dev/null"