Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add krew manifest for snapshot-api-objects #4227

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oguzhan-yilmaz
Copy link

About

This plugins loops through namespaces, kubernetes api object types and gets the -o yaml output, pipes it to kubectl neat - create a snapshot of the currently installed K8s API objects to filesystem.

Then it creates a .tar.gz file with cluster name and timestamp values.

Verify you can install your plugin locally: kubectl krew install --manifest=[...] --archive=[...]

$ kubectl krew install --manifest=plugins/snapshot_api_objects.yaml
Installing plugin: snapshot_api_objects
Installed plugin: snapshot_api_objects
\
 | Use this plugin:
 |      kubectl snapshot_api_objects
 | Documentation:
 |      https://github.com/oguzhan-yilmaz/kubectl-snapshot-api-objects
 | Caveats:
 | \
 |  | Requires:
 |  |   - kubectl neat
 |  |   - yq
 | /
/

Copy link

linux-foundation-easycla bot commented Nov 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@ahmetb
Copy link
Member

ahmetb commented Nov 17, 2024

🤖 Beep beep! I’m a robot speaking on behalf of @ahmetb. 🤖


Thanks for submitting your kubectl plugin to Krew!
One of the krew-index maintainers will review it soon. Note that the reviews for new plugin submissions may take a few days.

In the meanwhile, here are a few tips to make your plugin manifest better:

  • Make sure your plugin follows the best practices.
  • Eliminate redundant wording form shortDescription (it should be max 50 characters).
  • Try to word wrap your description to 80-character lines (no usage examples, please).

Thanks for your patience!
/kind new-plugin

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: oguzhan-yilmaz
Once this PR has been reviewed and has the lgtm label, please assign chriskim06 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 17, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @oguzhan-yilmaz!

It looks like this is your first PR to kubernetes-sigs/krew-index 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/krew-index has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 17, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 17, 2024
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
# 'name' must match the filename of the manifest. The name defines how
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the boilerplate comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed with the new commit

kind: Plugin
metadata:
# 'name' must match the filename of the manifest. The name defines how
name: snapshot_api_objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you picked _ over - ? It's rather not typical plugin naming.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an oversight, I've updated it to snapshot-api-objects now

# 'shortDescription' explains what the plugin does in only a few words
shortDescription: "Snapshot Kubernetes API Objects"
description: |
Snapshot all Kubernetes Objects and save them as yaml files in .tar.gz archive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does kubectl get-all plugin let us do this? If so, it might be good to not create another plugin and instead compose them.

@oguzhan-yilmaz oguzhan-yilmaz changed the title add krew manifest for snapshot_api_objects add krew manifest for snapshot-api-objects Nov 18, 2024
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 18, 2024
@oguzhan-yilmaz
Copy link
Author

Does kubectl get-all plugin let us do this? If so, it might be good to not create another plugin and instead compose them.

Thanks for the insight @ahmetb. I wasn't aware of the get-all plugin and it does a good job at data collection with more CLI options.

My main goal was to have a way to snapshot API Objects to a point-in-time and then have another way to diff the snapshots to get an idea of what's changed.

So I created this plugin to have the data, and was planning to create a complementary plugin for diffing two snapshots using the dyff tool. Which is a great tool with semantic diff features.

I've decided to collect the two features into this plugin to make it different than get-all plugin.

My current plan is:

  • utilize kubectl get-all for data collection
  • add the diff functionality
  • Have collect and diff cmds:
    • kubectl snapshot-api-objects collect -n default, -r pods,configmaps
    • kubectl snapshot-api-objects diff snap1.tar.gz snap2.tar.gz

Would adding the diff functionality make this plugin acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/new-plugin size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants