-
Notifications
You must be signed in to change notification settings - Fork 15
NETOBSERV-1554 Add CLI to Krew index #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5051183
merge commands into unique bash
jpinsonneau 4e9ea0b
addressed feedback
jpinsonneau 230f083
force kubectl / oc only when not krew plugin
jpinsonneau 1a879eb
inject version
jpinsonneau ad143ad
krew index generation
jpinsonneau 07b68c0
prepare release with notes
jpinsonneau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ output | |
tmp | ||
cover.out | ||
kubeconfig | ||
netobserv-cli.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
source "./scripts/functions.sh" | ||
|
||
# interface filter such as 'br-ex' or pcap filter such as 'tcp,80' | ||
filter="" | ||
|
||
# CLI image to use | ||
img="quay.io/netobserv/network-observability-cli:main" | ||
|
||
# version to display | ||
version="0.0.1" | ||
|
||
# command to run | ||
command="" | ||
|
||
case "$1" in | ||
"help") | ||
# display Help | ||
echo | ||
echo "Netobserv allows you to capture flow and packets from your cluster." | ||
echo "Find more information at: https://github.com/netobserv/network-observability-cli/" | ||
echo | ||
echo "Syntax: netobserv [flows|packets|cleanup] [filters]" | ||
echo | ||
echo "options:" | ||
echo " flows Capture flows information. You can specify an optionnal interface name as filter such as 'netobserv flows br-ex'." | ||
echo " packets Capture packets from a specific protocol/port pair such as 'netobserv packets tcp,80'" | ||
echo " cleanup Remove netobserv components." | ||
echo " version Print software version." | ||
echo | ||
exit 0 ;; | ||
"version") | ||
# display version | ||
echo "Netobserv CLI version $version" | ||
exit 0 ;; | ||
"flows") | ||
if [ -z "${2:-}" ] | ||
then | ||
echo "Filters not set" | ||
else | ||
echo "Filters set as $2" | ||
filter=$2 | ||
fi | ||
# run flows command | ||
command="flows" ;; | ||
"packets") | ||
if [ -z "${2:-}" ]; then | ||
echo "Specify a valid filter as first argument such as 'tcp,80'" | ||
exit 1 | ||
else | ||
echo "Filters set as $2" | ||
filter=$2 | ||
fi | ||
# run packets command | ||
command="packets" ;; | ||
"cleanup") | ||
# run cleanup command | ||
cleanup | ||
exit 0 ;; | ||
*) | ||
echo "Unknown command $1. Use 'netobserv help' to display options" | ||
exit 1 | ||
esac | ||
|
||
trap cleanup EXIT | ||
|
||
setup $command $filter | ||
|
||
echo "Running network-observability-cli get-$command... " | ||
${K8S_CLI_BIN} run \ | ||
-n netobserv-cli \ | ||
collector \ | ||
--image=$img\ | ||
--image-pull-policy='Always' \ | ||
--restart='Never' \ | ||
--command -- sleep infinity | ||
|
||
${K8S_CLI_BIN} wait \ | ||
-n netobserv-cli \ | ||
--for=condition=Ready pod/collector | ||
|
||
${K8S_CLI_BIN} exec -i --tty \ | ||
-n netobserv-cli \ | ||
collector \ | ||
-- /network-observability-cli get-$command ${filter:+"--filter" "$filter"} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need this operation to be arch aware and generate tar ball for each arch ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to test it on different arch first. It may work out of box; else maybe just tweaking around the script.
On top, krew index allow you to point different binaries for each platform if needed