cilium / hubble

Hubble - Network, Service & Security Observability for Kubernetes using eBPF
Apache License 2.0
3.53k stars 253 forks source link

Add Hubble Binaries to Package Managers #307

Open jedsalazar opened 4 years ago

jedsalazar commented 4 years ago

I’m going through the kind install hubble-relay section which has users download the darwin-amd64 image for the hubble binary on the hubble/releases/download page. I’m thinking we should supply this binary in a package manager like brew (as well as other package managers for windows and Linux) so users automatically stay up-to-date without manually updating from the releases page.

This will likely save us confusion in the long-run as we won't have to consistently be asking what version of the local hubble binary was installed. It's also a better operator experience as most critical binaries on an operator's machine are installed and lifecycle-managed through package managers.

zhiyanfoo commented 3 years ago

Could you assign this issue to me? I have done some work already for homebrew. I might be available to work on other package manager but not guarantees.

Homebrew recommends that the formula builds the target using a tarballed source. The github release of this tarballed source omit the '.git' directory, so git commands ran in the Makefile fail.

I have two PR's that solve this issue in slightly different ways and have no strong preference to which one is chosen.

https://github.com/cilium/hubble/compare/master...zhiyanfoo:makefile-command-brew-opt1 https://github.com/cilium/hubble/compare/master...zhiyanfoo:makefile-command-brew-opt2

Alternatively we could have the formula clone the repo, omitting the need to modify the makefile. Glancing through the current accepted formulas, very few repositories go through this route.

The below formula should work nonetheless. Also available from https://github.com/zhiyanfoo/homebrew-experimental-tap. You can try it by running brew tap zhiyanfoo/experimental-tap and brew install hubble.

require 'open3'

class Hubble < Formula
  desc "Hubble - Network, Service & Security Observability for Kubernetes using eBPF"
  homepage "https://github.com/cilium/hubble"
  url "https://github.com/cilium/hubble.git",
      tag:      "v0.8.0"
  license "Apache-2.0"
  head "https://github.com/cilium/hubble.git"

  depends_on "go" => :build

  def install
    system 'make', 'hubble'
    bin.install 'hubble'
  end

  test do
    _, _, status = Open3.capture3("#{bin}/hubble", "version")

    assert_equal 0, status
  end
end

So to summarize

  1. Do we use the github release tarball or clone the git repo?
  2. If the former which PR to modify the Makefile?
  3. What other package managers would you like hubble to be available on?
rolinh commented 3 years ago

@zhiyanfoo Awesome! I assigned the issue to you.

Option 2 is definitely the way to go as this is how it was intended to work (note that || printf '' can be omitted from your patch as it's redundant).

  1. Do we use the github release tarball or clone the git repo?
  2. If the former which PR to modify the Makefile?
  3. What other package managers would you like hubble to be available on?
  1. The Github release tarball.
  2. Opt 2, ie
    GIT_BRANCH = $(shell which git >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD 2>/dev/null)
    GIT_HASH = $(shell which git >/dev/null 2>&1 && git rev-parse --short HEAD 2>/dev/null)
  3. It's not yet clear, it depends on what OS/distro most of Hubble users use. Debian is probably a good candidate as it is upstream of Ubuntu and many other distros.
zhiyanfoo commented 3 years ago

PR https://github.com/cilium/hubble/pull/589/files with printf '' removed

zhiyanfoo commented 3 years ago

With the next release I believe we can submit something like this to https://github.com/Homebrew/homebrew-core

require 'open3'

class Hubble < Formula
  desc "Hubble - Network, Service & Security Observability for Kubernetes using eBPF"
  homepage "https://github.com/cilium/hubble"
  url "https://github.com/cilium/hubble/archive/refs/tags/v0.9.0.tar.gz",
  license "Apache-2.0"
  head "https://github.com/cilium/hubble.git"

  depends_on "go" => :build

  def install
    system 'make', 'hubble'
    bin.install 'hubble'
  end

  test do
    _, _, status = Open3.capture3("#{bin}/hubble", "version")

    assert_equal 0, status
  end
end
rolinh commented 3 years ago

@zhiyanfoo I've marked your PR for backport to the v0.8 branch so that we can release v0.8.1 with the fix.

zhiyanfoo commented 3 years ago

I've opened a PR to add hubble as a formula

https://github.com/Homebrew/homebrew-core/pull/81876

zhiyanfoo commented 3 years ago

brew formula merged. https://github.com/Homebrew/homebrew-core/pull/81876. I've managed to install via brew install hubble.