You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by iu...@apache.org on 2022/04/18 08:35:10 UTC

[brooklyn-docs] branch master updated: Docs for nginx-multi-upstream-sync policy

This is an automated email from the ASF dual-hosted git repository.

iuliana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-docs.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c4b845f Docs for nginx-multi-upstream-sync policy
     new deaec3c8 Merge pull request #350 from algairim/policy/nginx-multi-upstream-sync
2c4b845f is described below

commit 2c4b845f87076ac22ed0d05944866170f99cc9e8
Author: Mykola Mandra <my...@cloudsoft.io>
AuthorDate: Thu Apr 14 14:57:14 2022 +0100

    Docs for nginx-multi-upstream-sync policy
    
    Signed-off-by: Mykola Mandra <my...@cloudsoft.io>
---
 guide/blueprints/policies/available_policies.md | 92 ++++++++++++++++++++++++-
 1 file changed, 91 insertions(+), 1 deletion(-)

diff --git a/guide/blueprints/policies/available_policies.md b/guide/blueprints/policies/available_policies.md
index d1f4200c..3af01fce 100644
--- a/guide/blueprints/policies/available_policies.md
+++ b/guide/blueprints/policies/available_policies.md
@@ -182,7 +182,97 @@ The CreateUserPolicy Attaches to an Entity and monitors for the addition of a lo
 
 This is similar to the CreateUserPolicy.  It will monitor the addition of WinRmMachineLocation to an entity and then create a sensor advertising the administrative user's credentials.
 
-
+### Synchronization Policies
+
+#### nginx-multi-upstream-sync Policy
+
+*nginx-multi-upstream-sync* policy is designed to be used in combination with `nginx-multi` type that allows to achieve blue-green deployment.
+Here is an example:
+
+1. Deploy cluster of apps version 1 with the following blueprint:
+
+    ```yaml
+    name: My Application
+    services:
+      - type: nginx-multi:1.1.0-SNAPSHOT
+        id: my-nginx-multi
+      - type: org.apache.brooklyn.entity.webapp.DynamicWebAppCluster
+        id: my-app-cluster-v1
+        name: App Cluster v1
+        brooklyn.config:
+          latch.launch: $brooklyn:component("my-nginx-multi").attributeWhenReady("service.isUp")
+          dynamiccluster.quarantineFailedEntities: false
+          dynamiccluster.memberspec:
+            '$brooklyn:entitySpec':
+              type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+              brooklyn.config:
+                wars.root: https://repo1.maven.org/maven2/org/apache/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.8.0-incubating/brooklyn-example-hello-world-sql-webapp-0.8.0-incubating.war
+        brooklyn.policies:
+          - type: nginx-multi-upstream-sync
+            brooklyn.config:
+              group: $brooklyn:component("my-app-cluster-v1")
+              sensorsToTrack:
+                - service.isUp
+              nginxNode: $brooklyn:component("my-nginx-multi")
+              groupName: v1
+    ```
+
+2. Navigate to NGINX effectors and render routing for `v1.myapp.com` pointing to v1 app group. `v1.myapp.com` is an
+   endpoint to test cluster of apps version 1.
+    * logicalNme `v1`
+    * hostName `v1.myapp.com`
+    * groupName `v1`
+3. Find IP address of the NGINX in sensors and map it to `v1.myapp.com` in `/etc/hosts` and load `v1.myapp.com` in the
+   browser on the machine where `/etc/hosts` is modified to test version 1, e.g. `11.22.33.44 v1.myapp.com`.
+4. Render routing for `myapp.com` pointing to v1 app group. `myapp.com` in this example is a production endpoint.
+    * logicalNme `production`
+    * hostName `myapp.com`
+    * groupName `v1`
+5. Map IP address of the NGINX to myapp.com in `/etc/hosts` and load `myapp.com` in the browser on the machine where
+   `/etc/hosts` is modified to verify that production endpoint loads version 1.
+6. Deploy cluster of apps version 2 alongside version 1 in the same application:
+
+    ```yaml
+    services:
+      - type: org.apache.brooklyn.entity.webapp.DynamicWebAppCluster
+        id: my-app-cluster-v2
+        name: App Cluster v2
+        brooklyn.config:
+          latch.launch: $brooklyn:component("my-nginx-multi").attributeWhenReady("service.isUp")
+          dynamiccluster.quarantineFailedEntities: false
+          dynamiccluster.memberspec:
+            '$brooklyn:entitySpec':
+              type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+              brooklyn.config:
+                wars.root: https://repo1.maven.org/maven2/org/apache/brooklyn/example/brooklyn-example-hello-world-sql-webapp/1.0.0/brooklyn-example-hello-world-sql-webapp-1.0.0.war
+        brooklyn.policies:
+          - type: nginx-multi-upstream-sync
+            brooklyn.config:
+              group: $brooklyn:component("my-app-cluster-v2")
+              sensorsToTrack:
+                - service.isUp
+              nginxNode: $brooklyn:component("my-nginx-multi")
+              groupName: v2
+    ```
+
+   ***Hint:*** add as a child to a deployed application.
+
+7. Render routing for `v2.myapp.com` pointing to v2 app group. `v2.myapp.com` is an endpoint to test cluster of apps
+   version 2.
+    * logicalNme `v2`
+    * hostName `v2.myapp.com`
+    * groupName `v2`
+8. Map IP address of the NGINX to `v2.myapp.com` in `/etc/hosts` and load `v2.myapp.com` in the browser on the machine
+   where `/etc/hosts` is modified to test version 2.
+9. Render routing for `myapp.com` pointing to v2 app group to switch the app version at production endpoint.
+    * logicalNme `production`
+    * hostName `myapp.com`
+    * groupName `v2`
+10. Refresh myapp.com in the browser on the machine where `/etc/hosts` is modified to verify that production endpoint
+    loads version 2.
+11. Try to resize cluster of app version 2 and see routing configuration updated in activities of nginx-multi node.
+
+***Note***, `/etc/hosts` is used to simplify demonstration of the policy in a blue-green deployment.
 
 Writing a Policy
 ----------------