Giter Site home page Giter Site logo

havener's Introduction

Havener /ˈheɪvənə/

License Go Report Card Tests Codecov Go Reference Release

havener

Table of Contents

Introducing Havener

If you use a Kubernetes cluster, chances are very high that you use kubectl a lot. These are fine tools and allow you to do everything you need to do, but there are use cases where you end up with a very long kubectl command in your terminal. This is why we created havener to introduce a convenience wrapper around kubectl. Think of it as a swiss army knife for Kubernetes tasks. Possible use cases are for example executing a command on multiple pods at the same time, or retrieving usage details.

Ok, tell me more

To see a detail list of all havener commands, please refer to the command documentation.

Like kubectl, havener relies on the Kubernetes configuration that can be set via the KUBECONFIG environment variable. It can also be provided with the --kubeconfig flag, which takes the path to the YAML file (for example $HOME/.kube/config).

Notable Use Cases

Usage overview

havener Quickly get a live overview of the current cluster usage details, for example Load, CPU, and Memory of the cluster nodes.

Pods in namespace overview

havener Watch pods in multiple namespaces with added colors to help identify the respective state.

Havener Commands

How do I get started

There are different ways to get havener. You are free to pick the one that makes the most sense for your use case.

  • On macOS systems, a Homebrew tap is available to install havener:

    brew install homeport/tap/havener
  • Use a convenience script to download the latest release to install it in a suitable location on your local machine:

    curl -sL https://raw.githubusercontent.com/homeport/havener/main/scripts/download-latest.sh | bash
  • Of course, you can also build it from source code (only for development):

    go install github.com/homeport/havener/cmd/havener

Contributing

We are happy to have other people contributing to the project. If you decide to do that, here's how to:

  • get Go (havener requires Go version 1.20 or greater)
  • fork the project
  • create a new branch
  • make your changes
  • open a PR.

Git commit messages should be meaningful and follow the rules nicely written down by Chris Beams:

The seven rules of a great Git commit message

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

Running test cases and binaries generation

There are multiple make targets, but running all does everything you want in one call.

make all

Test it with Linux on your macOS system

The best way to test is to use Docker to spin up a container:

docker run \
  --interactive \
  --tty \
  --rm \
  --volume $GOPATH/src/github.com/homeport/havener:/go/src/github.com/homeport/havener \
  --workdir /go/src/github.com/homeport/havener \
  golang:latest /bin/bash

Package dependencies (Go modules)

The Go module setup can be frustrating, if you have to update Kubernetes API libraries. In general, using go get with a specific version based on a tag is known to work, for example go get k8s.io/[email protected]. In case you run into difficulties, please do not hesitate to reach out to us.

License

Licensed under MIT License

havener's People

Contributors

ansrev avatar dependabot-preview[bot] avatar dependabot[bot] avatar edwardstudy avatar github-actions[bot] avatar heavywombat avatar imgbotapp avatar m-lukas avatar qu1queee avatar tareqmamari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

havener's Issues

Report panic: runtime error: index out of range

Executing the command upgrade with the --config flag causes the following error.
According to @HeavyWombat, the bug is probably in /internal/hvnr/diffs.go:75.

Error Message:

runtime error: index out of range

Stacktrace:

runtime/debug.Stack(0xc0000e3690, 0x2140fbe, 0x11)
	/usr/local/go/src/runtime/debug/stack.go:24  0x9d
github.com/homeport/havener/internal/cmd.exitWithErrorAndIssue(0x216b748, 0x31, 0x232dd40, 0x2edf600)
	/Users/lukas.mueller/Projects/havener/internal/cmd/common.go:106  0x287
github.com/homeport/havener/internal/cmd.Execute.func1()
	/Users/lukas.mueller/Projects/havener/internal/cmd/root.go:58  0x171
panic(0x1fba5c0, 0x2edf600)
	/usr/local/go/src/runtime/panic.go:522  0x1b5
