Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

请在使用站内资源的同时不要恶意进行爬取或倒链等行为,感谢支持!

Note

相关文档:

UI Button
colorblue
newWindowtrue
sizesmall
displayblock
iconlink
title链接
urlhttp://lusyoe.github.io/2019/06/22/%E5%9F%BA%E4%BA%8EKubernetes%E7%9A%84Gitlab%E8%87%AA%E5%8A%A8%E5%AE%9A%E6%97%B6%E5%A4%87%E4%BB%BD/

Info
iconfalse

Table of Contents

Kubernetes Gitlab Backup

Gitlab 定时备份。

创建 kubeconfig:

Code Block
languagebash
$ kubectl create configmap kubeconfig --from-file=/root/.kube/config -n gitlab

创建 crobjob 配置:

Code Block
languagebash
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: gitlab-backup-schedule
spec:
  schedule: "0 1 * * *"
  successfulJobsHistoryLimit: 0
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          volumes:
          - name: config
            configMap:
              name: kubeconfig
          containers:
          - name: gitlab-backup
            image: harbor.ops.zhangyue-ops.com/kubernetesslzcc/kubectl:v1.15.3
            volumeMounts:
            - name: config
              mountPath: /etc/kubeconfig
            command:
            - /bin/sh
            - -c
            - pod_name=$(kubectl get pods -l app=gitlab-ops -o jsonpath='{.items[*].metadata.name}' -n gitlab --kubeconfig=/etc/kubeconfig/config);
              kubectl get po/$pod_name --kubeconfig=/etc/kubeconfig/config;
              kubectl --kubeconfig=/etc/kubeconfig/config exec $pod_name -- gitlab-rake gitlab:backup:create
          restartPolicy: OnFailure

查看定时任务:

Code Block
languagebash
$ kubectl get cronjob gitlab-backup-schedule

文档创建于 最后一次更新于  , 文档当前的状态 

Status
colourGreen
title正式版
 , 当前编写页面的版本 
Status
colourBlue
titlev1.3.1
 。