Belaid Youba Hadj Arab, Etienne Deneuve
Feb 20, 2024 · 2 min
read
Backup of Kibana with a Cronjob
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 Volumeand aPersistent Volume Claim. These will enable us to link our backup folder and our storage account.
- Here’s the first
yamlwe’ll callfileshare-pv.yaml, which will be thePersistent Volume. :
apiVersion: v1kind: PersistentVolumemetadata: 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- The second yaml, called
fileshare-pvc.yaml, will be thePersistent Volume Claim. :
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: azurefilekibana namespace: <namespace-ou-est-déployé-kibana>spec: accessModes: - ReadWriteMany storageClassName: azurefile-csi resources: requests: storage: 10Gi- And the last yaml will be the one containing the
credentialsto be able to link to ourstorage account, we will name itfileshare-secret.yaml:
apiVersion: v1kind: Secretmetadata: name: azure-secret namespace: estype: Opaquedata: azurestorageaccountkey: # must be encoded in base64 azurestorageaccountname: # must be encoded in base64To retrieve the
azurestorageaccountkey, go to portal, thenstorage account, and finallyAccess keys.
Cronjob
- For our
cronjobto work, it will need 3 components:
- the
dockerconfigjsonwhich will be used topullthe docker image we’ve created and pushed into the azure container registry
Backup Kibana Tutorial