-
Notifications
You must be signed in to change notification settings - Fork 519
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
Document how to do equivalent of kubectl apply -f {filename}
using this client
#367
Comments
The Go code for If you want to try to emulate it with this library (but honestly waiting for Server-Side apply is a better idea...) |
Thank you for the information! I like the idea of using the |
We need to regenerate for the Kubernetes 1.16 API an then see if it works :) I'd guess sometime in the next month or so. |
This is exactly what I want to do with this lib -- kick off jobs. |
Any update on when the API may be regenerated for 1.16/1.17? |
I'll try to get to it this week. |
@brendanburns sorry to bug you, have you got an ETA at all? If you're swamped, I can try and do the PR myself (if you could lend a little guidance that would be awesome). |
@garyo I haven't used it myself yet, but can't you already create jobs using the following code ? import k8s from '@kubernetes/client-node';
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.BatchV1Api);
k8sApi.createNamespacedJob(....) |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
/lifecycle frozen |
A bit late but are you looking for this example here? Just create a yml file with your resource and apply it. |
@soerenbrockmann, how do I resolve the error on line# 16 saying 'Property 'KubernetesObjectApi' does not exist on type 'typeof ' @kubernetes/client-node |
It does seem that the types are broken for this apply-example.ts I get the following for line 19: Type 'unknown[]' is not assignable to type 'KubernetesObject[]'.
Type 'unknown' is not assignable to type 'KubernetesObject'.ts and the following error for line 32: Argument of type 'KubernetesObject' is not assignable to parameter of type 'KubernetesObjectHeader<KubernetesObject>'.
Type 'KubernetesObject' is not assignable to type '{ metadata: { name: string; namespace: string; }; }'.
Types of property 'metadata' are incompatible.
Type 'V1ObjectMeta | undefined' is not assignable to type '{ name: string; namespace: string; }'.
Type 'undefined' is not assignable to type '{ name: string; namespace: string; }' |
We worked around this by typing the return value of
I'd describe it as narrowing the type by removing the possibility of That said, I think it's reasonable to hope/expect that the types defined in the Kubernetes client would allow this kind of usage. |
The documentation is not clear (to me) as to how the equivalent of the
kubectl apply -f {filename}
might be achieved using this client.eg: use this to create/update a Deployment.
So, how is it done?
FYI:
I have done some digging through some of the issues in connection with this, which lead me to the 'patch' commands with the 'force' set to 'true', (confirmation (or not) that this is indeed equivalent would be good), and that the 'options' needs to provide an override to the default 'content-type' value.
But, I have yet to see a clear definition of the 'body' that is supposed to be passed, as, the object model simply lists this as an 'object', which, could be anything at all, but, realistically, when I pass the same object as used to
createNamespacedDeployment()
with success, it fails miserably when used withpatchNamespacedDeployment()
, with an error message indicating that the body was unable to be processed.By the way, if it makes a difference, I'm using TypeScript.
Thank you in advance!
:)
The text was updated successfully, but these errors were encountered: