Skip to content

Commit cbbc4a6

Browse files
authored
Merge pull request #1224 from yue9944882/docs/crd-code-gen-pt1
CodeGen doc follow-up
2 parents 482de98 + c542a2a commit cbbc4a6

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

docs/generate-model-from-third-party-resources.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,42 @@ Alternatively, without this automatic code-generation process, you can always ma
55
models for CRDs by implementing [KubernetesObject](https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/common/KubernetesObject.java)
66
and [KubernetesListObject](https://github.com/kubernetes-client/java/blob/master/kubernetes/src/main/java/io/kubernetes/client/common/KubernetesListObject.java) interfaces.
77

8-
### Example Commands For remote CRD manifests
8+
### Setup Environment
9+
10+
1. Make there's an active docker daemon service working on your host, run `docker ps` to check it if
11+
it's correctly setup.
12+
13+
2. Generating your access token in [https://github.com/settings/tokens](https://github.com/settings/tokens)
14+
and grants it package-read privilege. And save your token into a local file `~/TOKEN.txt`.
15+
16+
3. Login to github docker registry by running:
17+
18+
```bash
19+
# TODO: replace USERNAME w/ your github alias
20+
cat ~/TOKEN.txt | docker login https://docker.pkg.github.com -u USERNAME --password-stdin
21+
```
22+
23+
### Code-generator Image
24+
25+
##### Usage
26+
27+
Basically the code-generator container works by automatically provisioning a kubernetes cluster on
28+
your local docker daemon and applies your CRDs onto the cluster. After verifying all the CRDs are
29+
correctly installed, we will download the OpenAPI schemas and generate a minimal java project which
30+
contains the generated class models for your CRDs.
31+
32+
To make code-generator container work, you're required to mount both the `docker.sock` and corresponding
33+
host path to the container so that it can connect to the docker service and save the generated project
34+
to your host path. There're also a few configuration items to adjust the code-generation behavior:
35+
36+
```bash
37+
-u: <CRD's download URL or file path, use it multiple times to read multiple CRDs>
38+
-n: <the target CRD group name, which is in the reverse order of ".spec.group">
39+
-p: <output package name for the generated java classes>
40+
-o: <output path of the generated project>
41+
```
42+
43+
##### Example Commands For remote CRD manifests
944
1045
Run the following commands and it will download and generate the java models for you. Note that
1146
a docker daemon service is required on the host.
@@ -27,12 +62,12 @@ docker run \
2762
```
2863
2964
30-
### Example Commands For local CRD manifests
65+
##### Example Commands For local CRD manifests
3166
32-
First of all, you're required to download/place your CRD manifests into a single YAML file or under
33-
one directory. In the following example, we're manually downloading the manifests to directory
34-
`/tmp/crds/`. And similar to code-generation from the remote manifests, we need to mount the crd
35-
file/directory into the code-generation container to make it work.
67+
First of all, make sure the CRD manifest present on your local host paths. In the following example,
68+
we're manually downloading the manifests to directory `/tmp/crds/`. And similar to code-generation
69+
from the remote manifests, we need to mount the crd file/directory into the code-generation container
70+
to make it work.
3671

3772
```bash
3873
# Downloading

0 commit comments

Comments
 (0)