Skip to content

Commit fa158e4

Browse files
committed
add repository server controller details
1 parent 596c074 commit fa158e4

2 files changed

Lines changed: 202 additions & 19 deletions

File tree

docs/Tutorial/tutorial_repositoryserver.rst

Lines changed: 174 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,45 @@ application is installed in the ``default`` namespace.
3939
.. code-block:: yaml
4040
4141
$ cat <<EOF | kubectl create -f -
42+
apiVersion: v1
43+
kind: PersistentVolumeClaim
44+
metadata:
45+
name: time-log-pvc
46+
labels:
47+
app: time-logger
48+
spec:
49+
accessModes:
50+
- ReadWriteOnce
51+
resources:
52+
requests:
53+
storage: 1Gi
54+
---
4255
apiVersion: apps/v1
4356
kind: Deployment
4457
metadata:
4558
name: time-logger
4659
spec:
4760
replicas: 1
61+
selector:
62+
matchLabels:
63+
app: time-logger
4864
template:
4965
metadata:
5066
labels:
5167
app: time-logger
5268
spec:
5369
containers:
5470
- name: test-container
55-
image: containerlabs/aws-sdk
71+
image: ghcr.io/kanisterio/kanister-tools:0.92.0
5672
command: ["sh", "-c"]
5773
args: ["while true; do for x in $(seq 1200); do date >> /var/log/time.log; sleep 1; done; truncate /var/log/time.log --size 0; done"]
74+
volumeMounts:
75+
- name: data
76+
mountPath: /var/log
77+
volumes:
78+
- name: data
79+
persistentVolumeClaim:
80+
claimName: time-log-pvc
5881
EOF
5982
6083
Starting Kopia Repository Server
@@ -210,21 +233,77 @@ command used to create repository as specified in section :ref:`Creating a Kopia
210233
userAccessSecretRef:
211234
name: repository-server-user-access
212235
namespace: kanister
213-
username: kanisterUser
236+
username: kanisteruser
214237
EOF
215238
216239
217-
Once the Repository Server is created, you will see a repository server pod and a service created
218-
in kanister namespace.
240+
Once the Repository Server is created, you will see a repository server pod and a service exposing the
241+
the kopia repository server created in kanister namespace.
242+
243+
.. code-block:: bash
219244
220-
########
221-
(TODO: List pods and services)
245+
$ kubectl get pods,svc -n kanister
246+
NAME READY STATUS RESTARTS AGE
247+
pod/kanister-kanister-operator-5b7dfbf97b-5j5p5 2/2 Running 0 33m
248+
pod/repo-server-pod-4tjcw 1/1 Running 0 2m13s
249+
250+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
251+
service/kanister-kanister-operator ClusterIP 10.96.197.93 <none> 443/TCP 33m
252+
service/repo-server-service-rq2pq ClusterIP 10.96.127.153 <none> 51515/TCP 2m13s
222253
223254
To see if the server started successfully, you can check the status of
224255
the server using following command
225256

226-
#########
227-
(TODO: Please describe repository server resource)
257+
.. code-block:: bash
258+
259+
$ kubectl get repositoryservers.cr.kanister.io kopia-repo-server -n kanister -oyaml
260+
apiVersion: cr.kanister.io/v1alpha1
261+
kind: RepositoryServer
262+
metadata:
263+
annotations:
264+
kubectl.kubernetes.io/last-applied-configuration: |
265+
{"apiVersion":"cr.kanister.io/v1alpha1","kind":"RepositoryServer","metadata":{"annotations":{},"name":"kopia-repo-server","namespace":"kanister"},"spec":{"repository":{"hostname":"timelog.app","passwordSecretRef":{"name":"repository-pass","namespace":"kanister"},"rootPath":"/test/repo-controller","username":"kansiterAdmin"},"server":{"adminSecretRef":{"name":"repository-server-admin","namespace":"kanister"},"tlsSecretRef":{"name":"repository-server-tls-cert","namespace":"kanister"},"userAccess":{"userAccessSecretRef":{"name":"repository-server-user-access","namespace":"kanister"},"username":"kanisteruser"}},"storage":{"credentialSecretRef":{"name":"s3-loc-creds","namespace":"kanister"},"secretRef":{"name":"s3-location","namespace":"kanister"}}}}
266+
creationTimestamp: "2023-06-05T05:45:49Z"
267+
generation: 1
268+
name: kopia-repo-server
269+
namespace: kanister
270+
resourceVersion: "41529"
271+
uid: b4458c4f-b2d5-4dcd-99de-a0a4d32ed216
272+
spec:
273+
repository:
274+
hostname: timelog.app
275+
passwordSecretRef:
276+
name: repository-pass
277+
namespace: kanister
278+
rootPath: /test/repo-controller
279+
username: kansiterAdmin
280+
server:
281+
adminSecretRef:
282+
name: repository-server-admin
283+
namespace: kanister
284+
tlsSecretRef:
285+
name: repository-server-tls-cert
286+
namespace: kanister
287+
userAccess:
288+
userAccessSecretRef:
289+
name: repository-server-user-access
290+
namespace: kanister
291+
username: kanisteruser
292+
storage:
293+
credentialSecretRef:
294+
name: s3-loc-creds
295+
namespace: kanister
296+
secretRef:
297+
name: s3-location
298+
namespace: kanister
299+
status:
300+
progress: ServerReady
301+
serverInfo:
302+
podName: repo-server-pod-4tjcw
303+
serviceName: repo-server-service-rq2pq
304+
305+
``pod/repo-server-pod-4tjcw`` and ``service/repo-server-service-rq2pq`` populated in
306+
``status.serverInfo`` field should be used by the client to connect to the server
228307

229308
Invoking Kanister Actions
230309
=========================
@@ -247,10 +326,14 @@ Kanister function ``BackupDataUsingKopiaServer`` that uses kopia repository serv
247326
data to s3 storage. The action ``restore`` uses two kanister functions ``ScaleWorkload`` and
248327
``RestoreDataUsingKopiaServer``. ``ScaleWorkload`` function scales down the timelog application
249328
before restoring the data. ``RestoreDataUsingKopiaServer`` restores data using kopia repository server
250-
form s3 storage
329+
form s3 storage.
251330

252331
For more information of kanister function refer :doc:`Kanister's parameter templating </functions>`.
253332

