Git Product home page Git Product logo

ocm-ramen-samples's Introduction

ocm-ramen-samples

OCM Stateful application samples, including Ramen resources.

Initial setup

  1. Clone this git repository to get started:

    git clone https://github.com/RamenDR/ocm-ramen-samples.git
    cd ocm-ramen-samples
    
  2. Switch kubeconfig to point to the OCM Hub cluster

    kubectl config use-context hub
    
  3. Create DRClusters and DRPolicy

    When using the ramen testing environment this is not needed, but if you are using your own Kubernetes clusters you need to create the resources.

    Modify the DRCluster and DRpolicy resources in the ramen directory to match the actual cluster names in your environment, and apply the kustomization:

    kubectl apply -k ramen
    

    This creates DRPolicy and DRCluster resources in the cluster namespace that can be viewed using:

    kubectl get drcluster,drpolicy
    
  4. Setup the common OCM channel resources on the hub:

    kubectl apply -k channel
    

    This creates a Channel resource in the ramen-samples namespace and can be viewed using:

    kubectl get channel ramen-gitops -n ramen-samples
    

Sample applications

In the workloads directory provides samples that can be deployed on Kubernetes and OpenShift.

  • deployment - busybox deployment
  • kubevirt
    • vm-pvc - PVC based VM
    • vm-dv - DataVolume based VM
    • vm-dvt - DataVolumeTemplate based VM

Deploying a sample application

In the example we use the busybox deployment for Kubernetes regional DR environment using RBD storage:

subscription/deployment-k8s-regional-rbd

This application is deployed in the deployment-rbd namespace on the hub and managed clusters.

You can use other overlays to deploy on other cluster types or use different storage class. You can also create your own overlays based on the examples.

  1. Deploy an OCM application subscription on hub:

    kubectl apply -k subscription/deployment-k8s-regional-rbd
    

    This creates the required Subscription, Placement, and ManagedClusterSetBinding resources for the deployment in the deployment-rbd namespace and can be viewed using:

    kubectl get subscription,placement -n deployment-rbd
    
  2. Inspect subscribed resources from the channel created in the same namespace on the ManagedCluster selected by the Placement.

    The busybox deployment Placement status can be viewed on the hub using:

    kubectl get placement placement -n deployment-rbd
    

    The Busybox deployment subscribed resources, like the pod and the PVC can be viewed on the ManagedCluster using (example ManagedCluster dr1):

    kubectl get pod,pvc -n deployment-rbd --context dr1
    

Undeploying a sample application

To undeploy an application delete the subscription overlay used to deploy the application:

kubectl delete -k subscription/deployment-k8s-regional-rbd

Enable DR for a deployed application

  1. Change the Placement to be reconciled by Ramen

    kubectl annotate placement placement -n deployment-rbd \
       cluster.open-cluster-management.io/experimental-scheduling-disable=true
    
  2. Deploy a DRPlacementControl resource for the OCM application on the hub, for example:

    kubectl apply -k dr/deployment-k8s-regional-rbd
    

    This creates a DRPlacementControl resource for the busybox deployment in the deployment-rbd namespace and can be viewed using:

    kubectl get drpc -n deployment-rbd
    

    At this point the placement of the application is managed by Ramen.

Disable DR for a DR enabled application

  1. Ensure the placement is pointing to the cluster where the workload is currently placed to avoid data loss if OCM moves the application to another cluster.

    The sample placement does not require any change, but if you are using an application created by OpenShift Console, you may need to change the cluster name in the placement.

  2. Delete the drpc resource for the OCM application on the hub:

    kubectl delete -k dr/deployment-k8s-regional-rbd
    

    This deletes the DRPlacementControl resource for the busybox deployment, disabling replication and removing replicated data.

  3. Change the Placement to be reconciled by OCM

    kubectl annotate placement placement -n deployment-rbd \
        cluster.open-cluster-management.io/experimental-scheduling-disable-
    

    At this point the application is managed again by OCM.

ocm-ramen-samples's People

Contributors

hatfieldbrian avatar johnsimcall avatar netzzer avatar nirs avatar raghavendra-talur avatar rakeshgm avatar shyamsundarr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.