Skip to content

WIP: Rebase 1.32 Pre.1 Diff #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 58 commits into
base: kcp-1.32-baseline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
dead945
UPSTREAM: 113151: Revert: Revert: Clean up CRD conversion code structure
sttts Sep 11, 2023
d157aea
README
sttts Sep 1, 2023
a0f3d68
UPSTREAM: <carry>: controlplane/apiserver: add miniaggregator
sttts Sep 27, 2023
7234f81
UPSTREAM: <carry>: clusterize controllers
sttts Sep 1, 2023
28ac217
UPSTREAM: <carry>: re-add GC worker locks
gman0 Feb 3, 2025
570c6ed
UPSTREAM: <carry>: Add kcp patchers
sttts Oct 8, 2023
c93e304
UPSTREAM: <carry>: re-generated pkg/controller/resourcequota/resource…
gman0 Jan 26, 2025
2016601
UPSTREAM: <carry>: re-generated pkg/controller/garbagecollector/garba…
gman0 Feb 11, 2025
f87a202
UPSTREAM: <carry>: storage: etcd cluster key computation
sttts Sep 27, 2023
aad4a42
UPSTREAM: <carry>: clusterize serviceaccounts
sttts Sep 1, 2023
86eb6a8
UPSTREAM: <carry>: registry/core/serviceaccount: do not crash without…
sttts Sep 27, 2023
0e41242
UPSTREAM: <carry>: kube-aggregator
sttts Sep 1, 2023
006648f
UPSTREAM: <carry>: INTERESTING: clusterize admission
sttts Sep 1, 2023
ba55bcf
UPSTREAM: <carry>: Clusterize ValidatingAdmissionPolicy admission plu…
embik Jul 24, 2024
aaa0e92
UPSTREAM: <carry>: clusterize storage hash
sttts Sep 27, 2023
f2ad525
UPSTREAM: <carry>: endpoints: add Cluster struct for ctx
sttts Sep 27, 2023
4ed5b98
UPSTREAM: <carry>: endpoints/patch: wire openapi for CRD strategic me…
sttts Sep 27, 2023
4739ef6
UPSTREAM: <carry>: storage/etcd3: clusterize
sttts Sep 27, 2023
ab335e9
UPSTREAM: <carry>: apiserver: partial wildcard metadata request accro…
sttts Sep 27, 2023
d868a62
UPSTREAM: <carry>: endpoints: set kcp.io/original-api-version on wild…
sttts Sep 27, 2023
7f28105
UPSTREAM: <carry>: watch(er/cache): clusterize
sttts Sep 27, 2023
e271562
UPSTREAM: <carry>: apiserver: split chain into pre and post authz
sttts Sep 27, 2023
4a2b5f9
UPSTREAM: <carry>: apiserver: clusterize listed paths
sttts Sep 27, 2023
b9669e3
UPSTREAM: <carry>: apiserver: clusterize OpenAPI v2
sttts Sep 27, 2023
b5939d8
UPSTREAM: <carry>: clusterize BuiltInAuthenticationOptions
sttts Sep 27, 2023
bf1a2a1
UPSTREAM: <carry>: storage: add UseResourceAsPrefixDefault for legacy…
sttts Sep 27, 2023
879e485
UPSTREAM: <carry>: apiextensions-apiserver
sttts Sep 27, 2023
0203da1
UPSTREAM: <carry>: cache-server: wire shard name into storage
sttts Sep 27, 2023
db825b7
UPSTREAM: <carry>: add client and informer hacks
sttts Sep 27, 2023
1159daa
UPSTREAM: <carry>: controlplane: wire informers and clients
sttts Sep 11, 2023
4c9c3df
UPSTREAM: <carry>: generic cleanup
mjudeikis Sep 3, 2024
ab917a9
UPSTREAM: <carry>: controlplane/apiserver: disable protobuf for loopback
sttts Sep 25, 2023
e142cc7
UPSTREAM: <carry>: pass system:admin clients and informers in generic…
embik Jun 13, 2024
a71d65e
UPSTREAM: <carry>: remove REST mapper from admission plugins
embik Jun 20, 2024
68b54d6
UPSTREAM: <carry>: provide supportedMediaTypes for custom resoure han…
embik Jun 21, 2024
50c9ea5
UPSTREAM: <carry>: prevent NPE if no authorization is set
embik Jun 21, 2024
2034abe
UPSTREAM: <carry>: wrap CRD group into packagePrefix for OpenAPIV3 bu…
embik Jul 12, 2024
8a207b8
UPSTREAM: <CARRY>: clusterize validatingadmissionpolicystatus controller
embik Jul 23, 2024
7a27a28
UPSTREAM: <carry>: apiserver cleaning
mjudeikis Sep 3, 2024
5c809ee
UPSTREAM: <squash>: remove syncer custom code from apiextensions-apis…
sttts Sep 18, 2024
fe0acf7
UPSTREAM: <carry>: include cluster name in authz SubjectAccessReview …
xrstf Nov 13, 2024
d57c237
UPSTREAM: <squash>: prevent conflict with pre-existing auth annotation
xrstf Nov 14, 2024
455d854
CARRY: split auth/authz chains even more
mjudeikis Dec 10, 2024
1a37a19
UPSTREAM: <carry>: authz: add scoping to default rule resolver
sttts Aug 23, 2024
b6ac17f
UPSTREAM: <carry>: authz: add warrants to default rule resolver
sttts Aug 23, 2024
dc03406
UPSTREAM: <squash>: authz: add warrants to default rule resolver: glo…
sttts Jan 24, 2025
b06d2a8
UPSTREAM: <squash>: authz: add warrants to default rule resolver: hel…
sttts Jan 24, 2025
1b0b146
UPSTREAM: <squash>: authz: add warrants to default rule resolver: glo…
sttts Jan 25, 2025
0ced631
UPSTREAM: <squash>: authz: add warrants to default rule resolver: for…
sttts Jan 25, 2025
bffed1d
UPSTREAM: <squash>: authz: add warrants to default rule resolver: sim…
sttts Jan 25, 2025
8fd95d6
UPSTREAM: <carry>: endpoints: wire in ctx to watchListTransformer
gman0 Jan 22, 2025
8befcaf
UPSTREAM: <carry>: Clusterize MutatingAdmissionPolicy admission plugi…
gman0 Jan 23, 2025
8fc9059
UPSTREAM: <carry>: don't use --prefers-protobuf with client-gen
gman0 Feb 10, 2025
03a3c1b
UPSTREAM: <drop>: Pinned kcp dependencies
gman0 Feb 12, 2025
204c308
UPSTREAM: <drop>: Updated vendor modules
gman0 Feb 12, 2025
c6ebc59
UPSTREAM: <drop>: Re-generated client code
gman0 Feb 12, 2025
89e1549
UPSTREAM 130180: Make disable lookups of SA related artifacts working
mjudeikis Feb 14, 2025
3b193fc
Merge pull request #163 from mjudeikis/mjudeikis/cherry.sa.lookup
mjudeikis Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
97 changes: 97 additions & 0 deletions KCP_RELATED_CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Why this forked repository ?