333+
We are using output artifacts here to store the path of our data in s3 and snapshot ID that
334+
that will be used as ``backupIdentifier`` while performing restore. To know more about
335+
artifacts you can refer :ref:`tutorial`.
336+
254337
Blueprint
255338
---------
256339

@@ -279,7 +362,6 @@ Blueprint
279362
pod: "{{ index .Deployment.Pods 0 }}"
280363
container: test-container
281364
includePath: /var/log
282-
283365
restore:
284366
inputArtifactNames:
285367
- timeLog
@@ -297,7 +379,7 @@ Blueprint
297379
args:
298380
namespace: "{{ .Deployment.Namespace }}"
299381
pod: "{{ index .Deployment.Pods 0 }}"
300-
image: ghcr.io/kanisterio/kanister-tools:0.89.0
382+
image: ghcr.io/kanisterio/kanister-tools:0.92.0
301383
backupIdentifier: "{{ .ArtifactsIn.backupIdentifier.KeyValue.id }}"
302384
restorePath: /var/log
303385
- func: ScaleWorkload
@@ -307,10 +389,8 @@ Blueprint
307389
name: "{{ .Deployment.Name }}"
308390
kind: Deployment
309391
replicas: 1
310-
311392
EOF
312393
313-
314394
Once we create a Blueprint, we can see its events by using the following command:
315395

316396
.. code-block:: yaml
@@ -328,13 +408,90 @@ multiple actions, each acting on a different Kubernetes object. The ActionSet
328408
we're about to create in this tutorial specifies the ``time-logger`` Deployment we
329409
created earlier and selects the ``backup`` action inside our Blueprint.
330410

411+
412+
Add some data in the time logger app
413+
.. code-block:: bash
414+
kubectl exec -it time-logger-6d89687cbb-bmdj8 -n default -it sh
415+
sh-5.1# cd /var/log/
416+
sh-5.1# ls
417+
time.log
418+
sh-5.1# echo "hello world" >> test.log
419+
sh-5.1# cat test.log
420+
hello world
421+
331422
ActionSet
332-
---------------
423+
---------
333424

