Apply feedback

Kubernetes-commit: bf851e8bcfa6213218c6352636dcc5114d83399c
This commit is contained in:
Joe Betz
2025-09-05 15:43:48 -04:00
committed by Kubernetes Publisher
parent 799b7635a9
commit fad66b0287
2 changed files with 14 additions and 11 deletions

View File

@@ -65,8 +65,7 @@ The **`kubernetes.Clientset`** provides compile-time, type-safe access to core,
The **`dynamic.DynamicClient`** represents all objects as `unstructured.Unstructured`, allowing it
to interact with any API resource, including CRDs. It relies on two discovery mechanisms:
1. The **`discovery.DiscoveryClient`** determines *what* resources exist. The
**`CachedDiscoveryClient`** is a critical optimization that caches this data on disk to solve
the severe N+1 request performance bottleneck that can occur during discovery.
**`CachedDiscoveryClient`** is an optimization that caches this data on disk to solve.
2. The **OpenAPI schema** (fetched from `/openapi/v3`) describes the *structure* of those
resources, providing the schema awareness needed by the dynamic client.
@@ -85,6 +84,8 @@ several key components:
A contributor modifying a built-in API type **must** run the code generation scripts to update all
of these dependent components. For the Kubernetes project, `hack/update-codegen.sh` runs code generation.
`sample-controller` shows how code generate can be configured to build custom controllers.
## Controller Infrastructure
The `tools/cache` package provides the core infrastructure for controllers, replacing a high-load,

View File

@@ -1,5 +1,5 @@
/*
Copyright 2021 The Kubernetes Authors.
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -373,15 +373,17 @@ func Example_leaderElection() {
}()
// Create the lock object.
lock := &resourcelock.LeaseLock{
LeaseMeta: metav1.ObjectMeta{
Name: leaseName,
Namespace: leaseNamespace,
},
Client: clientset.CoordinationV1(),
LockConfig: resourcelock.ResourceLockConfig{
lock, err := resourcelock.New(resourcelock.LeasesResourceLock,
leaseNamespace,
leaseName,
clientset.CoreV1(),
clientset.CoordinationV1(),
resourcelock.ResourceLockConfig{
Identity: id,
},
})
if err != nil {
fmt.Printf("Error creating lock: %v\n", err)
return
}
// Create the leader elector.