This repository carries the prototype branch which accumulates the hacks, prototypes, proto-KEP experiments, and workarounds required to make [KCP](https://github.com/kcp-dev/kcp/blob/main/README.md) a reality.
It is based on K8S 1.22 for now and commits are identified with basic labels like HACK/FEATURE/WORKAROUND.

# Summary of changes

The detailed explanation of the changes made on top of the Kubernetes code can be found in both the commit messages, and comments of the associated code.

However here is a summary of the changes, with the underlying requirements and motivations. Reading the linked investigation document first will help.

## A. Minimal API Server

__Investigation document:__ [minimal-api-server.md](https://github.com/kcp-dev/kcp/blob/main/docs/investigations/minimal-api-server.md)

1. New generic control plane based on kube api-server

It is mainly provided by code:

1. initially duplicated from kube api-server main code, and legacy scheme (`DUPLICATE` commits),

2. then stripped down from unnecessary things (ergress, api aggregation, webhooks) and APIs (Pods, Nodes, Deployments, etc ...) (`NEW` commits)

2. Support adding K8S built-in resources (`core/Pod`, `apps/Deployment`, ...) as CRDs

This is required since the new generic control plane scheme doesn't contain those resources any more.

This is provided by:

- hacks (`HACK` commits) that:

1. <a id="A-2-1"></a> allow the go-restful server to be bypassed for those resources, and route them to the CRD handler
2. <a id="A-2-2"></a> allow the CRD handler, and opanapi publisher, to support resources of the `core` group
3. <a id="A-2-3"></a> convert the `protobuf` requests sent to those resources resources to requests in the `application/json` content type, before letting the CRD handler serve them
4. <a id="A-2-4"></a> replace the table converter of CRDs that bring back those resources, with the default table converter of the related built-in resource

- a new feature, or potential kube fix (`KUBEFIX` commit), that:

5. <a id="A-2-5"></a> introduces the support of strategic merge patch for CRDs.
This support uses the OpenAPI v3 schema of the CRD to drive the SMP execution, but only adds a minimal implementation and doesn't fully support OpenAPI schemas that don't have expected `patchStrategy` and `patchMergeKey` annotations.
In order to avoid changing the behavior of existing client tools, the support is only added for those K8S built-in resources

## B. Logical clusters

__Investigation document:__ [logical-clusters.md](https://github.com/kcp-dev/kcp/blob/main/docs/investigations/logical-clusters.md)

1. Logical clusters represented as a prefix in etcd

It is mainly provided by hacks (`HACK` commits) that:

1. <a id="B-1-1"></a> allow intercepting the api server handler chain to set the expected logical cluster context value from either a given suffix in the request APIServer base URL, or a given header in the http request

2. <a id="B-1-2"></a> change etcd storage layer in order to use the logical cluster as a prefix in the etcd key

3. <a id="B-1-3"></a> allow wildcard watches that retrieve objects from all the logical clusters

4. <a id="B-1-4"></a> correctly get or set the `clusterName` metadata field in the storage layer operations based on the etcd key and its new prefix

2. Support of logical clusters (== tenancy) in the CRD management, OpenAPI and discovery endpoints, and clients used by controllers

<a id="B-2"></a>It is mainly provided by a hack (`HACK` commit) that adds CRD tenancy by ensuring that logical clusters are taken in account in:
- CRD-related controllers
- APIServices-related controllers
- Discovery + OpenAPI endpoints

In the current Kubernetes design, those 3 areas are highly coupled and intricated, which explains why this commit had to hack the code at various levels:
- client-go level
- controllers level,
- http handlers level.

While this gives a detailed idea of which code needs to be touched in order to enable CRD tenancy, a clean implementation would first require some refactoring, in order to build the required abstraction layers that would allow decoupling those areas.

# Potential client problems

Although these changes in the K8S codebase were made in order to keep the compatibility with Kuberntes client tools, there might be some problems:

## Incomplete protobuf support for built-in resources

In some contexts, like the `controller-runtime` library used by the Operator SDK, all the resources of the `client-go` scheme are created / updated using the `application/vnd.kubernetes.protobuf` content type.

However when these resources are in fact added as CRDs, in the KCP minimal API server scenario, these resources cannot be created / updated since the protobuf (de)serialization is not (and probably cannot be) supported for CRDs.
So for now in this case, the [A.2.3 hack mentioned above](#A-2-3) just converts the `protobuf` request to a `json` one, but this might not cover all the use-cases or corner cases.

The clean solution would probably be the negotiation of serialization type in `client-go`, which we haven't implemented yet, but which would work like this:
When a request for an unsupported serialization is returned, the server should reject it with a 406
and provide a list of supported content types. `client-go` should then examine whether it can satisfy such a request by encoding the object with a different scheme.
This would require a KEP but at least is in keeping with content negotiation on GET / WATCH in Kube

## Incomplete Strategic merge patch support for built-in resources

Client tools like `kubectl` assume that all K8S native resources (== `client-go` schema resources)
support strategic merge patch, and use it by default when updating or patching a resource.

In Kube, currently, strategic merge patch is not supported for CRDs, which would break compatibility with client tools for all the K8S natives resources that are in fact added as CRD in the KCP minimal api server.
The [A-2-5 change mentioned above](#A-2-5) tries to fix this by using the CRD openAPI v3 schema as the source of the required information that will drive the strategic merge patch execution.

While this fixes the problem in most cases, there might still be errors in case the OpenAPI v2 schema for such a resource is missing `x-kubernetes-patch-strategy` and `x-kubernetes-patch-merge-key` annotations when imported from the CRD OpenAPI v3 schema.
206 changes: 206 additions & 0 deletions LICENSES/vendor/github.com/kcp-dev/apimachinery/v2/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading