A
u
Belaid Youba Hadj Arab, Etienne Deneuve
Feb 20, 2024 · 2 min read

Backup of Kibana with a Cronjob

Side view worker wearing gloves

What is a cronjob?

CronJob is a periodic job creator. It is designed to execute regular scheduled actions such as backups, report generation, etc. It periodically executes a job according to a given schedule, written in Cron format. It periodically executes a job according to a given schedule, written in Cron format.

Persistent Volume & Persistent Volume Claim

  • Before deploying our cronjob, we first need to prepare the ground by deploying a Persistent Volume and a Persistent Volume Claim. These will enable us to link our backup folder and our storage account.
  1. Here’s the first yaml we’ll call fileshare-pv.yaml, which will be the Persistent Volume. :
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: file.csi.azure.com
name: azurefilekibana
namespace: <namespace-ou-est-déployé-kibana>
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: azurefile-csi
csi:
driver: file.csi.azure.com
readOnly: false
volumeHandle: unique-volumeid
volumeAttributes:
resourceGroup:
shareName:
nodeStageSecretRef:
name: azure-secret
namespace: <namespace-ou-est-déployé-kibana>
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=0
- gid=0
- mfsymlinks
- cache=strict
- nosharesock
- nobrl
  1. The second yaml, called fileshare-pvc.yaml, will be the Persistent Volume Claim. :
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: azurefilekibana
namespace: <namespace-ou-est-déployé-kibana>
spec:
accessModes:
- ReadWriteMany
storageClassName: azurefile-csi
resources:
requests:
storage: 10Gi
  1. And the last yaml will be the one containing the credentials to be able to link to our storage account, we will name it fileshare-secret.yaml :
apiVersion: v1
kind: Secret
metadata:
name: azure-secret
namespace: es
type: Opaque
data:
azurestorageaccountkey: # must be encoded in base64
azurestorageaccountname: # must be encoded in base64

To retrieve the azurestorageaccountkey, go to portal, then storage account, and finally Access keys.

Cronjob

  • For our cronjob to work, it will need 3 components:
  1. the dockerconfigjson which will be used to pull the docker image we’ve created and pushed into the azure container registry
Backup Kibana Tutorial

Related articles