github.com/homeport/havener/internal/hvnr.ShowHelmReleaseDiff(0xc000150150, 0x7, 0xc0001501b0, 0xe, 0xc0003ec3c0, 0x3c, 0x40, 0x0, 0xc0003ae000, 0x32756d0)
	/Users/lukas.mueller/Projects/havener/internal/hvnr/diffs.go:75  0x769
github.com/homeport/havener/internal/cmd.UpgradeViaHavenerConfig(0x7ffeefbffad7, 0x1b, 0xe, 0x7ffeefbffad7)
	/Users/lukas.mueller/Projects/havener/internal/cmd/upgrade.go:112  0x4fe
github.com/homeport/havener/internal/cmd.glob..func9(0x2eeade0, 0xc0003cc0e0, 0x0, 0x2, 0x0, 0x0)
	/Users/lukas.mueller/Projects/havener/internal/cmd/upgrade.go:56  0x64
github.com/spf13/cobra.(*Command).execute(0x2eeade0, 0xc0003cc040, 0x2, 0x2, 0x2eeade0, 0xc0003cc040)
	/Users/lukas.mueller/Projects/golang/pkg/mod/github.com/spf13/[email protected]/command.go:826  0x465
github.com/spf13/cobra.(*Command).ExecuteC(0x2eea8e0, 0x21cc5a0, 0x21cddd8, 0x109326f)
	/Users/lukas.mueller/Projects/golang/pkg/mod/github.com/spf13/[email protected]/command.go:914  0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/lukas.mueller/Projects/golang/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/homeport/havener/internal/cmd.Execute()
	/Users/lukas.mueller/Projects/havener/internal/cmd/root.go:66  0x60
main.main()
	/Users/lukas.mueller/Projects/havener/cmd/havener/main.go:42  0xcd

Need a better message format when deployment failed

When deployment failed, havener returned this message

binaries/havener-darwin-amd64  deploy --config examples/tomcat-deployment.yml
⠙ Creating Helm Release for tomcat-releaseMessage: Unable to create and initialize the tunnel, Error: could not find tiller

It contained two sentences.

Maybew we can split by : or other format:

⠙ Creating Helm Release for tomcat-release: Message: Unable to create and initialize the tunnel, Error: could not find tiller

Install tiller if not available

On a fresh cluster (e.g. minikube), there is not set-up for helm available. This means there is no tiller pod.

Proposal: Perform something like helm init as part of havener for the deploy command.

Is it possible to have a new parameter for top command so that just show one time

Right now, the havener top command will keep reporting top result.

I think in the future, it can be automated so that an automation script run one time to save the result for debugging or just for show for us.

So keep reporting may not work for that. Can we add a new parameter for example havener top -n 1 to just show the result 1 or x times?

Move ExitWithError out of havener package

The ExitWithError function is designed to provide an explanation to the end-user. It should be moved into the internal package. If possible, avoid using os.Exit() and experiment with runtime.Goexit() so that potential defer functions are honoured.

Replace client-go with kubernetes-sigs/controller-runtime

Describe the bug
cr

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Add `--no-cross-compile` flag to build script

Add --no-cross-compile flag to build script so that only a binary for the current platform is created. This flag should then be used in the Dockerfiles to avoid compiling macOS binaries if only the Linux one is required.

Add alternative root shell option

Investigate whether the following alternative would be feasible:

kubectl run r00t --restart=Never -ti --rm --image lol --overrides '{"spec":{"hostPID": true, "containers":[{"name":"1","image":"alpine","command":["nsenter","--mount=/proc/1/ns/mnt","--","/bin/bash"],"stdin": true,"tty":true,"securityContext":{"privileged":true}}]}}'

Add new blueprint functionality

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Change type of chart version to string

The mongoDB example chart can't be deployed because the env operator is a String but the field is unmarshaled as Integer before the operator is resolved. Because version numbers are often more complex than usual Integers, it makes sense to change the field type to String.

