client-go VS kubectl

Compare client-go vs kubectl and see what are their differences.

client-go

Go client for Kubernetes. (by kubernetes)

kubectl

Issue tracker and mirror of kubectl code (by kubernetes)
Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
client-go kubectl
38 13
8,530 2,664
1.7% 2.0%
9.3 9.2
8 days ago 1 day ago
Go Go
Apache License 2.0 Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

client-go

Posts with mentions or reviews of client-go. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-02-14.
  • The Inner Workings of Kubernetes Management Frontends — A Software Engineer’s Perspective
    4 projects | dev.to | 14 Feb 2024
    The Kubernetes clients (e.g., Go client) support developers with both methods to connect to a cluster, as we can see in the following examples.
  • Has anyone ever tried to learn how k8s works?
    4 projects | /r/golang | 11 Jul 2023
    My suggestion would be to start looking at things like https://github.com/kubernetes/client-go first in order to get a feel for the API and how data plane k8s components interact with the apiserver (it's the same thing that kubelet uses). Then move on to trying to build your own k8s operator to get a feel for how people expand and customize k8s functionality without having to modify upstream at all. IMO the codebase itself is too messy and in constant flux to make too much sense of it unless you are planning to contribute to upstream.
  • CUE compared to helm/kustomize...
    3 projects | /r/kubernetes | 5 Jul 2023
    CUE is cool and all but as soon as I start writing real code structures I want to reach for client-go.
  • Go 1.21 will (probably) download newer toolchains on demand by default
    4 projects | news.ycombinator.com | 23 Jun 2023
    I'm... really not sure I agree with this, from a philosophical point of view. It feels like this is making "eh, we'll just upgrade our Go version next quarter" too easy; ultimately some responsibility toward updating your application's Go version to work with what new dependencies require should fall on Us, the application developers. Sure, we're bad at it. Everyone's lived through running years-old versions of some toolchain. But I think this just makes the problem worse, not better.

    Its compounded by the problem that, when you're setting up a new library, the `go` directive in the mod file defaults to your current toolchain; most likely a very current one. It would take a not-insignificant effort on the library author's part to change that to assert the true-minimum version of Go required, based on libraries and language features and such. That's an effort most devs won't take on.

    I'd also guess that many developers, up-to this point if not indefinitely because education is hard, interpreted that `go` directive to mean more-of "the version of go this was built with"; not necessarily "the version of go minimally required". There are really major libraries (kubernetes/client-go [1]) which assert a minimum go version of 1.20; the latest version (see, for comparison, the aws-sdk, which specifies a more reasonable go1.11 [2]). I haven't, you know, fully audited these libraries, but 1.20 wasn't exactly a major release with huge language and library changes; do they really need 1.20? If devs haven't traditionally operated in this world where keeping this value super-current results in actually significant downstream costs in network bandwidth (go1.20 is 100mb!) and CI runtime, do we have confidence that the community will adapt? There's millions of Go packages out there.

    Or, will a future version of Go patch a security update, not backport it more than one version or so, and libraries have to specify the newest `go` directive version, because manifest security scanning and policy and whatever? Like, yeah, I get the rosy worldview of "your minimum version encodes required language and library features", but its not obvious to me that this is how this field is, or even will be, used.

    Just a LOT of tertiary costs to this change which I hope the team has thought through.

    [1] https://github.com/kubernetes/client-go/blob/master/go.mod#L...

    [2] https://github.com/aws/aws-sdk-go/blob/main/go.mod

  • My LFX Mentorship experience with OpenELB
    8 projects | dev.to | 6 Oct 2022
    Then on June 18th, 2022, I got a chance to meet our mentors and the other mentee of OpenELB (the mentee and the mentors of OpenFunction were also there). There I was informed about how to start working on the project, so I started learning about using the Kubernetes API client. After experimenting with the official Kubernetes Client, I learned that it's not very feasible to use that for dealing with CRDs (custom resource definitions), so I explored the controller-runtime client as per what I found in many sources, and found that it was a great fit for the backend of our project. During that time, I also built a simple project to see if everything would work as expected or not (as this was the first time I dealt with a Kubernetes client, I considered that debugging would be easier in a smaller project).
  • Automatically import Secrets INTO Vault
    5 projects | /r/kubernetes | 10 Sep 2022
  • Using client-go to `kubectl apply` against the Kubernetes API directly with multiple types in a single YAML file
    6 projects | /r/codehunter | 14 Aug 2022
    I'm using https://github.com/kubernetes/client-go and all works well.
  • 深入解析kubernetes中的选举机制
    2 projects | dev.to | 31 Jul 2022
  • Golang for devops
    2 projects | /r/devops | 26 Apr 2022
    with this https://github.com/kubernetes/client-go (get, delete, create deployments, secrets, pods...)
  • k8s controller to scale up and down namespaces on demand, with an embedded friendly UI
    3 projects | /r/kubernetes | 4 Apr 2022
    I directly used the client-go package from Kubernetes, as we wrote a controller which does not handle CRDs. If you are already a little bit comfortable with Go (I'm definitely not an expert), you should be able to get on the rails pretty quickly, especially with their examples. I'll be happy to help if needed!

kubectl

Posts with mentions or reviews of kubectl. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-05-02.
  • Setting kubectl context via env var
    6 projects | /r/kubernetes | 2 May 2023
    I have read this issue, and up to now it seems not possible to change the kubectl context via an env var: https://github.com/kubernetes/kubectl/issues/1154
  • Deciding between Rust or Go for desktop applications
    9 projects | /r/golang | 8 Apr 2023
    However, I would encourage people to take a look at what the code looks like before assuming the Go developer experience on this was positive. Bear in mind that's just the top level kubectl command and some helper functions, the subcommand definitions take up a several more files split into a few more packages. Then you're still not even done, because code that uses the parsed flags still has to redundantly check things that couldn't be enforced at the type level, something Go folks like to pretend is a good thing for some reason.
  • Recommendations on file/dir/module structure, common dependencies, and/or anti-patterns for writing CLI tool in Rust
    12 projects | /r/rust | 18 Mar 2023
    kubectl is for sure battle tested, but it involves very Kubernetes specific implementations and is going to be too complicated for the first pointer
  • Recommendations on building a simple DSL REPL?
    5 projects | /r/golang | 18 Mar 2023
  • Why Go and Not Rust?
    4 projects | news.ycombinator.com | 27 Jan 2023
    > context.Background() is typically only used when one doesn’t care about the result. If you did care about the result, you should be passing the parent context to preserve the circuit breaker timeout in case the operation takes too long.

    Not necessarily. You would use context.Background in a test situation. It's also commonly used for short-lived applications like a CLI invocation. You can see kubectl uses context.Background quite a lot: https://github.com/kubernetes/kubectl/search?q=context.backg...

    > I think the level of pain you experience from mutable references in Rust depends on if you’re coming from an OOP or FP background. I have a FP background and so the patterns I use to build code already greatly restrict mutation. You can usually change code that updates data immutably (creating a new copy of it) with mutable code in rust because the control flow of your program already involves passing that new version back to the caller which also satisfies the borrow checker in most situations.

    There has to be a better solution to needlessly copying data.

  • What's the number one annoyance that drives you crazy about Kubernetes?
    7 projects | /r/kubernetes | 25 Jan 2022
    Go add --no-really-all if you really want it: https://github.com/kubernetes/kubectl
  • Looking for a tutorial or a resource to write good looking CLI applications
    4 projects | /r/golang | 22 Jul 2021
    - https://github.com/kubernetes/kubectl
  • Best examples of a Go client
    13 projects | /r/golang | 1 May 2021
    I haven't looked at the code all that much, but kubectl does a heck of a lot, and you can't argue that it's not battle-tested.
  • client-go retrieve pods event
    2 projects | /r/kubernetes | 13 Mar 2021
    The canonical example client-go app you're most familiar with is kubectl. https://github.com/kubernetes/kubectl/blob/e69a10320e34fd2487b61927f69affbb52e4f0e1/pkg/describe/describe.go#L279 is the kubectl describe kind name... bit that deals with fetching events related the object with that kind/name.

What are some alternatives?

When comparing client-go and kubectl you can also consider the following projects:

kubebuilder - Kubebuilder - SDK for building Kubernetes APIs using CRDs

controller-runtime - Repo for the controller-runtime subproject of kubebuilder (sig-apimachinery)

helm - The Kubernetes Package Manager

kustomize - Customization of kubernetes YAML configurations

celery - Distributed Task Queue (development branch)

apimachinery

k3s - Lightweight Kubernetes

nfs-subdir-external-provisioner - Dynamic sub-dir volume provisioner on a remote NFS server.

kubernetes - Production-Grade Container Scheduling and Management

machinery - Machinery is an asynchronous task queue/job queue based on distributed message passing.

kube-openapi - Kubernetes OpenAPI spec generation & serving

robusta - Kubernetes observability and automation, with an awesome Prometheus integration