Documentation
¶
Overview ¶
Package kube is a dependency-free Kubernetes REST client scoped to exactly what the bootnode plugin needs: server-side-apply of namespaced custom resources (bootno.de/v1 Network, NodeFleet, KMSSecret).
It deliberately avoids k8s.io/client-go and its transitive dependency tree. The bootnode plugin applies a handful of CR kinds; a full typed client is overkill. This client talks to the apiserver over net/http using the in-cluster service-account token + CA (the standard pod identity), falling back to KUBE_APISERVER + KUBE_TOKEN env for out-of-cluster development.
Apply uses Kubernetes server-side apply (PATCH with application/apply-patch+yaml). It is idempotent: applying the same object twice converges to the same state with bootnode as the field manager.
Index ¶
- Variables
- func SetTarget(c *Client, apiServer, token string)
- type Client
- func (c *Client) Apply(ctx context.Context, gvr GVR, name string, labels map[string]string, ...) (string, error)
- func (c *Client) Available() bool
- func (c *Client) Delete(ctx context.Context, gvr GVR, name string) error
- func (c *Client) Get(ctx context.Context, gvr GVR, name string, out any) (bool, error)
- func (c *Client) Namespace() string
- type CustomResource
- type GVR
- type Metadata
Constants ¶
This section is empty.
Variables ¶
var ( NetworkGVR = GVR{Group: "bootno.de", Version: "v1", Plural: "networks", Kind: "Network"} NodeFleetGVR = GVR{Group: "bootno.de", Version: "v1", Plural: "nodefleets", Kind: "NodeFleet"} KMSSecretGVR = GVR{Group: "bootno.de", Version: "v1", Plural: "kmssecrets", Kind: "KMSSecret"} )
bootno.de/v1 resources the bootnode plugin manages.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client applies namespaced custom resources to a Kubernetes cluster.
func New ¶
New constructs a Client. It resolves cluster access in this order:
- In-cluster service account (token + CA + namespace files).
- KUBE_APISERVER + KUBE_TOKEN environment variables (dev / out-of-cluster).
New never fails: when no cluster is reachable the Client is marked unavailable and Client.Available returns false. Callers decide whether a missing cluster is fatal for a given request (it is for network/node provisioning, surfaced as a 503).
func (*Client) Apply ¶
func (c *Client) Apply(ctx context.Context, gvr GVR, name string, labels map[string]string, spec map[string]any) (string, error)
Apply performs a server-side apply of the given custom resource. It is idempotent. spec is the resource's .spec; labels are attached to metadata.
Returns the applied object's name on success.
func (*Client) Available ¶
Available reports whether a Kubernetes cluster was resolved at construction.
func (*Client) Delete ¶
Delete removes a named custom resource. A 404 is treated as success (idempotent delete).
type CustomResource ¶
type CustomResource struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata Metadata `json:"metadata"`
Spec map[string]any `json:"spec"`
}
CustomResource is the minimal shape of a namespaced custom resource. Apply fills in apiVersion/kind/namespace, so callers provide Name + Spec.