1
1
---
2
2
title : Generating Reference Documentation for kubectl Commands
3
3
content_template : templates/task
4
+ weight : 90
4
5
---
5
6
6
7
{{% capture overview %}}
7
8
8
- This page shows how to automatically generate reference pages for the
9
- commands provided by the ` kubectl ` tool.
9
+ This page shows how to generate the ` kubectl ` command reference.
10
10
11
11
{{< note >}}
12
12
This topic shows how to generate reference documentation for
@@ -23,29 +23,12 @@ reference page, see
23
23
24
24
{{% /capture %}}
25
25
26
-
27
26
{{% capture prerequisites %}}
28
27
29
- * You need to have
30
- [ Git] ( https://git-scm.com/book/en/v2/Getting-Started-Installing-Git )
31
- installed.
32
-
33
- * You need to have
34
- [ Golang] ( https://golang.org/doc/install ) version 1.9.1 or later installed,
35
- and your ` $GOPATH ` environment variable must be set.
36
-
37
- * You need to have
38
- [ Docker] ( https://docs.docker.com/engine/installation/ ) installed.
39
-
40
- * You need to know how to create a pull request to a GitHub repository.
41
- Typically, this involves creating a fork of the repository. For more
42
- information, see
43
- [ Creating a Documentation Pull Request] ( /docs/home/contribute/create-pull-request/ ) and
44
- [ GitHub Standard Fork & Pull Request Workflow] ( https://gist.github.com/Chaser324/ce0505fbed06b947d962 ) .
28
+ {{< include "prerequisites-ref-docs.md" >}}
45
29
46
30
{{% /capture %}}
47
31
48
-
49
32
{{% capture steps %}}
50
33
51
34
## Setting up the local repositories
@@ -85,8 +68,7 @@ Remove the spf13 package from `$GOPATH/src/k8s.io/kubernetes/vendor/github.com`.
85
68
rm -rf $GOPATH /src/k8s.io/kubernetes/vendor/github.com/spf13
86
69
```
87
70
88
- The kubernetes/kubernetes repository provides access to the kubectl and kustomize source code.
89
-
71
+ The kubernetes/kubernetes repository provides the ` kubectl ` and ` kustomize ` source code.
90
72
91
73
* Determine the base directory of your clone of the
92
74
[ kubernetes/kubernetes] ( https://github.com/kubernetes/kubernetes ) repository.
@@ -108,15 +90,16 @@ The remaining steps refer to your base directory as `<rdocs-base>`.
108
90
109
91
In your local k8s.io/kubernetes repository, check out the branch of interest,
110
92
and make sure it is up to date. For example, if you want to generate docs for
111
- Kubernetes 1.15 , you could use these commands:
93
+ Kubernetes 1.17 , you could use these commands:
112
94
113
95
``` shell
114
96
cd < k8s-base>
115
- git checkout release-1.15
116
- git pull https://github.com/kubernetes/kubernetes release-1.15
97
+ git checkout v1.17.0
98
+ git pull https://github.com/kubernetes/kubernetes v1.17.0
117
99
```
118
100
119
- If you do not need to edit the kubectl source code, follow the instructions to [ Edit the Makefile] ( #editing-makefile ) .
101
+ If you do not need to edit the ` kubectl ` source code, follow the instructions for
102
+ [ Setting build variables] ( #setting-build-variables ) .
120
103
121
104
## Editing the kubectl source code
122
105
@@ -152,65 +135,60 @@ milestone in your pull request. If you don’t have those permissions, you will
152
135
need to work with someone who can set the label and milestone for you.
153
136
{{< /note >}}
154
137
155
- ## Editing Makefile
138
+ ## Setting build variables
156
139
157
- Go to ` <rdocs-base> ` , and open the ` Makefile ` for editing:
140
+ Go to ` <rdocs-base> ` . On you command line, set the following environment variables.
158
141
159
- * Set ` K8SROOT ` to ` <k8s-base> ` .
160
- * Set ` WEBROOT ` to ` <web-base> ` .
161
- * Set ` MINOR_VERSION ` to the minor version of the docs you want to build. For example,
162
- if you want to build docs for Kubernetes 1.15 , set ` MINOR_VERSION ` to 15. Save and close the ` Makefile ` .
142
+ * Set ` K8S_ROOT ` to ` <k8s-base> ` .
143
+ * Set ` WEB_ROOT ` to ` <web-base> ` .
144
+ * Set ` K8S_RELEASE ` to the version of the docs you want to build.
145
+ For example, if you want to build docs for Kubernetes 1.17 , set ` K8S_RELEASE ` to 1.17 .
163
146
164
- For example, update the following variables :
147
+ For example:
165
148
166
- ```
167
- WEBROOT =$(GOPATH)/src/github.com/<your-username>/website
168
- K8SROOT =$(GOPATH)/src/k8s.io/kubernetes
169
- MINOR_VERSION=15
149
+ ``` shell
150
+ export WEB_ROOT =$( GOPATH) /src/github.com/< your-username> /website
151
+ export K8S_ROOT =$( GOPATH) /src/k8s.io/kubernetes
152
+ export K8S_RELEASE=1.17
170
153
```
171
154
172
- ## Creating a version directory
155
+ ## Creating a versioned directory
173
156
174
- The version directory is a staging area for the kubectl command reference build.
175
- The YAML files in this directory are used to create the structure and navigation
176
- of the kubectl command reference .
157
+ The ` createversiondirs ` build target creates a versioned directory
158
+ and copies the kubectl reference configuration files to the versioned directory.
159
+ The versioned directory name follows the pattern of ` v<major>_<minor> ` .
177
160
178
- In the ` <rdocs-base>/gen-kubectldocs/generators ` directory, if you do not already
179
- have a directory named ` v1_<MINOR_VERSION> ` , create one now by copying the directory
180
- for the previous version. For example, suppose you want to generate docs for
181
- Kubernetes 1.15, but you don't already have a ` v1_15 ` directory. Then you could
182
- create and populate a ` v1_15 ` directory by running these commands:
161
+ In the ` <rdocs-base> ` directory, run the following build target:
183
162
184
163
``` shell
185
- mkdir gen-kubectldocs/generators/v1_15
186
- cp -r gen-kubectldocs/generators/v1_14/ * gen-kubectldocs/generators/v1_15
164
+ cd < rdocs-base >
165
+ make createversiondirs
187
166
```
188
167
189
- ## Checking out a branch in k8s.io/kubernetes
168
+ ## Checking out a release tag in k8s.io/kubernetes
190
169
191
- In your local <k8s-base > repository, checkout the branch that has
170
+ In your local ` <k8s-base> ` repository, checkout the branch that has
192
171
the version of Kubernetes that you want to document. For example, if you want
193
- to generate docs for Kubernetes 1.15 , checkout the release-1.15 branch . Make sure
172
+ to generate docs for Kubernetes 1.17 , checkout the ` v1.17.0 ` tag . Make sure
194
173
you local branch is up to date.
195
174
196
175
``` shell
197
176
cd < k8s-base>
198
- git checkout release-1.15
199
- git pull https://github.com/kubernetes/kubernetes release-1.15
177
+ git checkout v1.17.0
178
+ git pull https://github.com/kubernetes/kubernetes v1.17.0
200
179
```
201
180
202
181
## Running the doc generation code
203
182
204
- In your local kubernetes-sigs/reference-docs repository, build and run the
205
- kubectl command reference generation code. You might need to run the command as root:
183
+ In your local ` <rdocs-base> ` , run the ` copycli ` build target. The command runs as ` root ` :
206
184
207
185
``` shell
208
186
cd < rdocs-base>
209
187
make copycli
210
188
```
211
189
212
- The ` copycli ` command will clean the staging directories, generate the kubectl command files,
213
- and copy the collated kubectl reference HTML page and assets to ` <web-base> ` .
190
+ The ` copycli ` command cleans the temporary build directory, generates the kubectl command files,
191
+ and copies the collated kubectl command reference HTML page and assets to ` <web-base> ` .
214
192
215
193
## Locate the generated files
216
194
@@ -237,7 +215,7 @@ static/docs/reference/generated/kubectl/kubectl-commands.html
237
215
static/docs/reference/generated/kubectl/navData.js
238
216
```
239
217
240
- Additionally, the output might show the modified files :
218
+ The output may also include :
241
219
242
220
```
243
221
static/docs/reference/generated/kubectl/scroll.js
@@ -275,13 +253,12 @@ A few minutes after your pull request is merged, your updated reference
275
253
topics will be visible in the
276
254
[ published documentation] ( /docs/home ) .
277
255
278
-
279
256
{{% /capture %}}
280
257
281
258
{{% capture whatsnext %}}
282
259
283
- * [ Generating Reference Documentation for Kubernetes Components and Tools ] ( /docs/home/ contribute/generated-reference/kubernetes-components / )
284
- * [ Generating Reference Documentation for the Kubernetes API ] ( /docs/home/ contribute/generated-reference /kubernetes-api / )
285
- * [ Generating Reference Documentation for the Kubernetes Federation API] ( /docs/home/ contribute/generated-reference/federation -api/ )
260
+ * [ Generating Reference Documentation Quickstart ] ( /docs/contribute/generate-ref-docs/quickstart / )
261
+ * [ Generating Reference Documentation for Kubernetes Components and Tools ] ( /docs/contribute/generate-ref-docs /kubernetes-components / )
262
+ * [ Generating Reference Documentation for the Kubernetes API] ( /docs/contribute/generate-ref-docs/kubernetes -api/ )
286
263
287
264
{{% /capture %}}
0 commit comments