-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CLI with embedded server (#118)
* Adds a CLI that allows users to run Kubetail locally and make requests to a remote cluster using their local kube config file * Adds an experimental "extensionsEnabled" config flag to frontend and backend that enables/disables requests to agents
- Loading branch information
Showing
45 changed files
with
1,779 additions
and
308 deletions.
There are no files selected for viewing
This file contains 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 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,68 @@ | ||
# Define variables | ||
CLI_DIR := ./backend/cli | ||
OUTPUT_DIR := ./bin | ||
CLI_BINARY := kubetail | ||
|
||
DASHBOARD_UI_DIR := ./frontend | ||
DASHBOARD_SERVER_DIR := ./backend/server | ||
|
||
# Detect the operating system | ||
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
ARCH := $(shell uname -m) | ||
|
||
# Default target | ||
all: build | ||
|
||
# Create the bin directory if it doesn't exist | ||
$(OUTPUT_DIR): | ||
mkdir -p $(OUTPUT_DIR) | ||
|
||
# Build the dashboard UI | ||
build-dashboard-ui: | ||
@echo "Building dashboard UI..." | ||
@cd $(DASHBOARD_UI_DIR) && pnpm install && pnpm build | ||
@echo "Copying dashboard-ui/dist to modules/dashboard/website..." | ||
@rm -rf $(DASHBOARD_SERVER_DIR)/website | ||
@cp -r $(DASHBOARD_UI_DIR)/dist $(DASHBOARD_SERVER_DIR)/website | ||
@touch $(DASHBOARD_SERVER_DIR)/website/.gitkeep | ||
@echo "Dashboard UI built and copied successfully." | ||
|
||
# Build CLI binary for host platform | ||
build-cli: | ||
@echo "Building kubetail CLI binary..." | ||
@cd $(CLI_DIR) && GOOS=darwin GOARCH=arm64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-darwin-arm64 ./main.go | ||
|
||
# Build all the CLI binaries | ||
build-cli-all: | ||
@echo "Building kubetail CLI binaries..." | ||
@cd $(CLI_DIR) && GOOS=darwin GOARCH=amd64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-darwin-amd64 ./main.go | ||
@echo "Built kubetail for darwin-amd64." | ||
@cd $(CLI_DIR) && GOOS=darwin GOARCH=arm64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-darwin-arm64 ./main.go | ||
@echo "Built kubetail for darwin-arm64." | ||
@cd $(CLI_DIR) && GOOS=linux GOARCH=amd64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-linux-amd64 ./main.go | ||
@echo "Built kubetail for linux-amd64." | ||
@cd $(CLI_DIR) && GOOS=linux GOARCH=arm64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-linux-arm64 ./main.go | ||
@echo "Built kubetail for linux-arm64." | ||
@cd $(CLI_DIR) && GOOS=windows GOARCH=amd64 go build -o ../../$(OUTPUT_DIR)/$(CLI_BINARY)-windows-adm64 ./main.go | ||
@echo "Built kubetail for windows-amd64." | ||
@echo "Kubetail CLI binaries built successfully." | ||
|
||
# Build the CLI | ||
build: build-dashboard-ui build-cli | ||
|
||
# Build the CLI | ||
build-all: build-dashboard-ui build-cli-all | ||
|
||
## Clean the build output | ||
clean: | ||
@echo "Cleaning up..." | ||
@rm -rf $(OUTPUT_DIR) | ||
@echo "Cleanup done" | ||
|
||
# Help message | ||
help: | ||
@echo "Makefile targets:" | ||
@echo " all - Build the kubetail CLI" | ||
@echo " build - Compile the kubetail CLI for the current OS" | ||
@echo " clean - Remove the built binaries" | ||
@echo " help - Show this help message" |
This file contains 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 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 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 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,49 @@ | ||
// Copyright 2024 Andres Morey | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// rootCmd represents the base command when called without any subcommands | ||
var rootCmd = &cobra.Command{ | ||
Use: "kubetail", | ||
Version: "0.0.1", | ||
Short: "Kubetail - Kubernetes Logging Utility", | ||
} | ||
|
||
// Execute adds all child commands to the root command and sets flags appropriately. | ||
// This is called by main.main(). It only needs to happen once to the rootCmd. | ||
func Execute() { | ||
err := rootCmd.Execute() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
// Here you will define your flags and configuration settings. | ||
// Cobra supports persistent flags, which, if defined here, | ||
// will be global for your application. | ||
|
||
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cli.yaml)") | ||
|
||
// Cobra also supports local flags, which will only run | ||
// when this action is called directly. | ||
//rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
Oops, something went wrong.