Fileset Examples

In the example below, all Kubernetes Namespaces, Objects and Persistent Volume Configurations will be backed up using the default Kubernetes API access credentials. The PVC data will not be backed up.

Fileset {
  Name = FS_Kubernetes_All
  Include {
    Plugin = "kubernetes:"
  }
}

In this example, we will backup a single Kubernetes Namespace using the Bearer Token authorization method. The PVC data will not be backed up.

Fileset {
  Name = FS_Kubernetes_plugintest
  Include {
    Plugin = "kubernetes: host=http://10.0.0.1/k8s/clusters/test \
        token=kubeconfig-user:cbhssdxq8vv8hrcw8jdxs2 namespace=plugintest"
  }
}

The same example as above, but with a Persistent Volume configuration. The PVC data will not be backed up.

Fileset {
  Name = FS_Kubernetes_mcache1
  Include {
    Plugin = "kubernetes: host=http://10.0.0.1/k8s/clusters/test \
        token=kubeconfig-user:cbhssdxq8vv8hrcw8jdxs2 \
        namespace=plugintest persistentvolume=myvol"
  }
}

This example backs up a single Namespace and all detected PVCs in this Namespace using a defined listening and entry point address and the default connection port:

Fileset {
  Name = FS_Kubernetes_test_namespace
  Include {
    Plugin = "kubernetes: namespace=test pvcdata fdaddress=10.0.10.10"
  }
}

The same example as above, but using different listening and entry point addresses as may be found when the service is behind a firewall using port forwarding features:

Fileset {
  Name = FS_Kubernetes_test_namespace_through_firewall
  Include {
    Plugin = "kubernetes: namespace=test pvcdata=plugin-storage fdaddress=10.0.10.10 \
        pluginhost=backup.example.com pluginport=8080"
  }
}

In cluster example

This section provides an example (for both Kubernetes and Bacula) demonstrating the use of an in-cluster mode. As an initial step, we define the Pod in Kubernetes along with the corresponding Service. In this example, we omit the creation of the bacula-fd image. If you need to create it, refer to the The Kubernetes Plugin InCluster Option section.

Config to create a Pod using bacula-fd and their service
 1apiVersion: v1
 2kind: Pod
 3metadata:
 4  name: bacula-fd
 5  namespace: bacula # It can be other namespace
 6  labels:
 7    app: bacula-fd
 8spec:
 9  containers:
10  - name: bacula-fd
11    image: private-repository/bacula-fd:latest
12    volumeMounts:
13    - name: bacula-fd-config
14      mountPath: /opt/bacula/etc/bacula-fd.conf
15      subPath: bacula-fd.conf
16  volumes:
17  - name: bacula-fd-config
18    configMap:
19      name: bacula-fd-config
20---
21apiVersion: v1
22kind: Service
23metadata:
24  name: bacula-fd-service
25  namespace: bacula # It can be other namespace
26  labels:
27    app: bacula-fd
28spec:
29  type: NodePort # We can also use NodeIP, if it is required
30  selector:
31    app: bacula-fd
32  ports:
33  - name: bacula-fd-port
34    port: 33042 # We request to this port to access bacula-fd
35    targetPort: 9102
36    nodePort: 33042
37    protocol: TCP
38  - name: k8s-plugin-access
39    port: 33100 # We request to this port to pvcdata backup
40    targetPort: 9104
41    nodePort: 33100
42    protocol: TCP

In this example, it is assumed that access to the data stored on the PVC is made through the svc.cluster.local service. So with this configuration, we can access from other container to this pod using bacula-fd-service.bacula.svc.cluster.local service and the ports 33042 to 9102, and 33100 to 9104.

With this environment, we can use the next Bacula configuration:

Client {
  Name = "bacula-container-fd"
  Address = "<cluster-address>"
  FdPort = 33042
  [...]
}

Fileset {
  Name = "k8s_default_pvcs"
  Include {
    Plugin = "kubernetes: incluster namespace=default pvcdata \
        pluginhost=bacula-fd-service.bacula.svc.cluster.local pluginport=33100"
  }
}

The following shows a diagram illustrating the example:

../../../../../../_images/diagram_example_in_cluster.png

This image represents the diagram of this example.

Go back to: Configuration.