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 Pod.gen() #222

Merged
merged 4 commits into from
Nov 29, 2023
Merged

Add Pod.gen() #222

merged 4 commits into from
Nov 29, 2023

Conversation

jacobtomlinson
Copy link
Member

With kubectl you can call commands like kubectl run nginx --image=nginx which will generate the spec for a Pod and create it. Or you can generate a service with kubectl create service clusterip my-cs --tcp=5678:8080.

This PR adds similar functionality with a .gen() method on Pod which allows you to generate the spec of a Pod object with a few keyword arguments. We can easily extend this for other objects in the future.

from kr8s.objects import Pod

pod = Pod.gen(name="example-1", image="nginx:latest")
pod.create()

xref #142

@github-actions github-actions bot added documentation Improvements or additions to documentation kr8s tests labels Nov 29, 2023
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (0280954) 94.99% compared to head (1410d55) 94.87%.
Report is 1 commits behind head on main.

Files Patch % Lines
kr8s/portforward.py 57.14% 3 Missing ⚠️
kr8s/tests/test_gen.py 90.47% 2 Missing ⚠️
kr8s/_objects.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #222      +/-   ##
==========================================
- Coverage   94.99%   94.87%   -0.13%     
==========================================
  Files          26       27       +1     
  Lines        2579     2633      +54     
==========================================
+ Hits         2450     2498      +48     
- Misses        129      135       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobtomlinson jacobtomlinson merged commit 9b668dc into kr8s-org:main Nov 29, 2023
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation kr8s tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant