Generating Reference Documentation for the Kubernetes API
This page shows how to update the Kubernetes API reference documentation.
The Kubernetes API reference documentation is built from the
using the
If you find bugs in the generated documentation, you need to
fix them upstream. If you need only to regenerate the reference documentation from the
spec, continue reading this page. You need a machine that is running Linux or macOS. You need to have these tools installed: Your You need to know how to create a pull request to a GitHub repository.
This involves creating your own fork of the repository. For more
information, see Work from a local clone. Create a local workspace and set your Get a local clone of the following repositories: If you don't already have the kubernetes/website repository, get it now: Get a clone of the kubernetes/kubernetes repository as k8s.io/kubernetes: The base directory of your clone of the
$GOPATH/src/k8s.io/kubernetes.
The remaining steps refer to your base directory as The base directory of your clone of the
$GOPATH/src/github.com/<your username>/website.
The remaining steps refer to your base directory as The base directory of your clone of the
repository is This section shows how to generate the
published Kubernetes API reference documentation. For example: The In the The Verify that these two files have been generated: Go to the base of your local The output is similar to: When generating reference documentation for a new release, update the file,
Open Open Publish a local version of the API reference.
Verify the . In Submit your changes as a
pull request to the
Before you begin
Requirements:
PATH
environment variable must include the required build tools, such as the Go
binary and python
.Setting up the local repositories
GOPATH
.mkdir -p $HOME/<workspace>
export GOPATH=$HOME/<workspace>
go get -u github.com/kubernetes-sigs/reference-docs
go get -u github.com/go-openapi/loads
go get -u github.com/go-openapi/spec
git clone https://github.com/<your-username>/website $GOPATH/src/github.com/<your-username>/website
git clone https://github.com/kubernetes/kubernetes $GOPATH/src/k8s.io/kubernetes
<k8s-base>
.<web-base>
.$GOPATH/src/github.com/kubernetes-sigs/reference-docs.
The remaining steps refer to your base directory as <rdocs-base>
.Generating the API reference docs
Setting build variables
K8S_ROOT
to <k8s-base>
.K8S_WEBROOT
to <web-base>
.K8S_RELEASE
to the version of the docs you want to build.
For example, if you want to build docs for Kubernetes 1.17.0, set K8S_RELEASE
to 1.17.0.export K8S_WEBROOT=${GOPATH}/src/github.com/<your-username>/website
export K8S_ROOT=${GOPATH}/src/k8s.io/kubernetes
export K8S_RELEASE=1.17.0
Creating versioned directory and fetching Open API spec
updateapispec
build target creates the versioned build directory.
After the directory is created, the Open API spec is fetched from the
<k8s-base>
repository. These steps ensure that the version
of the configuration files and Kubernetes Open API spec match the release version.
The versioned directory name follows the pattern of v<major>_<minor>
.<rdocs-base>
directory, run the following build target:cd <rdocs-base>
make updateapispec
Building the API reference docs
copyapi
target builds the API reference and
copies the generated files to directories in <web-base>
.
Run the following command in <rdocs-base>
:cd <rdocs-base>
make copyapi
[ -e "<rdocs-base>/gen-apidocs/build/index.html" ] && echo "index.html built" || echo "no index.html"
[ -e "<rdocs-base>/gen-apidocs/build/navData.js" ] && echo "navData.js built" || echo "no navData.js"
<web-base>
, and
view which files have been modified:cd <web-base>
git status
static/docs/reference/generated/kubernetes-api/v1.23/css/bootstrap.min.css
static/docs/reference/generated/kubernetes-api/v1.23/css/font-awesome.min.css
static/docs/reference/generated/kubernetes-api/v1.23/css/stylesheet.css
static/docs/reference/generated/kubernetes-api/v1.23/fonts/FontAwesome.otf
static/docs/reference/generated/kubernetes-api/v1.23/fonts/fontawesome-webfont.eot
static/docs/reference/generated/kubernetes-api/v1.23/fonts/fontawesome-webfont.svg
static/docs/reference/generated/kubernetes-api/v1.23/fonts/fontawesome-webfont.ttf
static/docs/reference/generated/kubernetes-api/v1.23/fonts/fontawesome-webfont.woff
static/docs/reference/generated/kubernetes-api/v1.23/fonts/fontawesome-webfont.woff2
static/docs/reference/generated/kubernetes-api/v1.23/index.html
static/docs/reference/generated/kubernetes-api/v1.23/js/jquery.scrollTo.min.js
static/docs/reference/generated/kubernetes-api/v1.23/js/navData.js
static/docs/reference/generated/kubernetes-api/v1.23/js/scroll.js
Updating the API reference index pages
<web-base>/content/en/docs/reference/kubernetes-api/api-index.md
with the new
version number.
<web-base>/content/en/docs/reference/kubernetes-api/api-index.md
for editing,
and update the API reference version number. For example:---
title: v1.17
---
[Kubernetes API v1.17](/docs/reference/generated/kubernetes-api/v1.17/)
<web-base>/content/en/docs/reference/_index.md
for editing, and add a
new link for the latest API reference. Remove the oldest API reference version.
There should be five links to the most recent API references.Locally test the API reference
cd <web-base>
git submodule update --init --recursive --depth 1 # if not already done
make container-serve
Commit the changes
<web-base>
run git add
and git commit
to commit the change.What's next