Comments (11)
These helper methods are definitely useful and I won't have objection adding them. However the approach is not scalable. I would also suggest we go the route of fluent interface that makes things like this easier like this:
v1.create_namespaced_pod(
client.V1Pod()
.metadata_name("busy box")
.container_image(0, "busybox")
.container_args(0, ["sleep", "3600"])
.container_name(0, "busy_box"))
(fluent interface + expanding internal types + array access fluently)
This is not solid yet, just a quick thought. I will write a proposal for it.
from python.
I've had more thoughts on fluent interface, something like this look much better:
client.V1Pod()
.edit_metadata()
.name("busy box")
.done()
.add_container()
.image("busybox")
.args(["sleep", "3600"])
.name("busy_box")
.done()
.create()
from python.
add_metadata()
maybe, it is not really an edit method.
from python.
Maybe, the difference is container is an array, metadata is not.
from python.
@mbohlool, I just want to let you know that I have started working on this, so any notes you have in mind would be welcomed.
from python.
Would be nice if you can share any design before implementation. I added "x-kubernetes-group-version-kind" and "x-kubernetes-action" in Kubernetes 1.7 spec and I was planning to use that to generate a set of kubernetes friendly object with actions on them based on the generated objects. Not a real design, but I was thinking to do have something like:
from kubernetes import objects
...
pod = objects.V1Pod() # objects are all in form of GroupVersionKind
or
pod = objects.for_gvk("", "v1", "pod")
# edit pod
pod.create()
from python.
@mbohlool Sorry for the delayed response, I was traveling to Denver for GopherCon 2017 and I am still in Denver for the Conference but I would just like to make some progress on the issue by the time I return to Cameroon.
Initialy I was hoping to create helper classes for the resources, which would inherite the exiting classes and then implement helper functions for the fluent interface. Below is a sample for what I had in mind.
class PodHelper(V1Pod):
def edit_metadata(self, name=""):
#Create metadata object and set name
return self
def add_container(self, image="", args=[], name="")
#Create container with provided details
return self
def create(self)
#created pod
We can then create a pod with
client.PodHelper()
.edit_metadata(name="")
.add_container(image="", args=[], name="")
.create()
from python.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
from python.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
from python.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
.
Mark the issue as fresh with /remove-lifecycle rotten
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
from python.
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen
.
Mark the issue as fresh with/remove-lifecycle rotten
.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
from python.
Related Issues (20)
- Test 1
- K8s Python interface issue HOT 2
- Manage resourceVersion to allow resilient restart of watch method HOT 2
- [stream/ws_client] Reading long stdout is truncated at 32768 chars HOT 3
- Request timeout in APIs HOT 9
- Watch() returns wrong "DELETED" event HOT 2
- Version 30.0? HOT 6
- Failed to create deployment HOT 2
- Kubernetes Async API Calls with Callbacks Support HOT 9
- How to get access to the slack channel? HOT 2
- Watch stream missing job completion events HOT 1
- `KubeConfigMerger` object poorly structured when `KUBECONFIG` is a list of files. HOT 2
- Cannot change kube config at runtime HOT 4
- k8s_sdk29.0 error:no attribute 'BatchV1beta1Api' HOT 2
- Support new Kubernetes Sidecar Containers HOT 2
- When I call the query deployment interface, it returns 403 forbidden. HOT 1
- Make google-auth an optional dependency
- kubernetes.client.AuthenticationV1TokenRequest() fails HOT 1
- Allow utils.create_from_yaml to use server side apply
- Error with api when set configuration assert_hostname as true
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python.