This Go command-line tool, powered by Cobra and Viper, has been enhanced to provide new features and a more streamlined user experience. The codebase has been refactored to make it easier to configure and use. Now, all flags can be set either from a configuration file or directly on the command line. Additionally, it introduces different subcommands for various functionalities.
You can download the binary executable directly from the Releases Assets to start using it immediately.
If you have Go installed, you can also install SSH Pod Log Downloader using the following command:
go install github.com/ipsegs/sshpodlog@latestThis command will fetch and install the latest version of SSH Pod Log Downloader directly into your Go binary directory, making it accessible from your command line.
If you prefer building from source, follow these steps:
-
Clone the repository:
git clone https://github.com/ipsegs/sshpodlog.git
-
Navigate to the project directory:
cd sshpodlog -
Run the installation script:
./installer.sh
The script will prompt you to select the target operating system (Linux, macOS, or Windows) for building the executable. After making your selection, the script will build the executable accordingly. Once the installation is complete, you will find the built executable file in the project directory.
-
If you prefer to manually build the executable, ensure you have Go installed and follow these steps based on your target operating system:
-
Compiling for Linux:
GOOS=linux GOARCH=amd64 go build ./...
-
Compiling for macOS:
GOOS=darwin GOARCH=amd64 go build ./...
-
Compiling for Windows:
GOOS=windows GOARCH=amd64 go build ./...
-
The SSH Pod Log Downloader now offers three distinct subcommands, each serving a specific purpose:
-
File Subcommand: This subcommand helps you print the logs into a file and send the logs from the server to a local client server. Example usage:
sshpodlog file -f config-file.yaml
-
Terminal Subcommand: Use this subcommand to print the logs directly to the terminal. Example usage:
sshpodlog terminal -f config-file.yaml
-
Filter Subcommand: The filter subcommand allows you to filter logs based on a string and print them to the terminal. Example usage:
sshpodlog filter -r ERROR -f config-file.yaml
-
Tail Subcommand: The tail subcommand allows you to watch live logs as they come in to the terminal. Example usage:
sshpodlog tail -f config-file.yamlNote that the configuration file can be in YAML, JSON, TOML, or other supported formats.
Here's how the configuration file (e.g., config-file.yaml) looks in YAML format:
# SSH Pod Log Downloader Configuration
server: 192.168.1.100
port: 22
username: myuser
cluster: production
key: ~/.ssh/id_rsaThe following flags can be used:
--server(-s): The SSH server address.--username(-u): The SSH username.--cluster(-c): The Kubernetes context switch.--port(-p): The SSH port.--key(-k): The path to the SSH private key file.--from-file(-f): The path to the configuration file.
Contributions are welcome! If you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License.