Skip to content

Instantly share code, notes, and snippets.

@jdennes
Created April 25, 2021 11:39
Show Gist options
  • Select an option

  • Save jdennes/ae4f747f771c40d747f5886bccb69ade to your computer and use it in GitHub Desktop.

Select an option

Save jdennes/ae4f747f771c40d747f5886bccb69ade to your computer and use it in GitHub Desktop.

Revisions

  1. jdennes created this gist Apr 25, 2021.
    40 changes: 40 additions & 0 deletions benchmarking-kubeclient.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    auth_options = {
    bearer_token_file: "/var/run/secrets/kubernetes.io/serviceaccount/token"
    }

    ssl_options = {
    ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
    }

    control_client = Kubeclient::Client.new \
    "https://kubernetes.default.svc",
    "v1",
    auth_options: auth_options,
    ssl_options: ssl_options

    candidate_client = Kubeclient::Client.new \
    "https://kubernetes.default.svc",
    "v1",
    auth_options: auth_options,
    ssl_options: ssl_options,
    as: :parsed_symbolized

    require "benchmark"

    config_map = "enterprise-settings"
    namespace = File.read("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
    n = 1000

    Benchmark.bm do |benchmark|
    benchmark.report("control") do
    n.times do
    control_client.get_config_map(config_map, namespace)
    end
    end

    benchmark.report("candidate") do
    n.times do
    candidate_client.get_config_map(config_map, namespace)
    end
    end
    end