Havener purge must be more resilient

Failed to delete a Helm Release, which was in state FAILED:

secondsMessage: Error deploying chart, Error: rpc error: code = Unknown desc = release uaa failed: Service "uaa-uaa-public" is invalid: spec.externalIPs[0]: Invalid value: "a.root-servers.net.\nb.root-servers.net.\nc.root-servers.net.\nd.root-servers.net.\ne.root-servers.net.\nf.root-servers.net.\ng.root-servers.net.\nh.root-servers.net.\ni.root-servers.net.\nj.root-servers.net.\nk.root-servers.net.\nl.root-servers.net.\nm.root-servers.net.": must be a valid IP address, (e.g. 10.9.8.7)

Shell operator processing won't work with windows

Update: In theory, we can support havener configuration files with (( shell ... )) operator that can do things in Windows. However, we have to discuss if it makes sense to put time into this since it is currently not a priority to have havener fully functional on Windows systems.

Rewrite Verbose functions with vargs

To avoid something like verbose(fmt.Sprintf("%d", num)), let's try to refactor the code so that verbose() itself accepts vargs and a format string: verbose("num: %d", num).

@ansrev Could be something for you :)

Show output of deployment steps in real-time (no buffering)

Describe the bug
In case the pre-deployment step takes very long, one does not understand what is currently happening.

To Reproduce
Use a havener configuration with a pre-deployment step, which takes 120 s and prints out a status every second.

Expected behavior
Live output of the pre-deployment.

Screenshots
n/a

Additional context
n/a

Code clean-up/refactor for user versus backend logic

In general, we need to move to a design where end-user specific code like spinners, error message printing, verbose messages, or confirmations are solely in the internal packages. Everything else should be in the pkg/havener package.

Rework naming and description

The whole repo name and description should align itself to what the cli actually do, which is more like a toolkit for operating a kubernetes cluster. It is also more appealing.

Add pkg versioning

There are two major dependencies with delicate versioning requirements: client-go and helm. It could be that we have to introduce a versioning of the havener package itself to reflect that different versions of that are required to match with code with specific Kubernetes API packages, or helm.

So far we have not hit an issue so far, but it would be nice to discuss this issue and potential problems.

Enhance logs cmd to support custom directories

Describe the bug
Improve the logs cmd, to allow a user to specify an specific path inside the pod from which to get the logs

To Reproduce
DOES NOT APPLY

Expected behavior
User can specify the logs directory

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Align stucture of pod-exec and node-exec

Make sure that both pod-exec and node-exec feel and behave the same, that means similar named flags for the same purpose, or same assumptions in case of missing arguments (e.g. no command, default to /bin/bash).

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

build github.com/homeport/havener: cannot load github.com/homeport/dyff: cannot find module providing package github.com/homeport/dyff

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Improve the top command from the content and look wise perspective

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Encapsulate parts from deploy.go, upgrade.go and exec.go

Especially deploy.go and upgrade.go are very similar and have a lot of redundant code. Together with exec.go which also features config reading and parsing, it make sence to encapsulate parts of the code to remove redundant/duplicated code.

Add command to do Pod exec

Similar to node-exec, introduce pod-exec to have an easy way of getting a shell in a pod. Ideally, you do not provide any namespace or pod name and havener will give you a choice of pods to exec into.

Update readme with latest new features

  1. The --config file deserves a detail explanation in the README that covers the following features:
  • pre steps
  • post steps
  • retrieval of secrets via (( secret .. ))
  • usage of env variables via (( env ..))

Buffer output in certs before printing it

Right now, certs subcommand will print the details in the moment when they are processed. Especially when the verbose mode is enabled, you end up with output and verbose output being mixed.

Proposal: Buffer the output in something like var buf bytes.Buffer and print the verbose message whenever it is required. Once all data is collected, print the content of the buffer as one block.

@ansrev That could be something for you to pick up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.