Increase Application Resilience

Typically, applications deployed into production environments have resiliency requirements. This could be a simple requirement of having multiple instances of the application running to protect against localized failures, or a complex requirement of having a geographically distributed application to provide clear fault domain boundaries between regions.

You can define the resiliency requirements for your Space so that when you deploy an application to the Space, you receive these resilience characteristics for your application.

This topic describes how to increase the resiliency of an application in two ways:

  • Increase the number of application instances within a region: This will increase the number of instances of your application running by adding a new cluster within your availability target. This protects your application from issues with a given cluster, but not within a given region.

  • Increase the number of application instances across regions: This will increase the number of instances of your application running by adding a new cluster to a new Availability Target in an additional region.

Before you begin

When deploying your application, you deployed your application with one of two options for backing services, Bitnami or AWS. Either backing service will work for this example. However, Bitnami services are not replicated between replicas. The result of increasing application resiliency while using Bitnami services will be isolated backing services, which will result in a split brain application. Using AWS will provide a shared backing service for all application instances and will provide the most optimal scenario for this example.

Increase Application Availability within a Single Region

Increasing application resiliency within a region is accomplished by increasing the number of replicas within an availability target. In the Availability Target context, a replica is an individual Kubernetes cluster.

The steps provided in the Getting Started guide deploys an application to a Space that uses the Tanzu provided all-regions.tanzu.vmware.com availability target which includes all clusters regardless of region. To increase the resiliency of an application within a single region, do the following:

  1. Create an Availability Target for the region you created the cluster in using the getting starting guide using the Manage Availability Target How To

  2. Use the create a cluster documentation to create a new cluster in the same VPC and region using the default Run clustergroup. This will add a second cluster to the region based availability target you created above.

  3. Update the Availability Target to use the region based availability target and number of replicas from 1 to 2 to schedule the Space to the newly created cluster.

    UI-based steps
    Do the following on the Tanzu Platform hub:
    1. On the left navigation pane, scroll down and expand Application Spaces.
    2. Click Spaces.
    3. Click the vertical ellipsis next to your Space and select Edit Space
    4. In the Availability Targets drop down, change the availability target from all-regions.tanzu.vmware.com to the new region based availability target created above.
    5. On Availability Targets, change the number of Replicas from 1 to 2
    6. Click Update Space to apply the changes.
    Tanzu CLI-based steps
    1. Set your Tanzu CLI context. Run the following command to authenticate to Tanzu Platform.
      tanzu login
      
    2. Set the scope to your project.

      1. Run the following command to view the available list of projects.
        tanzu project list
        
      2. Run the following command to set the project context.
        tanzu project use <project name>
        
    3. Update the space.yaml manifest you used in Create a Space to change the replica count from 1 to 2 for your availability target:

      apiVersion: spaces.tanzu.vmware.com/v1alpha1
      kind: Space
      metadata:
        name: my-first-space
        namespace: default
      spec:
      template:
        spec:
          profiles:
          - name: spring.tanzu.vmware.com
      availabilityTargets:
      - name: at-us-east-1
        replicas: 2
      updateStrategy:
        type: RollingUpdate
      
    4. Apply the manifest to create the Space in your project.

      tanzu deploy --only space.yaml
      

When you created a new cluster in the cluster group, the configuration of the cluster group was applied to the new cluster, resulting in the two clusters having the same configuration. The Availability Target then detects the new cluster in the region, and makes it available as an additional replica target for your space. By changing the replica count from one to two on the Space, your deployed Where for Dinner? application will be deployed to the newly created cluster, giving your application resilience to failures within a single cluster.

Be sure to check out the topology of your Space to see the second instance of your application running!

Increase application availability in a second region

Increasing your application’s resiliency to be resistant to faults across regions is accomplished by adding an second Availability Target to your Space. This will ensure that your application is replicated across regions so that a failure of a region will not impact your applications availability.

To increase your application resiliency across a second region, do the following:

  1. Use the create a vpc documentation to create a new VPC in AWS in a second region that is different from your existing region.
  2. Use the create a cluster documentation to create a new cluster in the newly created VPC using the default Run clustergroup.
  3. Use the create an availability target documentation to create a new availability target, specifying the new region.
  4. Add the new Availability Target to the Space

    UI-based steps
    Do the following on the Tanzu Platform hub:
    1. On the left navigation pane, scroll down to and expand Application Spaces.
    2. Click Spaces.
    3. Click the vertical ellipsis next to your Space and select Edit Space
    4. Under Availability Targets, click + Add availability target and select your new availability target from the drop down. Since we only have 1 cluster in the new availability target, enter 1 replica.
    5. Click Update Space to apply the changes.
    Tanzu CLI-based steps
    1. Set your Tanzu CLI context. Run the following command to authenticate to Tanzu Platform.
      tanzu login
      
    2. Set the scope to your project.

      1. Run the following command to view the available list of projects.
        tanzu project list
        
      2. Run the following command to set the project context.
        tanzu project use <project name>
        
    3. Update the space.yaml manifest you used in Create a Space to add the new Availability Target to the Space with a replica count of 1:

      apiVersion: spaces.tanzu.vmware.com/v1alpha1
      kind: Space
      metadata:
      name: my-first-space
      namespace: default
      spec:
      template:
      spec:
        profiles:
        - name: spring.tanzu.vmware.com
      availabilityTargets:
      - name: at-us-east-1
      replicas: 2
      - name: at-us-west-1
      replicas: 1
      updateStrategy:
      type: RollingUpdate
      
    4. Apply the manifest to create the Space in your project.

      tanzu deploy --only space.yaml
      

By adding an Availability Target to your Space, the deployed Where for Dinner? application will automatically be deployed to the new Availability Target, giving your application resilience to failures within a region.

Be sure to check out the topology of your Space to see the second region of your application running!

check-circle-line exclamation-circle-line close-line
Scroll to top icon