diff --git a/README.md b/README.md
index de16e32..3638070 100644
--- a/README.md
+++ b/README.md
@@ -116,7 +116,7 @@ Added advantages of building over Kubernetes,
### Using dashboard
-The dashboard/platform is called Bridge
+The dashboard is called **Bridge**
[Bridge url](`http://localhost:4000`)
@@ -127,12 +127,31 @@ The dashboard/platform is called Bridge
- Each app will be having an dedicated url to Discovery.
- Clients use this dedicated endpoint url to get the app's endpoint. (As specified in `Approach` section).
+
+
#### Deploying and managing an app
- When deploying an app, we have to specify the docker image name (which should be public as of now).
- Bridge shows each app's deployment logs/activites.
- Deployment CRUD operations to app are available as button clicks.
+
+
+#### Fetching latest server URL from Discovery
+
+- Client will hit Discovery API, and get the latest server endpoint url.
+
+ ```
+ GET - http://localhost:4000/api/get-endpoint?app_name=nightwatch
+
+ RESPONSE -
+ {
+ "endpoint": "nightwatch.minikube.com/9d00cc18"
+ }
+
+ ```
+
+
## Demo time
### Things to note
diff --git a/doc_assets/create-app.gif b/doc_assets/create-app.gif
new file mode 100644
index 0000000..446720a
Binary files /dev/null and b/doc_assets/create-app.gif differ
diff --git a/doc_assets/scale-app.gif b/doc_assets/scale-app.gif
new file mode 100644
index 0000000..1a1f108
Binary files /dev/null and b/doc_assets/scale-app.gif differ
diff --git a/lib/discovery/bridge/bridge_utils.ex b/lib/discovery/bridge/bridge_utils.ex
index 5a0dd2b..82df4b1 100644
--- a/lib/discovery/bridge/bridge_utils.ex
+++ b/lib/discovery/bridge/bridge_utils.ex
@@ -63,4 +63,16 @@ defmodule Discovery.Bridge.BridgeUtils do
deployment_details
|> DeployManager.create()
end
+
+ @doc """
+ Get latest deployment details of an app
+
+ Returns {:ok, term} | {:error, reason}
+ """
+ @spec get_latest_deployment(String.t()) :: map()
+ def get_latest_deployment(app_name) do
+ app_name
+ |> get_deployment_data()
+ |> List.first()
+ end
end
diff --git a/lib/discovery/deploy/deploy_utils.ex b/lib/discovery/deploy/deploy_utils.ex
index ed3fc86..37fb4ad 100644
--- a/lib/discovery/deploy/deploy_utils.ex
+++ b/lib/discovery/deploy/deploy_utils.ex
@@ -9,7 +9,8 @@ defmodule Discovery.Deploy.DeployUtils do
@type t :: %DeployUtils{
app_name: String.t(),
- app_image: String.t()
+ app_image: String.t(),
+ replicas: Integer
}
@type app :: %{
@@ -20,7 +21,8 @@ defmodule Discovery.Deploy.DeployUtils do
defstruct(
app_name: "",
- app_image: ""
+ app_image: "",
+ replicas: 1
)
@doc """
@@ -35,6 +37,7 @@ defmodule Discovery.Deploy.DeployUtils do
app_details = %{
app_name: deployment_details.app_name,
app_image: deployment_details.app_image,
+ replicas: deployment_details.replicas,
uid: uid
}
@@ -196,6 +199,7 @@ defmodule Discovery.Deploy.DeployUtils do
String.replace(deploy_template, "APP_NAME", app.app_name)
|> String.replace("UID", app.uid)
|> String.replace("APP_IMAGE", app.app_image)
+ |> String.replace("APP_REPLICA", "#{app.replicas}")
case File.open("minikube/discovery/#{app.app_name}/#{app.app_name}-#{app.uid}/deploy.yml", [
:write,
diff --git a/lib/discovery_web/live/page_live.ex b/lib/discovery_web/live/page_live.ex
index a213ef9..7f758ae 100644
--- a/lib/discovery_web/live/page_live.ex
+++ b/lib/discovery_web/live/page_live.ex
@@ -12,6 +12,7 @@ defmodule DiscoveryWeb.PageLive do
selected_app: nil,
create_modal_display: "none",
deploy_modal_display: "none",
+ scale_modal_display: "none",
create_app_warning: "none",
deploy_app_warning: "none",
modal_input?: true,
@@ -52,7 +53,30 @@ defmodule DiscoveryWeb.PageLive do
if socket.assigns.modal_input? do
%{
app_name: socket.assigns.selected_app,
- app_image: app_image
+ app_image: app_image,
+ replicas: 1
+ }
+ |> create_deployment()
+ end
+
+ socket =
+ socket
+ |> assign(modal_input?: false)
+
+ {:noreply, socket}
+ end
+
+ @impl true
+ def handle_event("update-replica", %{"app-replica" => replica_count} = _params, socket) do
+ latest_deployment =
+ socket.assigns.selected_app
+ |> BridgeUtils.get_latest_deployment()
+
+ if socket.assigns.modal_input? do
+ %{
+ app_name: socket.assigns.selected_app,
+ app_image: latest_deployment["image"],
+ replicas: replica_count |> String.to_integer()
}
|> create_deployment()
end
@@ -109,6 +133,22 @@ defmodule DiscoveryWeb.PageLive do
{:noreply, socket}
end
+ @impl true
+ def handle_event("show-scale-modal", _params, socket) do
+ display =
+ case socket.assigns.scale_modal_display do
+ "none" -> "block"
+ "block" -> "none"
+ _ -> "none"
+ end
+
+ socket =
+ socket
+ |> assign(scale_modal_display: display, modal_input?: true)
+
+ {:noreply, socket}
+ end
+
@impl true
def handle_event("hide-modal", _params, socket) do
socket =
@@ -117,6 +157,7 @@ defmodule DiscoveryWeb.PageLive do
create_modal_display: "none",
deploy_modal_display: "none",
deploy_app_warning: "none",
+ scale_modal_display: "none",
modal_input?: true
)
@@ -147,6 +188,7 @@ defmodule DiscoveryWeb.PageLive do
assign(
socket,
deploy_modal_display: "none",
+ scale_modal_display: "none",
deploy_app_warning: "none",
selected_app_details: selected_app_details,
apps: get_apps()
@@ -175,7 +217,7 @@ defmodule DiscoveryWeb.PageLive do
Process.send_after(
self(),
{"deployment-created", %{status: deployment_status, app_name: app_name}},
- 2000
+ 10_000
)
end
end
diff --git a/lib/discovery_web/live/page_live.html.leex b/lib/discovery_web/live/page_live.html.leex
index bfd11a7..807ea52 100644
--- a/lib/discovery_web/live/page_live.html.leex
+++ b/lib/discovery_web/live/page_live.html.leex
@@ -82,6 +82,45 @@
+
+ Please enter the replica count for the latest deployment.
+
+ Update Replica Count
+
+