334425
.. code-block:: bash
335426
# Create action set using the blueprint created in above step
336-
$ kanctl create actionset --action backup --namespace kanister --blueprint time-log-bp --deployment time-logger/time-logger --repository-server=kopia-repo-server
427+
$ kanctl create actionset --action backup --namespace kanister --blueprint time-log-bp --deployment default/time-logger --repository-server kanister/kopia-repo-server
428+
actionset actionset backup-rlcnp created
337429
338430
``--repository-server`` flag is used to provide the reference to the repository server CR that we created
339-
in step :ref:`Creating Repository Server custom resource`. The CR is made available to the kanister
340-
functions using template parameters.
431+
in step :ref:`Creating Repository Server custom resource`. Since the details related to kopia repository server and
432+
the secrets are present in the CR, the blueprint will be able to read these details using
433+
template parameters and will perform backup using kopia repository server
434+
435+
436+
.. code-block:: bash
437+
438+
Events:
439+
Type Reason Age From Message
440+
---- ------ ---- ---- -------
441+
Normal Started Action 14s Kanister Controller Executing action backup
442+
Normal Started Phase 14s Kanister Controller Executing phase backupToS3
443+
Normal Ended Phase 9s Kanister Controller Completed phase backupToS3
444+
Normal Update Complete 9s Kanister Controller Updated ActionSet 'backup-rlcnp' Status->complete
445+
446+
447+
Lets delete the date from ``timelogger`` app.
448+
449+
.. code-block:: bash
450+
kubectl exec -it time-logger-6d89687cbb-bmdj8 -n default -it sh
451+
sh-5.1# cd /var/log/
452+
sh-5.1# ls -lrt
453+
total 12
454+
-rw-r--r-- 1 root root 12 Jun 5 06:22 test.log
455+
-rw-r--r-- 1 root root 7308 Jun 5 06:26 time.log
456+
sh-5.1# rm -rf test.log
457+
sh-5.1# ls -lrt
458+
total 8
459+
-rw-r--r-- 1 root root 7482 Jun 5 06:26 time.log
460+
461+
462+
Lets perform restore now, by using ``restore`` action from the ``time-log-bp`` blueprint
463+
464+
.. code-block:: bash
465+
kanctl --namespace kanister create actionset --action restore --from "backup-rlcnp" --repository-server kanister/kopia-repo-server
466+
actionset restore-backup-rlcnp-g5h65 create
467+
468+
We can see if the restore is successful by describing the actionset
469+
470+
.. code-block:: bash
471+
$kubectl describe actionsets.cr.kanister.io restore-backup-rlcnp-g5h65 -n kanister
472+
473+
Events:
474+
Type Reason Age From Message
475+
---- ------ ---- ---- -------
476+
Normal Started Action 20s Kanister Controller Executing action restore
477+
Normal Started Phase 20s Kanister Controller Executing phase shutdownPod
478+
Normal Ended Phase 8s Kanister Controller Completed phase shutdownPod
479+
Normal Started Phase 8s Kanister Controller Executing phase restoreFromS3
480+
Normal Ended Phase 4s Kanister Controller Completed phase restoreFromS3
481+
Normal Started Phase 4s Kanister Controller Executing phase bringupPod
482+
Normal Ended Phase 3s Kanister Controller Completed phase bringupPod
483+
Normal Update Complete 2s Kanister Controller Updated ActionSet 'restore-backup-rlcnp-g5h65' Status->complete
484+
485+
Lets check if the data was restored successfully. We should see the ``time.log`` file that was removed
486+
before performing restore
487+
488+
.. code-block:: bash
489+
kubectl exec -it time-logger-6d89687cbb-pv5x6 -n default -it sh
490+
sh-5.1# ls -lrt /var/log
491+
total 16
492+
-rw-r--r-- 1 root root 12 Jun 5 06:22 test.log
493+
-rw-r--r-- 1 root root 9715 Jun 5 06:32 time.log
494+
sh-5.1# cat /var/log/test.log
495+
hello world
496+
497+

docs/architecture.rst

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,42 @@ Architecture
77
:local:
88

99

10-
Kopia Repository Server Controller
11-
==================================
10+
Kopia Repository Server Workflow
11+
=======================
1212

13+
Introducting Kopia
14+
------------------
15+
16+
Kopia is a powerful, cross-platform tool for managing encrypted backups in the cloud.
17+
It provides fast and secure backups, using compression, data deduplication, and client-side end-to-end encryption.
18+
It supports a variety of backup storage targets, including object stores, which allows users to choose the storage provider that better addresses their needs.
19+
In Kopia, these storage locations are called repositories. It is a lock-free system that allows concurrent multi-client operations including garbage collection.
20+
To explore other features of Kopia, see its `documentation<https://kopia.io/docs/features/>`_
1321

1422
Kopia Repository Server
1523
-----------------------
1624

25+
A Kopia Repository Server allows Kopia clients proxy access to the backend storage location through it.
26+
Kopia Repository. At any time, a repository server can only connect to a single repository. Due to this a separate instance of the server will be used for each repository.
27+
28+
In Kanister, the server will comprise a Kubernetes Pod, Service. The pod runs the kopia repository
29+
server process that will be used by kopia clients to perform backup and restore. Kopia clients would
30+
only need a username/password and service name to connect to server without the need to know
31+
the backend storage location. This provides enhanced security since only authorized users will be allowed
32+
to access the kopia repository server. These authorized users need to be added to the server
33+
before starting the server
34+
1735
Kopia Repository
1836
----------------
1937

38+
The backup storage location is called a "Repository" in Kopia.
39+
Only a single repository can exist at a particular path in the backend storage location. Users opting to use separate repositories are recommended to use unique path prefixes for each repository.
40+
For example, a repository for a namespace called monitoring on S3 storage bucket called test-bucket could be created at the location ``s3://test-bucket/<UUID of monitoring namespace>/repo/``
41+
Accessing the repository requires the storage location and credential information similar to a Kanister Profile CR and a unique password used by Kopia during encryption, along with a unique
42+
path prefix mentioned above.
43+
44+
To know more about the design of kopia repository server controller refer its `design documentation<https://github.com/kanisterio/kanister/blob/master/design/kanister-kopia-integration.md>
45+
2046
The design of Kanister follows the operator pattern. This means
2147
Kanister defines its own resources and interacts with those resources
2248
through a controller. `This blog post

0 commit comments

Comments
 (0)