2017-08-02 17:27:17 +00:00
# Heptio Ark
**Maintainers:** [Heptio][0]
[![Build Status][1]][2]
## Overview
2018-02-14 18:02:35 +00:00
Ark gives you tools to back up and restore your Kubernetes cluster resources and persistent volumes. Ark lets you:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
* Take backups of your cluster and restore in case of loss.
* Copy cluster resources across cloud providers. NOTE: Cloud volume migrations are not yet supported.
* Replicate your production environment for development and testing environments.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
Ark consists of:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
* A server that runs on your cluster
* A command-line client that runs locally
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
## Getting started
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
The following example sets up the Ark server and client, then backs up and restores a sample application.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
For simplicity, the example uses Minio, an S3-compatible storage service that runs locally on your cluster. See [Set up Ark with your cloud provider][3] for how to run on a cloud provider.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
### Prerequisites
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
* Access to a Kubernetes cluster, version 1.7 or later. Version 1.7.5 or later is required to run `ark backup delete` .
* A DNS server on the cluster
* `kubectl` installed
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
### Download
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
Clone or fork the Ark repository:
2017-08-02 17:27:17 +00:00
```
git clone git@github.com:heptio/ark.git
```
2018-02-14 18:02:35 +00:00
NOTE: Make sure to check out the appropriate version. We recommend that you check out the latest tagged version. The master branch is under active development and might not be stable.
2017-08-15 17:03:43 +00:00
2018-02-14 18:02:35 +00:00
### Set up server
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Start the server and the local storage service. In the root directory of Ark, run:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```bash
kubectl apply -f examples/common/00-prereqs.yaml
kubectl apply -f examples/minio/
kubectl apply -f examples/common/10-deployment.yaml
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
NOTE: If you get an error about Config creation, wait for a minute, then run the commands again.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Deploy the example nginx application:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```bash
kubectl apply -f examples/nginx-app/base.yaml
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Check to see that both the Ark and nginx deployments are successfully created:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
kubectl get deployments -l component=ark --namespace=heptio-ark
kubectl get deployments --namespace=nginx-example
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
### Install client
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
For this example, we recommend that you [download a pre-built release][26].
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
You can also [build from source][7].
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
Make sure that you install somewhere in your `$PATH` .
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
### Back up
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Create a backup for any object that matches the `app=nginx` label selector:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
ark backup create nginx-backup --selector app=nginx
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Simulate a disaster:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
kubectl delete namespace nginx-example
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. To check that the nginx deployment and service are gone, run:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
kubectl get deployments --namespace=nginx-example
kubectl get services --namespace=nginx-example
kubectl get namespace/nginx-example
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
You should get no results.
NOTE: You might need to wait for a few minutes for the namespace to be fully cleaned up.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
### Restore
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Run:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
ark restore create nginx-backup
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
1. Run:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
ark restore get
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
After the restore finishes, the output looks like the following:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
NAME BACKUP STATUS WARNINGS ERRORS CREATED SELECTOR
nginx-backup-20170727200524 nginx-backup Completed 0 0 2017-07-27 20:05:24 +0000 UTC < none >
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
NOTE: The restore can take a few moments to finish. During this time, the `STATUS` column reads `InProgress` .
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
After a successful restore, the `STATUS` column is `Completed` , and `WARNINGS` and `ERRORS` are 0. All objects in the `nginx-example` namespacee should be just as they were before you deleted them.
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
If there are errors or warnings, you can look at them in detail:
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
```
ark restore describe < RESTORE_NAME >
```
2017-11-28 21:45:22 +00:00
2018-02-14 18:02:35 +00:00
For more information, see [the debugging information][18].
2017-11-28 21:45:22 +00:00
2018-02-14 18:02:35 +00:00
### Clean up
2017-11-28 21:45:22 +00:00
2018-02-20 14:41:17 +00:00
Delete any backups you created:
```
kubectl delete -n heptio-ark backup --all
```
Before you continue, wait for the following to show no backups:
```
ark backup get
```
2018-02-14 18:02:35 +00:00
To remove the Kubernetes objects for this example from your cluster, run:
2017-11-28 21:45:22 +00:00
2018-02-14 18:02:35 +00:00
```
kubectl delete -f examples/common/
kubectl delete -f examples/minio/
kubectl delete -f examples/nginx-app/base.yaml
```
2017-08-02 17:27:17 +00:00
2018-02-14 18:02:35 +00:00
## More information
[The documentation][29] provides detailed information about building from source, architecture, extending Ark, and more.
2017-08-02 17:27:17 +00:00
## Troubleshooting
2017-09-21 05:15:33 +00:00
If you encounter any problems that the documentation does not address, [file an issue][4] or talk to us on the [Kubernetes Slack team][25] channel `#ark-dr` .
2017-08-02 17:27:17 +00:00
## Contributing
Thanks for taking the time to join our community and start contributing!
2017-08-04 18:12:24 +00:00
Feedback and discussion is available on [the mailing list][24].
2017-08-02 17:27:17 +00:00
#### Before you start
* Please familiarize yourself with the [Code of Conduct][8] before contributing.
* See [CONTRIBUTING.md][5] for instructions on the developer certificate of origin that we require.
#### Pull requests
* We welcome pull requests. Feel free to dig through the [issues][4] and jump in.
## Changelog
See [the list of releases][6] to find out about feature changes.
[0]: https://github.com/heptio
2017-10-30 19:49:03 +00:00
[1]: https://travis-ci.org/heptio/ark.svg?branch=master
[2]: https://travis-ci.org/heptio/ark
2018-02-14 18:02:35 +00:00
[3]: /docs/cloud-common.md
2017-08-02 17:27:17 +00:00
[4]: https://github.com/heptio/ark/issues
2018-02-14 18:02:35 +00:00
[5]: https://github.com/heptio/ark/blob/master/CONTRIBUTING.md
[6]: https://github.com/heptio/ark/releases
2017-08-02 17:27:17 +00:00
[7]: /docs/build-from-scratch.md
2018-02-14 18:02:35 +00:00
[8]: https://github.com/heptio/ark/blob/master/CODE_OF_CONDUCT.md
2017-08-02 17:27:17 +00:00
[9]: https://kubernetes.io/docs/setup/
[10]: https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-with-homebrew-on-macos
[11]: https://kubernetes.io/docs/tasks/tools/install-kubectl/#tabset-1
[12]: https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/README.md
[13]: /docs/output-file-format.md
[14]: https://github.com/kubernetes/kubernetes
[15]: https://aws.amazon.com/
[16]: https://cloud.google.com/
[17]: https://azure.microsoft.com/
[18]: /docs/debugging-restores.md
[19]: /docs/img/backup-process.png
[20]: https://kubernetes.io/docs/concepts/api-extension/custom-resources/#customresourcedefinitions
[21]: https://kubernetes.io/docs/concepts/api-extension/custom-resources/#custom-controllers
[22]: https://github.com/coreos/etcd
2017-08-04 18:12:24 +00:00
[24]: http://j.hept.io/ark-list
2017-09-21 05:15:33 +00:00
[25]: http://slack.kubernetes.io/
2017-10-24 17:59:43 +00:00
[26]: https://github.com/heptio/ark/releases
2017-11-28 21:45:22 +00:00
[27]: /docs/hooks.md
2018-02-14 18:02:35 +00:00
[28]: /docs/plugins.md
[29]: https://heptio.github.io/ark/