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)
- read proxy-url from kubeconf HOT 4
- Vulnerability issue: Lib/ipaddress.py in Python version HOT 4
- Get CR, delete and re-create results in unsolvable `TypeError: 'NoneType' object is not callable` HOT 1
- EoS required for v29.0.0 HOT 2
- How to find documentation for previous releases? HOT 1
- 'set' object has no attribute 'openapi_types' HOT 2
- Port forward a service HOT 4
- Bad return for json response HOT 2
- Errouneous link for [object] type in V1RollingUpdateDeployment and V1HTTPGetAction pages HOT 5
- client.CoreV1Api.read_namespaced_pod(pod_name, pod_namespace) returning incomplete data for several minutes after pod is deployed HOT 2
- kubernetes.client.Configuration.set_default is not working as expected HOT 4
- `load_config` does not really support "context" HOT 1
- `format_quantity` function missing to convert Decimal values in to K8s quantity string HOT 5
- Kubernetes connections using exec provided plugin commands fail if client ssl key and cert are not base64 encoded
- Support for Ephemeral Containers in Running Pods via Python Kubernetes Client 通过Python Kubernetes客户端在运行中的Pods里支持临时容器 HOT 4
- Is there any method to create service and deployment at the same time? HOT 1
- kubernetes.client.api.core_v1_api.delete_node_with_http_info deletes all nodes when `name` is an empty string. HOT 2
- What is the method to create a new resource type? HOT 5
- watch.Watch() - get only new events HOT 3
- Deprecation warning datetime.datetime.utcnow(). HOT 5
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.