diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7679a61..0000000 --- a/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# syntax=docker/dockerfile:1 - -# Build stage -FROM golang:1.20 as build - -ARG BUILD_VERSION=v0.0.0 -ARG BUILD_COMMIT=HEAD -ARG BUILD_DATE=unknown - -WORKDIR /src - -COPY go.mod go.sum ./ -RUN go mod download - -COPY . . - -RUN CGO_ENABLED=0 go build \ - -ldflags "-X main.version=${BUILD_VERSION} -X main.commit=${BUILD_COMMIT} -X main.date=${BUILD_DATE}" \ - -o bin/kexp main.go - -# App stage -FROM alpine:3.18 - -COPY --from=build /src/bin/kexp /usr/local/bin/kexp - -EXPOSE 5173 - -CMD ["kexp", "--host", "127.0.0.1", "--port", "5173"] diff --git a/Makefile b/Makefile index 6c4bfb4..4b8c716 100644 --- a/Makefile +++ b/Makefile @@ -28,30 +28,14 @@ front-lint-fix: front-build: cd ${CUR_DIR}/ui && npm run build -.PHONY: build -build: +.PHONY: build-dev +build-dev: cd ${CUR_DIR}/ui && npm run build go build -o ${CUR_DIR}/bin/kexp ${CUR_DIR}/main.go CGO_ENABLED=0 go build \ -ldflags "-X main.version=${VERSION} -X main.commit=${GIT_COMMIT} -X main.date=${UTC_NOW}" \ -o ${CUR_DIR}/bin/kexp main.go -.PHONY: docker-build -docker-build: - cd ${CUR_DIR}/ui && npm run build - docker buildx build \ - --progress plain \ - --build-arg BUILD_VERSION=${VERSION} \ - --build-arg BUILD_COMMIT=${GIT_COMMIT} \ - --build-arg BUILD_DATE=${UTC_NOW} \ - -t ghcr.io/iximiuz/kexp:latest \ - -f ${CUR_DIR}/Dockerfile \ - ${CUR_DIR} - -.PHONY: docker-push -docker-push: docker-build - docker push ghcr.io/iximiuz/kexp:latest - .PHONY: release release: goreleaser --clean diff --git a/README.md b/README.md index 8c804bb..ab25336 100644 --- a/README.md +++ b/README.md @@ -6,40 +6,109 @@ Not yet another attempt to manage production clusters in the browser. k'exp is for: - Learning and exploring Kubernetes capabilities -- Application development (object graph "presets" for every app) -- Controller and operator development (dynamic object graph) -- [coming soon] Postman-like client for Kubernetes API +- Application development (object graph _presets_ for every app) +- Controller and operator development (dynamic object graphs) +- [coming soon] Postman-like client and request builder for Kubernetes API +k'exp can reflect the state of your cluster in real-time: -## How to run +![k'exp in action](./assets/images/kexp-cluster-changes.gif) -It's a single Go binary with embedded UI. +k'exp can also give you a quick overview of "related" objects: + +![k'exp in action](./assets/images/kexp-preset-related-objects.gif) + +...as well as show object-specific insights: + +![k'exp in action](./assets/images/kexp-pod-insights-min.png) + +## In the wild + +You can try k'exp at every [Kubernetes Playground](https://labs.iximiuz.com/playgrounds?category=kubernetes) on iximiuz Labs. +Some tutorials also use k'exp to visualize Kubernetes objects and their relationships: + +- [Making Sense Out of Native Sidecar Containers in Kubernetes](https://labs.iximiuz.com/tutorials/kubernetes-native-sidecars) + +You can also find [a few short demos on YouTube](https://www.youtube.com/playlist?list=PL3ea3TG5uHXhzzk9gK4oNQk14lYyxdxPx). + + +## Installation + +Grab the latest release from GitHub: + +```sh +GOOS=linux +GOARCH=amd64 + +curl -Ls https://github.com/iximiuz/kexp/releases/latest/download/kexp_${GOOS}_${GOARCH}.tar.gz | tar xvz + +sudo mv kexp /usr/local/bin +``` + +At the moment, the only system `kexp` is actively tested on is Linux amd64, +but builds for Darwin amd64/arm64 and Linux arm64 are also available. + + +## Usage + +It's a statically linked Go binary with an embedded UI. If you already have `kubectl` configured to access your cluster(s), you can run `kexp` too - it uses the same `KUBECONFIG` discovery logic. +By default, `kexp` starts a server on `localhost:5173`: + ```sh +kexp + +open localhost:5173 +``` + +Alternatively, you can specify a custom address: + +```sh +kexp --host 0.0.0.0 --port 8090 ``` +## How it works + +`kexp` is a daemon that uses the local `KUBECONFIG` to access Kubernetes API. +Thus, it's as powerful (and potentially **destructive!**) as your `kubectl` can get. +The daemon lists Kubernetes API resources and objects, +may start a bunch of watchers for the objects of interest, +and even delete objects if you ask it to (via the UI). +The UI is a single-page application written in TypeScript and Vue and embedded into the daemon binary. + + ## Development -Server: +Pre-requisites: ```sh go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -``` - -Client: -```sh cd ui npm install -npm run dev + +# Optional +kind create cluster +# ...or +minikube start ``` +Running the dev server and the UI is easy: + ```sh -make front-run-dev +# In terminal 1 make back-run-dev -open localhost:5173 +# In terminal 2 +make front-run-dev ``` + +After that, you can access the UI at `http://localhost:5173`. + + +## Contributing + +Contributions are welcome! diff --git a/assets/images/kexp-cluster-changes.gif b/assets/images/kexp-cluster-changes.gif new file mode 100644 index 0000000..f7ae1b4 Binary files /dev/null and b/assets/images/kexp-cluster-changes.gif differ diff --git a/assets/images/kexp-pod-insights-min.png b/assets/images/kexp-pod-insights-min.png new file mode 100644 index 0000000..406b6a7 Binary files /dev/null and b/assets/images/kexp-pod-insights-min.png differ diff --git a/assets/images/kexp-preset-related-objects.gif b/assets/images/kexp-preset-related-objects.gif new file mode 100644 index 0000000..20e769a Binary files /dev/null and b/assets/images/kexp-preset-related-objects.gif differ diff --git a/main.go b/main.go index b8da068..6debe22 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ func main() { flags.AddFlags(cmd.PersistentFlags()) cmd.PersistentFlags().StringVar(&flags.host, "host", "127.0.0.1", "Listening host") - cmd.PersistentFlags().StringVar(&flags.port, "port", "8090", "Listening port") + cmd.PersistentFlags().StringVar(&flags.port, "port", "5173", "Listening port") if err := cmd.Execute(); err != nil { logrus.WithError(err).Fatal("Command failed") diff --git a/ui/dist/.keep b/ui/dist/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/ui/vite.config.js b/ui/vite.config.js index ab4a745..1ac2a1f 100644 --- a/ui/vite.config.js +++ b/ui/vite.config.js @@ -17,7 +17,7 @@ export default defineConfig({ server: { proxy: { '/api': { - target: 'http://localhost:8090', + target: 'http://localhost:5173', changeOrigin: true, ws: true, },