forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkubectl.ts
3806 lines (3798 loc) · 129 KB
/
kubectl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Internal scripts for this spec, not to be confused with the script property
const scripts = {
types: "kubectl api-resources -o name",
typeWithoutName: function (type) {
return `kubectl get ${type} -o custom-columns=:.metadata.name`;
},
};
const sharedPostProcessChecks = {
connectedToCluster: (out) => {
return out.includes("The connection to the server");
},
generalError: (out) => {
return out.includes("error:");
},
};
const sharedPostProcess: Fig.Generator["postProcess"] = (out) => {
if (
sharedPostProcessChecks.connectedToCluster(out) ||
sharedPostProcessChecks.generalError(out)
) {
return [];
}
return out.split("\n").map((item) => ({
name: item,
icon: "fig://icon?type=kubernetes",
})) as Fig.Suggestion[];
};
const sharedArgs: Record<string, Fig.Arg> = {
resourcesArg: {
name: "Resource Type",
generators: {
script: scripts.types,
postProcess: sharedPostProcess,
},
},
runningPodsArg: {
name: "Running Pods",
generators: {
script: "kubectl get pods --field-selector=status.phase=Running -o name",
postProcess: sharedPostProcess,
},
},
resourceSuggestionsFromResourceType: {
name: "Resource",
generators: {
script: function (context) {
const resourceType = context[context.length - 2];
return scripts.typeWithoutName(resourceType);
},
postProcess: sharedPostProcess,
},
isOptional: true,
},
listKubeConfContexts: {
name: "Context",
generators: {
script: function (context) {
const index = context.indexOf("--kubeconfig");
if (index !== -1) {
return `kubectl config --kubeconfig=${
context[index + 1]
} get-contexts -o name`;
}
return "kubectl config get-contexts -o name";
},
postProcess: sharedPostProcess,
},
},
listDeployments: {
name: "Deployments",
generators: {
script: () => scripts.typeWithoutName("deployments"),
postProcess: sharedPostProcess,
},
},
listClusters: {
name: "Cluster",
generators: {
script: function (context) {
const index = context.indexOf("--kubeconfig");
if (index !== -1) {
return `kubectl config --kubeconfig=${
context[index + 1]
} get-clusters`;
}
return "kubectl config get-clusters";
},
postProcess: function (out) {
if (
sharedPostProcessChecks.connectedToCluster(out) ||
sharedPostProcessChecks.generalError(out)
) {
return [];
}
return out
.split("\n")
.filter((line) => line !== "NAME")
.map((line) => ({
name: line,
icon: "fig://icon?type=kubernetes",
}));
},
},
},
typeOrTypeSlashName: {
name: "TYPE | TYPE/NAME",
generators: {
script: function (context) {
const lastInput = context[context.length - 1];
if (lastInput.includes("/")) {
return scripts.typeWithoutName(
lastInput.substring(0, lastInput.indexOf("/"))
);
}
return scripts.types;
},
postProcess: sharedPostProcess,
trigger: "/",
filterTerm: "/",
},
},
listNodes: {
name: "Node",
generators: {
script: () => scripts.typeWithoutName("nodes"),
postProcess: sharedPostProcess,
},
},
listClusterRoles: {
name: "Cluster Role",
generators: {
script: () => scripts.typeWithoutName("clusterroles"),
postProcess: sharedPostProcess,
},
},
listContainersFromPod: {
name: "Container",
generators: {
script: (context) => {
const podIndex = context.findIndex(
(i) =>
i === "pods" ||
i.includes("pods/") ||
i === "pod" ||
i.includes("pod/")
);
const podName = context[podIndex].includes("/")
? context[podIndex]
: `${context[podIndex]} + ${context[podIndex + 1]}`;
return `kubectl get ${podName} -o json`;
},
postProcess: function (out) {
if (
sharedPostProcessChecks.connectedToCluster(out) ||
sharedPostProcessChecks.generalError(out)
) {
return [];
}
return JSON.parse(out).spec.containers.map((item) => ({
name: item.name,
description: item.image,
icon: "fig://icon?type=kubernetes",
}));
},
},
},
};
const sharedOpts: Record<string, Fig.Option> = {
filename: {
name: ["-f", "--filename"],
description:
"Filename, directory, or URL to files identifying the resource",
args: {
name: "File",
template: "filepaths",
},
},
kustomize: {
name: ["-k", "--kustomize"],
description:
"Process the kustomization directory. This flag can't be used together with -f or -R.",
args: {
name: "Kustomize Dir",
template: "folders",
},
},
output: {
name: ["-o", "--output"],
description:
"Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file.",
args: {
name: "Output Format",
suggestions: [
"json",
"yaml",
"name",
"go-template",
"go-template-file",
"template",
"templatefile",
"jsonpath",
"jsonpath-file",
],
},
},
resourceVersion: {
name: ["--resource-version"],
insertValue: "--resource-version=",
description:
"If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.",
args: {},
},
dryRun: {
name: ["--dry-run"],
insertValue: "--dry-run=",
description:
'Must be "none", "server", or "client". If client strategy, only print the object that would be sent, without sending it. If server strategy, submit server-side request without persisting the resource.',
args: {
name: "Strategy",
suggestions: ["None", "Server", "Client"],
},
},
fieldSelector: {
name: ["--field-selector"],
insertValue: "--field-selector=",
description:
"Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.",
args: {},
},
local: {
name: ["--local"],
description:
"If true, annotation will NOT contact api-server but run locally.",
},
allResources: {
name: ["--all"],
description:
"Select all resources, including uninitialized ones, in the namespace of the specified resource types.",
},
allowMissingTemplateKeys: {
name: ["--allow-missing-template-keys"],
description:
"If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.",
},
recursive: {
name: ["-R", "--recursive"],
description:
"Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.",
},
selector: {
name: ["-l", "--selector"],
description:
"Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).",
args: {},
},
template: {
name: ["--template"],
insertValue: "--template=",
description:
"Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].",
args: {},
},
overwrite: {
name: ["--overwrite"],
description:
"If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.",
},
record: {
name: ["--record"],
description:
"Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.",
},
};
const sharedOptsArray = Object.values(sharedOpts);
export const completionSpec: Fig.Spec = {
name: "kubectl",
description: "",
subcommands: [
{
name: "alpha",
description:
"These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.",
subcommands: [
{
name: "debug",
description: "Tools for debugging Kubernetes resources",
options: [
{
name: ["--arguments-only"],
description:
"If specified, everything after -- will be passed to the new container as Args instead of Command.",
args: {},
},
{
name: ["--attach"],
description:
"If true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true.",
args: {},
},
{
name: ["--container"],
description: "Container name to use for debug container.",
args: {},
},
{
name: ["--env"],
description: "Environment variables to set in the container.",
args: {},
},
{
name: ["--image"],
description: "Container image to use for debug container.",
args: {},
},
{
name: ["--image-pull-policy"],
description: "The image pull policy for the container.",
args: {},
},
{
name: ["--quiet"],
description: "If true, suppress prompt messages.",
args: {},
},
{
name: ["-i", "--stdin"],
description:
"Keep stdin open on the container(s) in the pod, even if nothing is attached.",
args: {},
},
{
name: ["--target"],
description: "Target processes in this container name.",
args: {},
},
{
name: ["-t", "--tty"],
description: "Allocated a TTY for each container in the pod.",
args: {},
},
],
},
],
},
{
name: "annotate",
description: "Update the annotations on one or more resources",
args: [
sharedArgs.resourcesArg,
sharedArgs.resourceSuggestionsFromResourceType,
// * INFO: Fig doesn't display options if varidic is true
{
name: "KEY=VAL",
variadic: true,
},
],
options: sharedOptsArray,
},
{
name: "api-resources",
description: "Print the supported API resources on the server",
options: [
sharedOpts.output,
{
name: ["--api-group"],
insertValue: "--api-group",
description: "Limit to resources in the specified API group.",
args: {},
},
{
name: ["--cached"],
description: "Use the cached list of resources if available.",
},
{
name: ["--namespaced"],
description:
"If false, non-namespaced resources will be returned, otherwise returning namespaced resources by default.",
},
{
name: ["--no-headers"],
description:
"When using the default or custom-column output format, don't print headers (default print headers).",
},
{
name: ["--sort-by"],
insertValue: "--sort-by=",
description:
"If non-empty, sort nodes list using specified field. The field can be either 'name' or 'kind'.",
args: {},
},
{
name: ["--verbs"],
insertValue: "--verbs=",
description: "Limit to resources that support the specified verbs.",
args: {},
},
],
},
{
name: "api-versions",
description:
'Print the supported API versions on the server, in the form of "group/version"',
},
{
name: "apply",
description:
"Apply a configuration to a resource by filename or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.",
options: sharedOptsArray.concat([
{
name: ["--cascade"],
description:
"If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.",
},
{
name: ["--field-manager"],
insertValue: "--field-manager=",
description: "Name of the manager used to track field ownership.",
args: {},
},
{
name: ["--force"],
description:
"If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.",
},
{
name: ["--force-conflicts"],
description:
"If true, server-side apply will force the changes against conflicts.",
},
{
name: ["--grace-period"],
insertValue: "--grace-period=",
description:
"Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).",
args: {
name: "INT (seconds)",
},
},
{
name: ["--openapi-patch"],
description:
"If true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.",
},
{
name: ["--overwrite"],
description:
"Automatically resolve conflicts between the modified and live configuration by using values from the modified configuration",
},
{
name: ["--prune"],
description:
"Automatically delete resource objects, including the uninitialized ones, that do not appear in the configs and are created by either apply or create --save-config. Should be used with either -l or --all.",
},
{
name: ["--prune-whitelist"],
insertValue: "--prune-whitelist=",
description:
"Overwrite the default whitelist with <group/version/kind> for --prune",
args: {
name: "group/version/kind",
},
},
{
name: ["--server-side"],
description:
"If true, apply runs in the server instead of the client.",
},
{
name: ["--timeout"],
insertValue: "--timeout=",
description:
"The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object",
args: {
name: "INT (Seconds)",
},
},
{
name: ["--validate"],
description:
"If true, use a schema to validate the input before sending it",
},
{
name: ["--wait"],
description:
"If true, wait for resources to be gone before returning. This waits for finalizers.",
},
]),
subcommands: [
{
name: "edit-last-applied",
description:
"Edit the latest last-applied-configuration annotations of resources from the default editor.",
args: [
sharedArgs.typeOrTypeSlashName,
sharedArgs.resourceSuggestionsFromResourceType,
],
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.output,
sharedOpts.record,
sharedOpts.recursive,
sharedOpts.template,
{
name: ["--windows-line-endings"],
description:
"Defaults to the line ending native to your platform.",
},
{
name: ["--field-manager"],
description: "Name of the manager used to track field ownership.",
args: {},
},
{
name: ["--show-manged-fields"],
description:
"If true, keep the managedFields when printing objects in JSON or YAML format.",
},
],
},
{
name: "set-last-applied",
description:
"Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f<file> ' was run, without updating any other parts of the object.",
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.filename,
sharedOpts.output,
sharedOpts.template,
{
name: ["--show-manged-fields"],
description:
"If true, keep the managedFields when printing objects in JSON or YAML format.",
},
{
name: ["--create-annotation"],
description:
"Will create 'last-applied-configuration' annotations if current objects doesn't have one",
},
],
},
{
name: "view-last-applied",
description:
"View the latest last-applied-configuration annotations by type/name or file.",
args: [
sharedArgs.typeOrTypeSlashName,
sharedArgs.resourceSuggestionsFromResourceType,
],
options: [
sharedOpts.allResources,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.output,
sharedOpts.recursive,
sharedOpts.selector,
],
},
],
},
{
name: "attach",
description:
"Attach to a process that is already running inside an existing container.",
args: sharedArgs.runningPodsArg,
options: [
{
name: ["-c", "--container"],
description:
"Container name. If omitted, the first container in the pod will be chosen",
args: sharedArgs.listContainersFromPod,
},
{
name: ["--pod-running-timeout"],
insertValue: "-pod-running-timeout=",
description:
"The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running",
args: {},
},
{
name: ["-i", "--stdin"],
description: "Pass stdin to the container",
},
{
name: ["-t", "--tty"],
description: "Stdin is a TTY",
},
],
},
{
name: "auth",
description: "Inspect authorization",
subcommands: [
{
name: "can-i",
description: "Check whether an action is allowed.",
args: [
{
name: "VERB",
suggestions: ["get", "list", "watch", "delete"],
},
sharedArgs.typeOrTypeSlashName,
sharedArgs.resourceSuggestionsFromResourceType,
],
options: [
{
name: ["-A", "--all-namespaces"],
description:
"If true, check the specified action in all namespaces.",
},
{
name: ["--list"],
description: "If true, prints all allowed actions.",
},
{
name: ["--no-headers"],
description: "If true, prints allowed actions without headers",
},
{
name: ["-q", "--quiet"],
description:
"If true, suppress output and just return the exit code.",
},
{
name: ["--subresource"],
insertValue: "--subresource=",
description: "SubResource such as pod/log or deployment/scale",
// TODO: Generator here
args: {},
},
],
},
{
name: "reconcile",
description:
"Reconciles rules for RBAC Role, RoleBinding, ClusterRole, and ClusterRole binding objects.",
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.dryRun,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.output,
sharedOpts.recursive,
sharedOpts.template,
{
name: ["--remove-extra-permissions"],
description: "If true, removes extra permissions added to roles",
},
{
name: ["--remove-extra-subjects"],
description:
"If true, removes extra subjects added to rolebindings",
},
{
name: ["--show-managed-fields"],
description:
"If true, keep the managedFields when printing objects in JSON or YAML format.",
},
],
},
],
},
{
name: "autoscale",
description:
"Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.",
args: [
sharedArgs.typeOrTypeSlashName,
sharedArgs.resourceSuggestionsFromResourceType,
],
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.output,
sharedOpts.record,
sharedOpts.recursive,
sharedOpts.dryRun,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.template,
{
name: ["--cpu-percent"],
insertValue: "--cpu-percent=",
description:
"The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used.",
args: {
name: "INT (Percent)",
},
},
{
name: ["--generator"],
insertValue: "--generator=",
description:
"The name of the API generator to use. Currently there is only 1 generator.",
args: {},
},
{
name: ["--max"],
insertValue: "--max=",
description:
"The upper limit for the number of pods that can be set by the autoscaler. Required.",
args: {
name: "INT",
},
},
{
name: ["--min"],
insertValue: "--min=",
description:
"The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value.",
args: {
name: "INT",
},
},
{
name: ["--name"],
insertValue: "--name=",
description:
"The name for the newly created object. If not specified, the name of the input resource will be used.",
args: {},
},
{
name: ["--save-config"],
description:
"If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.",
},
],
},
{
name: "certificate",
description: "Modify certificate resources.",
subcommands: [
{
name: "approve",
description: "Approve a certificate signing request.",
args: {
name: "NAME",
},
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.output,
sharedOpts.recursive,
sharedOpts.template,
{
name: ["--force"],
description: "Update the CSR even if it is already approved.",
},
],
},
{
name: "deny",
description: "Deny a certificate signing request.",
args: {
name: "NAME",
},
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.filename,
sharedOpts.kustomize,
sharedOpts.output,
sharedOpts.recursive,
sharedOpts.template,
{
name: ["--force"],
description: "Update the CSR even if it is already approved.",
},
],
},
],
},
{
name: "cluster-info",
description:
"Display addresses of the master and services with label kubernetes.io/cluster-service=true To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.",
subcommands: [
{
name: "dump",
description:
"Dumps cluster info out suitable for debugging and diagnosing cluster problems. By default, dumps everything to stdout. You can optionally specify a directory with --output-directory. If you specify a directory, kubernetes will build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.",
options: [
sharedOpts.allowMissingTemplateKeys,
sharedOpts.output,
sharedOpts.template,
{
name: ["-A", "--all-namespaces"],
description:
"If true, dump all namespaces. If true, --namespaces is ignored.",
},
{
name: ["--namespaces"],
description: "A comma separated list of namespaces to dump.",
args: {
name: "Namespaces (Comma seperated)",
},
},
{
name: ["--output-directory"],
insertValue: "--output-directory=",
description:
"Where to output the files. If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory",
args: {},
},
{
name: ["--pod-running-timeout"],
insertValue: "--pod-running-timeout=",
description:
"The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running",
args: {
name: "Length of Time",
},
},
{
name: ["--show-managed-fields"],
description:
"If true, keep the managedFields when printing objects in JSON or YAML format.",
},
],
},
],
},
{
name: "completion",
description:
"Output shell completion code for the specified shell (bash or zsh). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash_profile.",
},
{
name: "config",
description:
'Modify kubeconfig files using subcommands like "kubectl config set current-context my-context"',
options: [
{
name: "--kubeconfig",
insertValue: "--kubeconfig=",
args: {
name: "path",
template: "filepaths",
},
},
],
subcommands: [
{
name: "current-context",
description: "Displays the current-context",
},
{
name: "delete-cluster",
description: "Delete the specified cluster from the kubeconfig",
args: sharedArgs.listClusters,
},
{
name: "delete-context",
description: "Delete the specified context from the kubeconfig",
args: sharedArgs.listKubeConfContexts,
},
{
name: "get-clusters",
description: "Display clusters defined in the kubeconfig.",
},
{
name: "get-contexts",
description:
"Displays one or many contexts from the kubeconfig file.",
args: { ...sharedArgs.listKubeConfContexts, isOptional: true },
options: [
sharedOpts.output,
{
name: ["--no-headers"],
description:
"When using the default or custom-column output format, don't print headers (default print headers).",
args: {},
},
],
},
{
name: "get-users",
description: "Display users defined in the kubeconfig.",
},
{
name: "rename-context",
description: "Renames a context from the kubeconfig file.",
args: [
sharedArgs.listKubeConfContexts,
{
name: "New Context Name",
},
],
},
{
name: "set",
description: "Sets an individual value in a kubeconfig file",
args: [
{
name: "PROPERTY_NAME",
},
{
name: "PROPERTY_VALUE",
},
],
options: [
{
name: ["--set-raw-bytes"],
description:
"When writing a []byte PROPERTY_VALUE, write the given string directly without base64 decoding.",
args: {},
},
],
},
{
name: "set-cluster",
description: "Sets a cluster entry in kubeconfig.",
args: {
name: "NAME",
},
options: [
{
name: ["--embed-certs"],
description: "embed-certs for the cluster entry in kubeconfig",
},
{
name: ["--server"],
insertValue: "--server=",
args: {
name: "Server",
},
},
{
name: ["--certificate-authority"],
insertValue: "--certificate-authority=",
description: "Path to certificate authority",
args: {
name: "Certificate Authority",
template: "filepaths",
},
},
{
name: ["--insecure-skip-tls-verify"],
insertValue: "--insecure-skip-tls-verify=",
args: {
suggestions: ["true", "false"],
},
},
{
name: ["--tls-server-name"],
insertValue: "--tls-server-name=",
args: {
name: "TLS Server Name",
},
},
],
},
{
name: "set-context",
description: "Sets a context entry in kubeconfig",
args: sharedArgs.listKubeConfContexts,
options: [
{
name: ["--current"],
description: "Modify the current context",
},
{
name: ["--cluster"],
insertValue: "--cluster=",
args: {
name: "cluster_nickname",
},
},
{
name: ["--user"],
insertValue: "--user=",
args: {
name: "user_nickname",
},
},
{
name: ["--namespace"],
insertValue: "--namespace=",
args: {
name: "namespace",
},
},
],
},
{
name: "set-credentials",
description: "Sets a user entry in kubeconfig",
args: sharedArgs.listClusters,
options: [
{
name: ["--client-certificate"],
insertValue: "--client-certificate=",
description: "Client cert for user entry",