2022-03-08

使用 Velero 备份 k8s 集群


获取 Velero 安装命令,开源项目地址: Velero


部署 Minio 对象存储


apiVersion: v1

kind: Namespace

metadata:

  name: velero

---

apiVersion: apps/v1

kind: Deployment

metadata:

  namespace: velero

  name: minio

  labels:

    component: minio

spec:

  strategy:

    type: Recreate

  selector:

    matchLabels:

      component: minio

  template:

    metadata:

      labels:

        component: minio

    spec:

      volumes:

      - name: storage

        emptyDir: {}

      - name: config

        emptyDir: {}

      containers:

      - name: minio

        image: minio/minio:latest

        imagePullPolicy: IfNotPresent

        args:

        - server

        - /storage

        - --config-dir=/config

        env:

        - name: MINIO_ACCESS_KEY

          value: "minio"

        - name: MINIO_SECRET_KEY

          value: "minio123"

        ports:

        - containerPort: 9000

        volumeMounts:

        - name: storage

          mountPath: "/storage"

        - name: config

          mountPath: "/config"

---

apiVersion: v1

kind: Service

metadata:

  namespace: velero

  name: minio

  labels:

    component: minio

spec:

  # ClusterIP is recommended for production environments.

  # Change to NodePort if needed per documentation,

  # but only if you run Minio in a test/trial environment, for example with Minikube.

  type: ClusterIP

  ports:

    - port: 9000

      targetPort: 9000

      protocol: TCP

  selector:

    component: minio

---

apiVersion: batch/v1

kind: Job

metadata:

  namespace: velero

  name: minio-setup

  labels:

    component: minio

spec:

  template:

    metadata:

      name: minio-setup

    spec:

      restartPolicy: OnFailure

      volumes:

      - name: config

        emptyDir: {}

      containers:

      - name: mc

        image: minio/mc:latest

        imagePullPolicy: IfNotPresent

        command:

        - /bin/sh

        - -c

        - "mc --config-dir=/config config host add velero http://minio:9000 minio minio123 && mc --config-dir=/config mb -p velero/velero"

        volumeMounts:

        - name: config

          mountPath: "/config"

使用 Velero 命令创建Velero 容器


velero install --provider aws --plugins velero/velero-plugin-for-aws:v1.2.1 --bucket velero --secret-file ./credentials-velero --use-volume-snapshots=false --backup-location-config region=minio,s3ForcePathStyle="true",s3Url=http://minio.velero.svc:9000

你可能感兴趣的:(2022-03-08)