Skip to content
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

[GSoD'20] Update how the Kubernetes website serves API references #23294

Merged
merged 2 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "themes/docsy"]
path = themes/docsy
url = https://github.com/google/docsy.git
[submodule "api-ref-generator"]
path = api-ref-generator
url = https://github.com/kubernetes-sigs/reference-docs
Comment on lines +4 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should update README.md to mention that there is more than one submodule

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# change is that the Hugo version is now an overridable argument rather than a fixed
# environment variable.

FROM alpine:latest
FROM golang:1.15-alpine

LABEL maintainer="Luc Perkins <[email protected]>"

Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,10 @@ docker-internal-linkcheck:
container-internal-linkcheck: link-checker-image-pull
$(CONTAINER_RUN) $(CONTAINER_IMAGE) hugo --config config.toml,linkcheck-config.toml --buildFuture
$(CONTAINER_ENGINE) run --mount type=bind,source=$(CURDIR),target=/test --rm wjdp/htmltest htmltest

clean-api-reference: ## Clean all directories in API reference directory, preserve _index.md
rm -rf content/en/docs/reference/kubernetes-api/*/
feloy marked this conversation as resolved.
Show resolved Hide resolved

api-reference: clean-api-reference ## Build the API reference pages. go needed
cd api-ref-generator/gen-resourcesdocs && \
go run cmd/main.go kwebsite --config-dir config/v1.20/ --file api/v1.20/swagger.json --output-dir ../../content/en/docs/reference/kubernetes-api --templates templates
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,49 @@ make serve

This will start the local Hugo server on port 1313. Open up your browser to http://localhost:1313 to view the website. As you make changes to the source files, Hugo updates the website and forces a browser refresh.

## Building the API reference pages

The API reference pages located in `content/en/docs/reference/kubernetes-api` are built from the Swagger specification, using https://github.com/kubernetes-sigs/reference-docs/tree/master/gen-resourcesdocs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We should signpost readers to a page that describes prerequisites; for example, go.


To update the reference pages for a new Kubernetes release (replace v1.20 in the following examples with the release to update to):

1. Pull the `kubernetes-resources-reference` submodule:

```
git submodule update --init --recursive --depth 1
```

2. Create a new API revision into the submodule, and add the Swagger specification:

```
mkdir api-ref-generator/gen-resourcesdocs/api/v1.20
curl 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json' > api-ref-generator/gen-resourcesdocs/api/v1.20/swagger.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd run:

Suggested change
curl 'https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json' > api-ref-generator/gen-resourcesdocs/api/v1.20/swagger.json
curl -L -o api-ref-generator/gen-resourcesdocs/api/v1.20/swagger.json https://raw.githubusercontent.com/kubernetes/kubernetes/v1.20.0/api/openapi-spec/swagger.json

```

3. Copy the table of contents and fields configuration for the new release from a previous one:

```
mkdir api-ref-generator/gen-resourcesdocs/api/v1.20
cp api-ref-generator/gen-resourcesdocs/api/v1.19/* api-ref-generator/gen-resourcesdocs/api/v1.20/
```

4. Adapt the files `toc.yaml` and `fields.yaml` to reflect the changes between the two releases

5. Next, build the pages:

```
make api-reference
```

You can test the results locally by making and serving the site from a container image:

```
make container-image
make container-serve
```

6. When all changes of the new contract are reflected into the configuration files `toc.yaml` and `fields.yaml`, create a Pull Request with the newly generated API reference pages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contract? I'm not sure this is the right English term.

Suggested change
6. When all changes of the new contract are reflected into the configuration files `toc.yaml` and `fields.yaml`, create a Pull Request with the newly generated API reference pages.
6. Once you have updated `toc.yaml` and `fields.yaml` to match the updated API definitions, commit your changes to a branch and open a pull request.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this part needs clarification. Changes to the configuration files need to be created in kubernetes-sigs/reference-docs.


## Troubleshooting
### error: failed to transform resource: TOCSS: failed to transform "scss/main.scss" (text/x-scss): this feature is not available in your current Hugo version

Expand Down
1 change: 1 addition & 0 deletions api-ref-generator
Submodule api-ref-generator added at ce9745
3 changes: 2 additions & 1 deletion content/en/docs/reference/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ This section of the Kubernetes documentation contains references.

## API Reference

* [API Reference for Kubernetes {{< param "version" >}}](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
* [Kubernetes API Reference](/docs/reference/kubernetes-api/)
* [One-page API Reference for Kubernetes {{< param "version" >}}](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/)
* [Using The Kubernetes API](/docs/reference/using-api/) - overview of the API for Kubernetes.

## API Client Libraries
Expand Down
6 changes: 5 additions & 1 deletion content/en/docs/reference/kubernetes-api/_index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
title: API Reference
title: "Kubernetes API"
weight: 30
---

<!-- overview -->

{{< glossary_definition prepend="Kubernetes' API is" term_id="kubernetes-api" length="all" >}}
6 changes: 0 additions & 6 deletions content/en/docs/reference/kubernetes-api/api-index.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Authentication Resources"
weight: 4
---
Loading