mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-16 07:08:22 +00:00
Apply feedback
Kubernetes-commit: bf851e8bcfa6213218c6352636dcc5114d83399c
This commit is contained in:
committed by
Kubernetes Publisher
parent
799b7635a9
commit
fad66b0287
@@ -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
|
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:
|
to interact with any API resource, including CRDs. It relies on two discovery mechanisms:
|
||||||
1. The **`discovery.DiscoveryClient`** determines *what* resources exist. The
|
1. The **`discovery.DiscoveryClient`** determines *what* resources exist. The
|
||||||
**`CachedDiscoveryClient`** is a critical optimization that caches this data on disk to solve
|
**`CachedDiscoveryClient`** is an optimization that caches this data on disk to solve.
|
||||||
the severe N+1 request performance bottleneck that can occur during discovery.
|
|
||||||
2. The **OpenAPI schema** (fetched from `/openapi/v3`) describes the *structure* of those
|
2. The **OpenAPI schema** (fetched from `/openapi/v3`) describes the *structure* of those
|
||||||
resources, providing the schema awareness needed by the dynamic client.
|
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
|
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.
|
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
|
## Controller Infrastructure
|
||||||
|
|
||||||
The `tools/cache` package provides the core infrastructure for controllers, replacing a high-load,
|
The `tools/cache` package provides the core infrastructure for controllers, replacing a high-load,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2021 The Kubernetes Authors.
|
Copyright 2025 The Kubernetes Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with 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.
|
// Create the lock object.
|
||||||
lock := &resourcelock.LeaseLock{
|
lock, err := resourcelock.New(resourcelock.LeasesResourceLock,
|
||||||
LeaseMeta: metav1.ObjectMeta{
|
leaseNamespace,
|
||||||
Name: leaseName,
|
leaseName,
|
||||||
Namespace: leaseNamespace,
|
clientset.CoreV1(),
|
||||||
},
|
clientset.CoordinationV1(),
|
||||||
Client: clientset.CoordinationV1(),
|
resourcelock.ResourceLockConfig{
|
||||||
LockConfig: resourcelock.ResourceLockConfig{
|
|
||||||
Identity: id,
|
Identity: id,
|
||||||
},
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Error creating lock: %v\n", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the leader elector.
|
// Create the leader elector.
|
||||||
|
Reference in New Issue
Block a user