├── LICENSE
├── README.md
├── Troubleshooting.md
├── kubectl-exec
└── resources
└── img
├── filemanager.gif
├── interactive.gif
├── kubectl-exec.png
├── mount-windows.gif
└── non-interactive.gif
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |     
4 |
5 |
6 |
7 |
8 |
9 | # kubectl-exec:
10 | Kubectl-exec is an interactive bash script that allows you to perform tasks on Windows and Linux kubernetes nodes. Such as accessing nodes shell, mounting a node filesystem, and accessing nodes filesystem in an easy-to-use web interface.
11 |
12 |
13 |
14 | # Key Features
15 |
16 | - Access Windows/Linux nodes shell interactively
17 |
18 | 
19 |
20 | - Access Windows/Linux nodes shell non-interactively
21 |
22 | 
23 |
24 | - Mount Windows/Linux filesystem to pod, can be used to explore or transfer files.
25 |
26 | 
27 |
28 | - Expose a web based file manager for managing files and folders and transfer data between nodes and your local machine.
29 |
30 | 
31 |
32 |
33 |
34 | # How it works:
35 |
36 | **For Linux:**
It works by creating a pod (with a priviledged container) in the node you specified and using nsenter for getting a shell into your kuberntes nodes.
37 |
38 | The created pod is from alpine official image which is ~2.6 mb in size, once you exit the shell, the pod will be deleted.
39 |
40 | **For Windows:**:
It works by creating a pod and using Windows SSH credentials to access Windows node or mounting the filesystem to the linux pod.
41 |
42 | **Why using linux pods to access Windows nodes ?**
43 | This is because windows container images are large in size 3GB+; instead, we are using a linux alpine image that is less than 3MB.
44 |
45 | > Notice: Windows nodes supports only nodes with OpenSSH installed.
46 | https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
47 |
48 | > This have been tested on AKS nodes which has OpenSSH installed by default.
49 |
50 |
51 |
52 | ## Installation:
53 | ```bash
54 | wget https://github.com/mohatb/kubectl-exec/raw/master/kubectl-exec
55 | chmod +x ./kubectl-exec
56 | sudo mv ./kubectl-exec /usr/local/bin/kubectl-exec
57 | ```
58 |
59 | ## Updating:
60 | ```bash
61 | sudo rm -rf $(which kubectl-exec)
62 | wget https://github.com/mohatb/kubectl-exec/raw/master/kubectl-exec
63 | chmod +x ./kubectl-exec
64 | sudo mv ./kubectl-exec /usr/local/bin/kubectl-exec
65 | ```
66 |
67 | ## Usage:
68 | ```bash
69 | Interactive:
70 | kubectl-exec
71 |
72 | Non-Interactive:
73 | kubectl-exec NodeName
74 |
75 | Examples:
76 | Access node shell:
77 | kubectl-exec
78 | kubectl-exec NodeName
79 |
80 | Mount The host filesystem to priviliged pod:
81 | kubectl-exec -mount
82 | kubectl-exec -mount NodeName
83 |
84 | Access node filesystem with web interface in the browser:
85 | kubectl-exec -filemanager
86 | kubectl-exec -filemanager NodeName
87 | ```
88 |
89 |
90 | # Troubleshooting:
91 | Please refer to troubleshooting section [Troubleshooting](Troubleshooting.md)
92 |
93 | # Contributing
94 | We welcome pull requests with open arms! There's a lot of work to do here, and we're especially concerned with ensuring the longevity and reliability of the project.
95 |
96 |
97 | ## Contributors
98 |
99 |
100 |
101 |
102 |
103 | # License
104 |
105 | This project is licensed under the [Apache License, Version 2.0](LICENSE).
106 |
--------------------------------------------------------------------------------
/Troubleshooting.md:
--------------------------------------------------------------------------------
1 | ## Windows AKS nodes does not have SSH Username/password:
2 |
3 | You can create windows SSH user/pass with azure CLI, this requires reimaging vmss instances
4 |
5 | ```bash
6 | VMSS=
7 | VMSSRG=
8 | WINADMINUSER=
9 | WINADMINPASS=
10 | az vmss update --resource-group $VMSSRG --name $VMSS --set "virtualMachineProfile.osProfile.adminUsername=$WINADMINUSER"
11 | az vmss update --resource-group $VMSSRG --name $VMSS --set "virtualMachineProfile.osProfile.adminPassword=$WINADMINPASS"
12 | az vmss update-instances --instance-ids "*" --resource-group $VMSSRG --name $VMSS
13 | #add --instance-id if you want to specify a specific image
14 | #Example: az vmss reimage --instance-id 1 --resource-group $VMSSRG --name $VMSS
15 | az vmss reimage --resource-group $VMSSRG --name $VMSS
16 | ```
--------------------------------------------------------------------------------
/kubectl-exec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #Check kubectl client exists
4 | if ! command -v kubectl &> /dev/null
5 | then
6 | printf "Kubectl client could not be found. Please install Kubectl client before running kubectl-exec.\nRefer to: https://kubernetes.io/docs/tasks/tools/\n\n"
7 | exit 1
8 | fi
9 |
10 | #Check client major/minor versions
11 | kubectl_major_version=$(kubectl version --client -o yaml | grep -i "major" | awk '{ print $2 }' | sed 's/"//g')
12 | kubectl_minor_version=$(kubectl version --client -o yaml | grep -i "minor" | awk '{ print $2 }' | sed 's/"//g')
13 |
14 | if [[ $kubectl_major_version -gt 1 ]] || [[ $kubectl_major_version -eq 1 && $kubectl_minor_version -ge 18 ]]
15 | then
16 | use_generator=false
17 | echo "Kuberetes client version is $kubectl_major_version.$kubectl_minor_version. Generator will not be used since it is deprecated."
18 | elif [[ $kubectl_major_version -eq 1 && $kubectl_minor_version -lt 18 ]]
19 | then
20 | use_generator=true
21 | echo "Kuberetes client version is $kubectl_major_version.$kubectl_minor_version. Generator will be used."
22 | else
23 | echo "Invalid kubectl version, exiting."
24 | exit 1
25 | fi
26 |
27 | #Usage message
28 | usage()
29 | {
30 | echo 'Interactive:'
31 | echo '$ kubectl-exec'
32 | echo " "
33 | echo 'Non-Interactive'
34 | echo '$ kubectl-exec NODE'
35 | echo ""
36 | echo "Examples:"
37 | echo ""
38 | echo "Access node shell:"
39 | echo "kubectl-exec"
40 | echo "kubectl-exec minikube"
41 | echo ""
42 | echo "Mount The host filesystem to priviliged pod"
43 | echo "kubectl-exec -mount"
44 | echo "kubectl-exec -mount node1"
45 | echo ""
46 | echo "Access node filesystem with web interface in the browser:"
47 | echo "kubectl-exec -filemanager"
48 | echo "kubectl-exec -filemanager node1"
49 | echo " "
50 | exit 0
51 | }
52 |
53 | #windows function to ssh to linux nodes
54 | LINUXNODES () {
55 |
56 | IMAGE="alpine"
57 | POD="$NODE-exec-$(echo $RANDOM)"
58 |
59 | # Check the node existance
60 | kubectl get node "$NODE" >/dev/null || exit 1
61 |
62 | #nsenter JSON overrrides
63 | OVERRIDES="$(cat </dev/null || exit 1
110 | WINNODEIP=$(kubectl get node $NODE --output=jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
111 |
112 | #nsenter JSON overrrides
113 | OVERRIDES="$(cat </dev/null || exit 1
166 |
167 | OVERRIDES="$(cat < Node:"
199 | echo "kubectl cp /etc/hostname default/$POD:/tmp/hostname"
200 | echo ""
201 | echo "From Node -> Local"
202 | echo "kubectl cp default/$POD:/etc/hostname /tmp/hostname"
203 | echo ""
204 |
205 | if [ $use_generator = true ]
206 | then
207 | kubectl run --image $IMAGE --overrides="$OVERRIDES" --generator=run-pod/v1 "$POD"
208 | else
209 | kubectl run --image $IMAGE --overrides="$OVERRIDES" "$POD"
210 | fi
211 |
212 | }
213 |
214 | # Windows -mount function
215 | WINDOWSHOSTMOUNT () {
216 | IMAGE="mohatb/mountcifs"
217 | POD="$NODE-host-filemanager"
218 |
219 | # Check the node existance
220 | kubectl get node "$NODE" >/dev/null || exit 1
221 | read -p "Enter the windows ssh username: " WINDOWSSSHUSERNAME
222 | read -s -p "Enter the windows ssh password: " WINDOWSSSHPASSWORD
223 | echo ""
224 | WINDOWSIPADDRESS=$(kubectl get node $NODE --output=jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
225 |
226 | OVERRIDES="$(cat < Node:"
263 | echo "kubectl cp /etc/hostname default/$POD:/mnt/winsows_share/c/tmp/hostname.txt"
264 | echo ""
265 | echo "From Node -> Local"
266 | echo "kubectl cp default/$POD:/mnt/windows_share/c/Windows/System32/drivers/etc/hosts /tmp/hosts"
267 | echo ""
268 |
269 |
270 | if [ $use_generator = true ]
271 | then
272 | kubectl run --image $IMAGE --overrides="$OVERRIDES" --generator=run-pod/v1 "$POD"
273 | else
274 | kubectl run --image $IMAGE --overrides="$OVERRIDES" "$POD"
275 | fi
276 | }
277 |
278 | #Function for -filemanager browser on Linux
279 |
280 | EXECFILEMANAGERLINUX () {
281 |
282 | IMAGE="mohatb/filemanager:latest"
283 | POD="$NODE-host-filemanager"
284 | echo "$NODE"
285 |
286 | # Check the node existance
287 | kubectl get node "$NODE" >/dev/null || exit 1
288 |
289 | OVERRIDES="$(cat < ${BLUE}kubectl port-forward $POD 8002:80${NC}"
333 | echo ""
334 | echo "Open your browser and go to the below URL"
335 | echo -e "> ${BLUE}http://127.0.0.1:8002${NC}"
336 | echo ""
337 |
338 | if [ $use_generator = true ]
339 | then
340 | kubectl run --image $IMAGE --overrides="$OVERRIDES" --generator=run-pod/v1 "$POD"
341 | else
342 | kubectl run --image $IMAGE --overrides="$OVERRIDES" "$POD"
343 | fi
344 |
345 | }
346 |
347 | #Function to start filemanager with -filemanager flag on windows nodes.
348 | EXECFILEMANAGERWINDOWS() {
349 |
350 | IMAGE="mohatb/filemanager:withcifs"
351 | POD="$NODE-host-filemanager"
352 |
353 | # Check the node existance
354 | kubectl get node "$NODE" >/dev/null || exit 1
355 | read -p "Enter the windows ssh username: " WINDOWSSSHUSERNAME
356 | read -s -p "Enter the windows ssh password: " WINDOWSSSHPASSWORD
357 | WINDOWSIPADDRESS=$(kubectl get node $NODE --output=jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}')
358 |
359 | OVERRIDES="$(cat < ${BLUE}kubectl port-forward $POD 8002:80${NC}"
397 | echo ""
398 | echo "Open your browser and go to the below URL"
399 | echo -e "> ${BLUE}http://127.0.0.1:8002${NC}"
400 | echo ""
401 |
402 | if [ $use_generator = true ]
403 | then
404 | kubectl run --image $IMAGE --overrides="$OVERRIDES" --generator=run-pod/v1 "$POD"
405 | else
406 | kubectl run --image $IMAGE --overrides="$OVERRIDES" "$POD"
407 | fi
408 |
409 | }
410 |
411 |
412 | ##########################################################################
413 | #Exection Start
414 | ##########################################################################
415 |
416 | #Colors for echo command
417 | RED='\033[0;31m'
418 | BLUE='\033[0;34m'
419 | Green='\033[0;32m'
420 | NC='\033[0m'
421 |
422 |
423 | #check if user is looking for documentation with -h
424 | if [ "$1" = "-h" ]
425 | then
426 | usage
427 | exit 1
428 | fi
429 |
430 | #Check user input for shell access
431 | if [ -z "$1" ]; then
432 |
433 | mapfile -t nodenumber < <( kubectl get nodes --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' )
434 |
435 | for i in "${!nodenumber[@]}"; do
436 | printf "$i ${nodenumber[i]} \n"
437 | done
438 |
439 | read -p "Enter the node number: " NODE_INDEX
440 | NODE=${nodenumber[NODE_INDEX]}
441 |
442 | else
443 | NODE=$1
444 | fi
445 |
446 | #Statement to check if user is looking to mount root file system in linux nodes to the pod.
447 | if [ "$1" = "-mount" ] && [ -n "$2" ]; then
448 | #Check if the user provided node number
449 | NODE="$2"
450 | NODEOS=$(kubectl get node $NODE -o jsonpath="{.metadata.labels.\kubernetes\.io/os}")
451 | if [[ $NODEOS = "windows" ]]
452 | then
453 | WINDOWSHOSTMOUNT
454 | exit 1
455 | else
456 | LINUXHOSTMOUNT
457 | exit 1
458 | fi
459 | exit 1
460 | elif [ "$1" = "-mount" ] && [ -z "$2" ]; then
461 | #If the user did not provide a node number, use interactive to get it.
462 | mapfile -t nodenumber < <( kubectl get nodes --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' )
463 |
464 | for i in "${!nodenumber[@]}"; do
465 | printf "$i ${nodenumber[i]} \n"
466 | done
467 |
468 | read -p "Enter the node number: " NODE_INDEX
469 | NODE=${nodenumber[NODE_INDEX]}
470 | NODEOS=$(kubectl get node $NODE -o jsonpath="{.metadata.labels.\kubernetes\.io/os}")
471 | if [[ $NODEOS = "windows" ]]
472 | then
473 | WINDOWSHOSTMOUNT
474 | exit 1
475 | else
476 | LINUXHOSTMOUNT
477 | exit 1
478 | fi
479 | exit 1
480 | fi
481 |
482 | #Statement to check if user is looking to mount root file system in linux nodes to the pod.
483 | if [ "$1" = "-filemanager" ] && [ -n "$2" ]; then
484 | #Check if the user provided node number
485 | NODE="$2"
486 | NODEOS=$(kubectl get node $NODE -o jsonpath="{.metadata.labels.\kubernetes\.io/os}")
487 | if [[ $NODEOS = "windows" ]]
488 | then
489 | EXECFILEMANAGERWINDOWS
490 | exit 1
491 | else
492 | EXECFILEMANAGERLINUX
493 | exit 1
494 | fi
495 | exit 1
496 | #If the user did not provide a node number, use interactive to get it.
497 | elif [ "$1" = "-filemanager" ] && [ -z "$2" ]; then
498 | mapfile -t nodenum < <( kubectl get nodes --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' )
499 | for i in "${!nodenum[@]}"; do
500 | printf "$i ${nodenum[i]} \n"
501 | done
502 |
503 | read -p "Enter the node number: " NODE_INDEX
504 | NODE=${nodenum[NODE_INDEX]}
505 | NODEOS=$(kubectl get node $NODE -o jsonpath="{.metadata.labels.\kubernetes\.io/os}")
506 | if [[ $NODEOS = "windows" ]]
507 | then
508 | EXECFILEMANAGERWINDOWS
509 | exit 1
510 | else
511 | EXECFILEMANAGERLINUX
512 | exit 1
513 | fi
514 | exit 1
515 | fi
516 |
517 | #Evaluate if windows node.
518 | NODEOS=$(kubectl get node $NODE -o jsonpath="{.metadata.labels.\kubernetes\.io/os}")
519 |
520 | if [[ $NODEOS = "windows" ]]
521 | then
522 | WINDOWSNODES
523 | else
524 | LINUXNODES
525 | fi
526 |
--------------------------------------------------------------------------------
/resources/img/filemanager.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohatb/kubectl-exec/a11f335e14bda0f8b9522dbf0871108d9236baf1/resources/img/filemanager.gif
--------------------------------------------------------------------------------
/resources/img/interactive.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohatb/kubectl-exec/a11f335e14bda0f8b9522dbf0871108d9236baf1/resources/img/interactive.gif
--------------------------------------------------------------------------------
/resources/img/kubectl-exec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohatb/kubectl-exec/a11f335e14bda0f8b9522dbf0871108d9236baf1/resources/img/kubectl-exec.png
--------------------------------------------------------------------------------
/resources/img/mount-windows.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohatb/kubectl-exec/a11f335e14bda0f8b9522dbf0871108d9236baf1/resources/img/mount-windows.gif
--------------------------------------------------------------------------------
/resources/img/non-interactive.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohatb/kubectl-exec/a11f335e14bda0f8b9522dbf0871108d9236baf1/resources/img/non-interactive.gif
--------------------------------------------------------------------------------