-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
implement the last subresources #127
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I'll do I have a rough sketch that can do something similar to Python client's example: // Portforward nginx container
let mut pf = pods.portforward("example", &[80]).await?; // Portforwarder
let mut ports = pf.ports().unwrap(); // Vec<Port>
let mut port = ports[0].stream().unwrap(); // impl AsyncRead + AsyncWrite + Unpin
port.write_all(b"GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: close\r\nAccept: */*\r\n\r\n")
.await?;
let mut rstream = tokio_util::io::ReaderStream::new(port);
if let Some(res) = rstream.next().await {
match res {
Ok(bytes) => {
let response = std::str::from_utf8(&bytes[..]).unwrap();
println!("{}", response);
assert!(response.contains("Welcome to nginx!"));
}
Err(err) => eprintln!("{:?}", err),
}
} I'll open a draft PR later (it's too messy at the moment to show...) to discuss the design. That should make kube a gold client except for "Proto encoding".
I'm not sure what that means. Do we need to support Protobufs? |
Yeah, that sounds sensible. Listening sounds like an application concern. In an example we can maybe use
Ugh. Ah, yeah, I am not sure that's really possible atm. The go api has protobuf codegen hints (see api/types.go) like: // +optional
// +patchMergeKey=name
// +patchStrategy=merge
EphemeralContainers []EphemeralContainer `json:"ephemeralContainers,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,34,rep,name=ephemeralContainers"` whereas the (huge) swagger codegen has the equivalent json for that part of the PodSpec: "ephemeralContainers": {
"description": "...",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.EphemeralContainer"
},
"type": "array",
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
}, think the |
The official JavaScript client is Gold and just have something like this (only deserializing): export class ProtoClient {
public readonly 'config': KubeConfig;
public async get(msgType: any, requestPath: string): Promise<any> {
// ...
const req = http.request(options);
const result = await new Promise<any>((resolve, reject) => {
let data = '';
req.on('data', (chunk) => {
data = data + chunk;
});
req.on('end', () => {
const obj = msgType.deserializeBinary(data);
resolve(obj);
});
req.on('error', (err) => {
reject(err);
});
});
req.end();
return result;
}
} https://github.com/kubernetes-client/javascript/blob/master/src/proto-client.ts (BTW, it can't portforward more than one port. https://github.com/kubernetes-client/javascript/blob/a8d4f1c7bea2b27403d380e22e492b6680f80b31/src/portforward.ts#L19) I guess the requirement for Gold is not well-defined? Python one seems more capable, but that's Silver. When I searched "Kubernetes Proto Encoding", https://kubernetes.io/docs/reference/using-api/api-concepts/#protobuf-encoding came up. |
Yeah, I think the client grading document is a thing they they wrote and applied to the clients they generated themselves. It technically doesn't apply to us (because we don't have our client in that place they say it should be in), but it's a nice benchmark otherwise. I have opened an issue to continue protobuf discussions in #371 at any rate. |
Naive question about |
It's probably just that no one has asked for it yet. It actually looks very simple. I can have a go at adding it. |
Eviction handled in #393 |
Can I have a go at implementing ephemeral container support? |
@jmintb Go for it! |
Subresources have a lot of special case logic, that is not easily derivable from
k8s_openapi
. So far we have implemented (see subresources.rs):/attach
and/exec
#360)/attach
and/exec
#360)create_subresource
method toApi
andcreate_token_request
method toApi<ServiceAccount>
#989Request
work from Request: support arbitrary subresources #487 (comment) to API - Add Api fns for arbitrary subresources and approval subresource for CertificateSigningRequest #773The general outline for the http based subresources:
We need a definition of what they are in subresources. The way to upgrade would be:
Resource
without restrictions (for now):Write one test case for one resource in examples (e.g. examples/log_openapi.rs).
EDIT (0.46.0):
Now this is not as difficult for the specialized requests requiring websockets (
ws
feature).This was discussed at length in #229, and finally implemented in #360.
Implementors of the last subresources ought to look at that PR for help.
The text was updated successfully, but these errors were encountered: