kwok icon indicating copy to clipboard operation
kwok copied to clipboard

[kwokctl] Support k8s format for snapshot

Open wzshiming opened this issue 3 years ago • 1 comments
trafficstars

kwokctl snapshot save --path snapshot.yaml --format=k8s
kwokctl snapshot restore --path snapshot.yaml --format=k8s

Save --format=k8s: means to convert k8s yaml to protobuf format and put it in the etcd database. Restore --format=k8s: means to get the data in protobuf format from etcd and convert it to yaml.

Non goal: Ability to filtering of namespace, resource, label, etc.

wzshiming avatar Aug 30 '22 02:08 wzshiming

/kind feature

wzshiming avatar Aug 30 '22 02:08 wzshiming

kwokctl snapshot save --path snapshot.yaml --format=k8s
kwokctl snapshot restore --path snapshot.yaml --format=k8s

Save --format=k8s: means to convert k8s yaml to protobuf format and put it in the etcd database. Restore --format=k8s: means to get the data in protobuf format from etcd and convert it to yaml.

Non goal: Ability to filtering of namespace, resource, label, etc.

I wonder if that's backwards ? Because kwokctl snapshot save means save etcd's data to a file and kwokctl snapshot restore means resore data to etcd from a file.

karhow avatar Nov 08 '22 10:11 karhow

In some production clusters, users may not have admin privileges and may not be able to export data from etcd, so kwokctl provides a yaml form of data import

wzshiming avatar Nov 09 '22 03:11 wzshiming

/assign

Fish-pro avatar Dec 02 '22 14:12 Fish-pro

@wzshiming Can I complete this requirement? If yes, I have the following questions:

1.format k8s means to obtain all cluster resources through the kube-apiserver interface and then back up the storage? 2.format k8s means to back up clusters created by kwokctl create cluster, in which case, should etcd data be backed up as well?

Please help provide a more detailed description

Fish-pro avatar Dec 02 '22 14:12 Fish-pro

The goal is to import and export data in yaml format. I tried importing through apiserver before, but it was very slow, so this time I'm going to bypass apiserver and operate etcd directly.

wzshiming avatar Dec 02 '22 15:12 wzshiming

@wzshiming Preliminary ideas, I understand, direct use of clientv3 connected to, to get the data, then according to the yaml format stored backup, if we need to restore data to put is down again.

However, this operation has a requirement that etcd remain in service in the backup while not allowing apiserver access.

At the same time need to implement the apiserver logic, the storage results marshal to kubernetes resource objects.

What's your opinion?

image

Fish-pro avatar Dec 05 '22 09:12 Fish-pro

There is no need to care about the apiserver, just stop the apiserver during the import, and try to resume the cluster afterwards.

wzshiming avatar Dec 05 '22 12:12 wzshiming

@wzshiming In the last meeting, @Huang-Wei i mentioned that it has been implemented locally

Fish-pro avatar Jan 29 '23 09:01 Fish-pro

@wzshiming In the last meeting, @Huang-Wei i mentioned that it has been implemented locally

As far as I know it should be a tool for exporting resources from the production cluster, which is not duplicated by this.

wzshiming avatar Jan 29 '23 09:01 wzshiming

@wzshiming ok I got it

Fish-pro avatar Jan 29 '23 09:01 Fish-pro

@wzshiming In the last meeting, @Huang-Wei i mentioned that it has been implemented locally

As far as I know it should be a tool for exporting resources from the production cluster, which is not duplicated by this.

To clarify, this issue is aimed to dump resources from etcd instead of API Server, so it's more about a wrapper layer to parse/unparse the etcd format's data and present it in yaml?

Huang-Wei avatar Feb 01 '23 20:02 Huang-Wei

@wzshiming In the last meeting, @Huang-Wei i mentioned that it has been implemented locally

As far as I know it should be a tool for exporting resources from the production cluster, which is not duplicated by this.

To clarify, this issue is aimed to dump resources from etcd instead of API Server, so it's more about a wrapper layer to parse/unparse the etcd format's data and present it in yaml?

Yeah, Use kubectl get or the export resource tool to export data from production, and use the functionality of this issue to quickly restore data from production in a kwok cluster.

wzshiming avatar Feb 02 '23 02:02 wzshiming

I tried writing data directly to etcd, which seemed like a lot of work, and was very cumbersome to make compatible. Let's go in a different direction, by copying the kubectl apply and kwokctl get code, removing the parts we don't need, and removing the QPS limit. This way it's easy to implement, and we don't have to worry about compatibility.

wzshiming avatar Mar 08 '23 07:03 wzshiming

/assign

wzshiming avatar Mar 17 '23 07:03 wzshiming