Skip to content

Commit cf1b5e0

Browse files
authored
Merge pull request #267 from srleyva/cli-docs
doc/user-guide.md: add docs for cli cmd build
2 parents d1213a0 + b3ae4e9 commit cf1b5e0

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

doc/sdk-cli-reference.md

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# CLI Guide
2+
3+
```bash
4+
Usage:
5+
operator-sdk [command]
6+
```
7+
8+
## build
9+
10+
### Args
11+
12+
* image - is the container image to be built, e.g. "quay.io/example/operator:v0.0.1". This image will be automatically set in the deployment manifests.
13+
14+
### Flags
15+
16+
* `-h, --help` - help for build
17+
18+
### Use
19+
20+
The operator-sdk build command compiles the code, builds the executables,
21+
and generates Kubernetes manifests. After build completes, the image would be built locally in docker. Then it needs to be pushed to remote registry.
22+
23+
### Example:
24+
25+
#### Build
26+
27+
```bash
28+
operator-sdk build quay.io/example/operator:v0.0.1
29+
30+
# Output:
31+
building example-operator...
32+
33+
building container quay.io/example/operator:v0.0.1...
34+
Sending build context to Docker daemon 163.9MB
35+
Step 1/4 : FROM alpine:3.6
36+
---> 77144d8c6bdc
37+
Step 2/4 : ADD tmp/_output/bin/example-operator /usr/local/bin/example-operator
38+
---> 2ada0d6ca93c
39+
Step 3/4 : RUN adduser -D example-operator
40+
---> Running in 34b4bb507c14
41+
Removing intermediate container 34b4bb507c14
42+
---> c671ec1cff03
43+
Step 4/4 : USER example-operator
44+
---> Running in bd336926317c
45+
Removing intermediate container bd336926317c
46+
---> d6b58a0fcb8c
47+
Successfully built d6b58a0fcb8c
48+
Successfully tagged quay.io/example/operator:v0.0.1
49+
```
50+
51+
## completion
52+
53+
### Available Commands
54+
55+
#### bash - Generate bash completions
56+
57+
##### Flags
58+
59+
* `-h, --help` - help for bash
60+
61+
#### zsh - Generate zsh completions
62+
63+
##### Flags
64+
65+
* `-h, --help` - help for zsh
66+
67+
### Flags
68+
69+
* `-h, --help` - help for completion
70+
71+
### Use
72+
73+
Generators for shell completions
74+
75+
Example:
76+
77+
```bash
78+
operator-sdk completion bash
79+
80+
# Output:
81+
# bash completion for operator-sdk -*- shell-script -*-
82+
...
83+
# ex: ts=4 sw=4 et filetype=sh
84+
```
85+
86+
## generate
87+
88+
### Available Commands
89+
90+
#### k8s - Generates Kubernetes code for custom resource
91+
92+
##### Use
93+
94+
k8s generator generates code for custom resource given the API spec
95+
to comply with kube-API requirements.
96+
97+
##### Flags
98+
99+
* `-h, --help` - help for k8s
100+
101+
##### Example
102+
103+
```bash
104+
operator-sdk generate k8s
105+
106+
# Output:
107+
Run code-generation for custom resources
108+
Generating deepcopy funcs
109+
```
110+
111+
#### olm-catalog - Generates OLM Catalog manifests
112+
113+
##### Flags
114+
115+
* `--image` **(required)** string - The container image name to set in the CSV to deploy the operator e.g: quay.io/example/operator:v0.0.1
116+
* `--version` **(required)** string - The version of the current CSV e.g: 0.0.1
117+
* `-h, --help` - help for olm-catalog
118+
119+
##### Example
120+
121+
```bash
122+
operator-sdk generate olm-catalog --image=quay.io/example/operator:v0.0.1 --version=0.0.1
123+
124+
# Output:
125+
Generating OLM catalog manifests
126+
```
127+
128+
### Flags
129+
130+
* `-h, --help` - help for generate
131+
132+
## new
133+
134+
The operator-sdk new command creates a new operator application and
135+
generates a default directory layout based on the input `project-name`.
136+
137+
### Args
138+
139+
* `project-name` - the project name of the new
140+
141+
### Flags
142+
143+
* `--api-version` **(required)** string - Kubernetes apiVersion and has a format of `$GROUP_NAME/$VERSION` (e.g app.example.com/v1alpha1)
144+
* `--kind` **(required)** string - Kubernetes CustomResourceDefintion kind. (e.g AppService)
145+
* `-h, --help` - help for new
146+
147+
### Example
148+
149+
```bash
150+
mkdir $GOPATH/src/github.com/example.com/
151+
cd $GOPATH/src/github.com/example.com/
152+
operator-sdk new app-operator --api-version=app.example.com/v1alpha1 --kind=AppService
153+
154+
# Output:
155+
Create app-operator/.gitignore
156+
...
157+
```
158+
159+
## up
160+
161+
### Available Commands
162+
163+
#### local - Launches the operator locally
164+
165+
##### Use
166+
167+
The operator-sdk up local command launches the operator on the local machine
168+
by building the operator binary with the ability to access a
169+
kubernetes cluster using a kubeconfig file.
170+
171+
##### Flags
172+
173+
* `--kubeconfig` string - The file path to kubernetes configuration file; defaults to $HOME/.kube/config
174+
175+
* `--namespace` string - The namespace where the operator watches for changes. (default "default")
176+
177+
* `--operator-flags` - Flags that the local operator may need.
178+
179+
* `-h, --help` - help for local
180+
181+
##### Example
182+
183+
```bash
184+
operator-sdk up local --kubeconfig "mycluster.kubecfg" \
185+
--namespace "default" \
186+
--operator-flags "--flag1 value1 --flag2=value2"
187+
```
188+
189+
### Flags
190+
191+
* `-h, --help` - help for up

0 commit comments

Comments
 (0)