Command-Line Interface
Learn about using Trilio for Kubernetes from the command-line interface
Last updated
Learn about using Trilio for Kubernetes from the command-line interface
Last updated
In order to get started with Trilio for Kubernetes in your environment, the following steps will be performed:
Install a compatible CSI Driver
Create a T4K Target - Location where backups will be stored.
Create a retention policy (Optional) - To specify how long to keep the backups for.
Run Example
Label Example
Helm Example
Operator Example
Namespace Example
Trilio for Kubernetes requires a compatible Container Storage Interface (CSI) driver that provides the Snapshot feature.
You should check the to select a driver appropriate for your backend storage solution. See the selected CSI driver's documentation for details on the installation of the driver in your cluster.
Create a secret containing the credentials for data stores to store backups. An example is provided below.
Supported values for S3 vendors include:
An Amazon S3 target example is provided below:
While the example backup custom resources created by following this Getting Started page can be deleted manually via kubectl
commands, Trilio also provides backup retention capability - to automatically delete the backups based on defined time boundaries.
Note: With the above configuration, policy would get created in default namespace unless specified.
This section covers backup and restores examples based on Labels, Helm charts, Operators, and Namespaces
Note:
Backup and BackupPlan should be in the same namespace.
For the restore operation, the resources will get restored in the namespace where restore CR is created.
Specifying backupPlan information in the restore manifest will automatically select the latest successful backup for that backupPlan.
The following sections will create a sample application (tag it with labels), backup the application via labels, and then restore the application.
The following steps will be performed.
Create a sample MySQL application
Create a BackupPlan CR that specifies the MySQL application to protect via labels
Create a Backup CR with reference to the BackupPlan CR
Create a Restore CR with reference to the Backup CR.
Create the following file as mysql.yaml. Note the labels used to tag the different components of the application.
Run below command to access the mysql DB using a mysql client from the host. This command works for "default" namespace. Please change the namespace context or use "-n <namespace>" if the demo app is installed in some other namespace.
Create a BackupPlan CR that references the application created in the previous step via matching labels in the same namespace where the application resides.
Create a Backup CR to protect the BackupPlan. Type
of the backup can be either full or incremental.
Note: The first backup into a target location will always be a Full backup.
Finally, create the Restore CR to restore the Backup in the same namespace where the Backup CR is created. In the example provided below, mysql-label-backup is being restored into the "default" namespace.
Note: If restoring into the same namespace, ensure that the original application components have been removed.
The following sections will create a sample application via Helm, back up the application via Helm selector fields, and then restore the application.
The following steps will be performed.
Create a cockroachdb instance using Helm
Create a BackupPlan CR that specifies the cockroachdb application to protect.
Create a Backup CR with a reference to the BackupPlan CR
Create a Restore CR with a reference to the Backup CR.
In this example, we will use Helm Tooling to create a "cockroachdb" application.
Run the following commands against a Kubernetes cluster. Use the attached cockroachdb_-values.yaml_ file for the installation by copying it to your local directory.
After running helm install, confirm the installation was successful by running helm ls
Use the following to create a BackupPlan. Ensure the name of the release you specify matches the output from the helm ls command in the previous step.
Use the following content to create a backup CR.
After the backup has completed successfully, create a Restore CR to restore the application in the same namespace where BackupPlan and Backup CRs are created.
Before restoring the app, we need to clean the existing app. This is required cluster level resources of the app can create conflict during restore operation.
Similar to the Label example above:
Note: If restoring into the same namespace, ensure that the original application components have been removed. Especially the PVC of application are deleted.
The following steps will be performed.
Install a sample etcd Operator
Create a etcd cluster
Create a BackupPlan CR that specifies the etcd application to protect.
Create a Backup CR with a reference to the BackupPlan CR
Create a Restore CR with a reference to the Backup CR.
We are demonstrating standard 'etcd-operator' here. First we need to deploy the operator using it's helm chart. Then we need to deploy etcd cluster. Following are the commands for it.
Create 'BackupPlan' resource to protect 'etcd-operator' and it's clusters. Use the following yaml definition.
'operatorResourceName': This field holds the name of the operator whose backup we are going to take. In this case our operator name is "demo-etcd-cluster"
'operatorResourceSelector': This field selects the operator resources (whose backup we are going to take) using labels. In this case, operator is 'etcd-operator' and all it's resources like pods, services, deployments have a unique label - "release: trilio-demo-etcd-operator"
'applicationResourceSelector': This field selects the resources of the application launched using the operator. In this case, etcd-cluster is the application launched using etcd-operator. All the resources of this application have a unique label - "app: etcd"
Take a backup of above 'BackupPlan'. Use following YAML definition to create a 'Backup' resource.
After the backup completes successfully, you can perform the Restore of it.
To restore the etcd-operator and it's clusters from the above backup, use the following YAML definition.
Note: If restoring into the same namespace, ensure that the original application components have been removed.
Create a namespace called 'wordpress'
Use helm to deploy a wordpress application into the namespace.
Perform a backup of the namespace
Delete the namespace/application
Create a new namespace 'wordpress-restore'
Perform a Restore of the namespace
Create the namespace called 'wordpress'
Install the wordpress Helm Chart
You can launch the wordpress app via a browser and make changes to the sample page to ensure changes are captured when you restore.
Create a backupPlan to backup the namespace
Use the following YAML to build the Backup CR
Perform restore of the namespace backup
Validate the pods are up and running after restore completes.
Finally, confirm the changes on the WordPress launch pages that were made earlier.
Please use one of the provided in the Custom Resource Definition section as a template for creating an NFS, Amazon S3, or any S3-compatible storage target.
Note: With the above configuration, the target would get created in the current user namespace unless specified. Also, additional information on Bucket permissions can be found in the ****
More information on the Retention Policy spec can be found in the section. A retention policy is referenced in the .
More details about CRDs and their usage/explanation can be found in the .
Note: If restoring to another cluster (migration scenario), ensure that Trilio for Kubernetes is running in the remote namespace/cluster as well. To restore into a new cluster (where the Backup CR does not exist), source.type
must be set to location. Please refer to the to view a restore by location example.
Note: If restoring into another namespace in the same cluster, ensure that the resources which cannot be shared, like ports, should be freed, or transformation should be used to avoid conflict. More information about transformation can be found at .
Note: If restoring to another cluster (migration scenario), ensure that Trilio for Kubernetes is running in the remote namespace/cluster as well. To restore into a new cluster (where the Backup CR does not exist), source.type
must be set to location. Please refer to the to view a restore by location example.
Note: If restoring to another cluster (migration scenario), ensure that Trilio for Kubernetes is running in the remote namespace/cluster as well. To restore into a new cluster (where the Backup CR does not exist), source.type
must be set to location. Please refer to the to view a restore by location example.