kubeclient icon indicating copy to clipboard operation
kubeclient copied to clipboard

[WIP] [EXPERIMENT] Don't send kind, apiVersion in create POST

Open cben opened this issue 7 years ago • 1 comments

Can we revert #58?

Seems https://github.com/kubernetes/kubernetes/issues/6439 fixed - from which kubernetes version? https://github.com/kubernetes/kubernetes/pull/10200 landed in v1.1.0.

Works for me on OpenShift 3.10-ish:

[8] pry(main)> kclient.create_service(Kubeclient::Resource.new(metadata: {namespace: 'default', name: 'foo'}, spec: {ports: [{port: 80}]}))
RestClient.post "https://internal-api.bpaskinc.origin-gce.dev.openshift.com:8443/api/v1/namespaces/default/services", "{\"metadata\":{\"namespace\":\"default\",\"name\":\"foo\"},\"spec\":{\"ports\":[{\"port\":80}]}}", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"80", "Content-Type"=>"application/json", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.1p111"
=> #<Kubeclient::Resource kind="Service", apiVersion="v1", metadata={:name=>"foo", :namespace=>"default", :selfLink=>"/api/v1/namespaces/default/services/foo", :uid=>"b2b41793-64e1-11e8-9540-42010a8e0002", :resourceVersion=>"45722", :creationTimestamp=>"2018-05-31T14:48:36Z"}, spec={:ports=>[{:protocol=>"TCP", :port=>80, :targetPort=>80}], :clusterIP=>"172.30.186.136", :type=>"ClusterIP", :sessionAffinity=>"None"}, status={:loadBalancer=>{}}>

(note POST body didn't include kind nor apiVersion)

Motivation: if we don't need to know apiVersion, this may (?) open up #284, #318, and other issues to simpler interface.

  • I'm not sure yet if we should commit to "we don't need to know apiVersion"
  • OTOH, I suspect we could infer apiVersion from discovery anyway?

cben avatar May 31 '18 15:05 cben

i feel like k8s 1.1.0 is old enough that removing apiVersion and kind is sufficient. bump the gem version as a breaking change. can always re-eval inferring apiVersion from a discovery method later if needed.

chasebolt avatar Jun 08 '18 22:06 chasebolt