Skip to content

Commit f9798eb

Browse files
authored
Merge pull request #5869 from msau42/update-api-docs
Update steps on how to make a new API version
2 parents 1248937 + 0c8bda6 commit f9798eb

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

contributors/devel/sig-architecture/api_changes.md

+32-9
Original file line numberDiff line numberDiff line change
@@ -658,23 +658,46 @@ If you are adding a new API version to an existing group, you can copy the
658658
structure of the existing `pkg/apis/<group>/<existing-version>` and
659659
`staging/src/k8s.io/api/<group>/<existing-version>` directories.
660660

661+
It is helpful to structure the PR in layered commits to make it easier for
662+
reviewers to see what has changed between the two versions:
663+
1. A commit that just copies the `pkg/apis/<group>/<existing-version>` and
664+
`staging/src/k8s.io/api/<group>/<existing-version>` packages to the
665+
`<new-version>`.
666+
1. A commit that renames `<existing-version>`to `<new-version>` in the new files.
667+
1. A commit that makes any new changes for `<new-version>`.
668+
1. A commit that contains the generated files from running `make generated_files`, `make update`, etc.
669+
661670
Due to the fast changing nature of the project, the following content is probably out-dated:
662-
* You can control if the version is enabled by default by update
663-
[pkg/master/master.go](https://github.com/kubernetes/kubernetes/blob/v1.8.0-alpha.2/pkg/master/master.go#L381).
671+
* You must add the version to
672+
[pkg/controlplane/instance.go](https://github.com/kubernetes/kubernetes/blob/v1.21.2/pkg/controlplane/instance.go#L662)
673+
is be enabled by default for beta and stable versions, or disabled by default
674+
for alpha versions.
664675
* You must add the new version to
665-
[pkg/apis/group_name/install/install.go](https://github.com/kubernetes/kubernetes/blob/v1.8.0-alpha.2/pkg/apis/apps/install/install.go).
676+
`pkg/apis/group_name/install/install.go` (for example, [pkg/apis/apps/install/install.go](https://github.com/kubernetes/kubernetes/blob/v1.21.2/pkg/apis/apps/install/install.go)).
666677
* You must add the new version to
667-
[hack/lib/init.sh#KUBE_AVAILABLE_GROUP_VERSIONS](https://github.com/kubernetes/kubernetes/blob/v1.8.0-alpha.2/hack/lib/init.sh#L53).
668-
* You must add the new version to
669-
[hack/update-generated-protobuf-dockerized.sh](https://github.com/kubernetes/kubernetes/blob/v1.8.2/hack/update-generated-protobuf-dockerized.sh#L44)
670-
to generate protobuf IDL and marshallers.
678+
[hack/lib/init.sh#KUBE_AVAILABLE_GROUP_VERSIONS](https://github.com/kubernetes/kubernetes/blob/v1.21.2/hack/lib/init.sh#L65).
671679
* You must add the new version to
672-
[cmd/kube-apiserver/app#apiVersionPriorities](https://github.com/kubernetes/kubernetes/blob/v1.8.0-alpha.2/cmd/kube-apiserver/app/aggregator.go#L172)
680+
[cmd/kube-apiserver/app#apiVersionPriorities](https://github.com/kubernetes/kubernetes/blob/v1.21.2/cmd/kube-apiserver/app/aggregator.go#L247).
673681
* You must setup storage for the new version in
674-
[pkg/registry/group_name/rest](https://github.com/kubernetes/kubernetes/blob/v1.8.0-alpha.2/pkg/registry/authentication/rest/storage_authentication.go)
682+
`pkg/registry/group_name/rest` (for example, [pkg/registry/authentication/rest](https://github.com/kubernetes/kubernetes/blob/v1.21.2/pkg/registry/authentication/rest/storage_authentication.go)).
675683

676684
You need to regenerate the generated code as instructed in the sections above.
677685

686+
### Testing
687+
688+
Some updates to tests are required.
689+
690+
* You must add the new storage version hash published in API discovery data to
691+
[pkg/controlplane/storageversionhashdata/datago#GVRToStorageVersionHash](https://github.com/kubernetes/kubernetes/blob/v1.21.2/pkg/controlplane/storageversionhashdata/data.go#L44).
692+
* Run `go test ./pkg/controlplane -run StorageVersion` to verify.
693+
* You must add the new version stub to the persisted versions stored in etcd in [test/integration/etcd/data.go](https://github.com/kubernetes/kubernetes/blob/v1.21.2/test/integration/etcd/data.go#L40).
694+
* Run `go test ./test/integration/etcd` to verify
695+
* Sanity test the changes by bringing up a cluster (i.e.,
696+
local-up-cluster.sh, kind, etc) and running `kubectl get
697+
<resource>.<version>.<group>`.
698+
* [Integration tests](../sig-testing/integration-tests.md)
699+
are also good for testing the full CRUD lifecycle along with the controller.
700+
678701
## Making a new API Group
679702

680703
You'll have to make a new directory under `pkg/apis/` and

0 commit comments

Comments
 (0)