Skip to content

Commit 60842c9

Browse files
docs cleanup (#1004)
1 parent 6e2822c commit 60842c9

38 files changed

+3204
-11803
lines changed

.DS_Store

-6 KB
Binary file not shown.

.github/workflows/docs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
- name: Generate vars and api doc
4747
run: |
48-
make doc
48+
make docs
4949
working-directory: "__vm-operator-repo"
5050

5151
- name: Update operator docs in VM repo
@@ -63,7 +63,7 @@ jobs:
6363
\cp -f $png ../__vm-docs-repo/$newpng
6464
done
6565
# Autogenerated files
66-
cat ./vars.md > ../__vm-docs-repo/docs/operator/vars.md
66+
cat ./docs/vars.md > ../__vm-docs-repo/docs/operator/vars.md
6767
cat ./docs/api.md > ../__vm-docs-repo/docs/operator/api.md
6868
working-directory: "__vm-operator-repo"
6969

.github/workflows/main.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
pull_request:
99
branches:
1010
- master
11+
types:
12+
- opened
13+
- reopened
14+
- ready_for_review
15+
- converted_to_draft
1116
concurrency:
1217
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1318
cancel-in-progress: true
@@ -23,7 +28,6 @@ jobs:
2328
with:
2429
go-version: "1.22"
2530
id: go
26-
2731
- name: Run Trivy vulnerability scanner in repo mode
2832
uses: aquasecurity/trivy-action@master
2933
with:
@@ -38,18 +42,21 @@ jobs:
3842
uses: github/codeql-action/upload-sarif@v2
3943
with:
4044
sarif_file: "trivy-results.sarif"
41-
45+
- name: Set output variables
46+
id: vars
47+
run: |
48+
IMAGE_TAG=${GITHUB_SHA:0:7}
49+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
4250
- name: lint and test
51+
if: github.event.pull_request.draft == false
4352
env:
4453
GO111MODULE: on
54+
DOCKER_BUILD_ARGS: --cache-from=type=gha --cache-to=type=gha,mode=max
55+
TAG: ${{ steps.vars.outputs.IMAGE_TAG }}
4556
run: |
4657
make lint
4758
make test
48-
- name: Set output variables
49-
id: vars
50-
run: |
51-
IMAGE_TAG=${GITHUB_SHA:0:7}
52-
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
59+
TAG=${TAG} make test-e2e
5360
- name: build binary
5461
env:
5562
GO111MODULE: on

.github/workflows/release.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ jobs:
2222
make lint
2323
make test
2424
make build
25-
make test-e2e
26-
2725
- name: build crosscompile and push to remote registry
2826
env:
2927
TAG: "${{ github.event.release.tag_name }}"
3028
run: |
3129
echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin
3230
make publish
33-
3431
- name: Upload Release CRDs
3532
id: upload-release-crds
3633
uses: actions/upload-release-asset@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Temporary Build Files
2+
.DS_Store
23
Dockerfile.cross
34
.idea
45
bin/

CONTRIBUTING.md

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@
22
## Required programs
33

44
for developing you need:
5-
- golang 1.15+
6-
- operator-sdk v1.33.0
5+
- kubebuilder v4
6+
- golang 1.22+
77
- docker
8-
- minikube or kind for e2e tests
9-
- golangci-lint
10-
8+
- kubectl
119

1210
## installing local env
1311

14-
- make install-develop-tools
15-
- kind create cluster
12+
```bash
13+
# make install-tools
14+
```
1615

1716
## local build and run
1817

1918
Use `make build` - it will generate new crds and build binary
2019

21-
22-
for running locally you need minikube and run two commands:
20+
for running locally on kind you need to run:
2321
```bash
24-
make install
25-
make run
22+
make deploy-kind
2623
```
2724
or you can run it from IDE with ```main.go```
2825

@@ -33,40 +30,21 @@ before creating merge request, ensure that tests passed locally:
3330
make build # it will update crds
3431
make lint # linting project
3532
make test #unit tests
36-
make e2e-local #e2e tests with minikube
33+
make test-e2e #e2e tests with minikube
3734
```
3835

3936
## adding new api
4037

41-
For adding new kind - KIND_NAME, you have to execute command:
38+
For adding new kind - `KIND_NAME`, you have to execute command:
4239

4340
```bash
44-
operator-sdk create api --group operator --version v1beta1 --kind KIND_NAME
41+
kubebuilder create api --group operator --version v1beta1 --kind KIND_NAME
4542
```
4643

47-
This will scaffold api and controller. Then you have to edit code at `api` and `controllers` folder.
48-
49-
## create olm package
44+
For adding new webhook for a `KIND_NAME`, you have to execute command:
5045

51-
Choose version (release tag at github) and generate or update corresponding csv file
5246
```bash
53-
TAG=v0.36.0 make bundle
54-
```
55-
56-
it will generate files at directories: `bundle/`
57-
58-
### publish to operator-hub
59-
60-
checkout to the latest release:
61-
1) `git checkout tags/v0.36.0`
62-
2) build package manifest: `TAG=v0.36.0 make bundle`
63-
3) add replacement for a previous version to generated cluster csv:
64-
`vi bundle/manifests/victoriametrics-operator.clusterserviceversion`
65-
```yaml
66-
spec:
67-
replaces: victoriametrics-operator.v0.35.0
47+
kubebuilder create webhook --group operator --version v1beta1 --kind KIND_NAME --conversion --programmatic-validation
6848
```
69-
Now you have to fork two repos and create pull requests to them with new version `/bundle`:
70-
1) https://github.com/k8s-operatorhub/community-operators for OperatorHub.io
71-
2) https://github.com/redhat-openshift-ecosystem/community-operators-prod for Embedded OperatorHub in OpenShift and OKD.
7249

50+
This will scaffold api and controller. Then you have to edit code at `api/operator/v1beta1` and `internal/controller/operator` folder.

Makefile

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
88
git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -d' ' -f2 | cut -c 1-8)))
99
OVERLAY ?= config/default
1010

11-
COMMA = ,
12-
EMPTY =
13-
SPACE = $(EMPTY) $(EMPTY)
14-
1511
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1612
ENVTEST_K8S_VERSION = 1.30.0
1713

@@ -89,12 +85,14 @@ api-gen: client-gen lister-gen informer-gen
8985
--go-header-file hack/boilerplate.go.txt
9086
rm api/go.*
9187

92-
.PHONY: doc
93-
doc: envconfig-docs doc-print
94-
cat hack/doc/header.md > docs/api.md
95-
$(DOC_PRINT) --paths=$(subst $(SPACE),$(COMMA),$(wildcard ./api/operator/v1beta1/*_types.go)) --owner VictoriaMetrics >> docs/api.md
96-
cat hack/doc/vars.md > vars.md
97-
$(ENVCONFIG_DOCS) --input internal/config/config.go --truncate=false >> vars.md
88+
.PHONY: docs
89+
docs: envconfig-docs crd-ref-docs manifests
90+
$(CRD_REF_DOCS) --config ./docs/config.yaml \
91+
--templates-dir ./docs/templates/api \
92+
--renderer markdown
93+
mv out.md docs/api.md
94+
cat docs/headers/vars.md > docs/vars.md
95+
$(ENVCONFIG_DOCS) --input internal/config/config.go --truncate=false >> docs/vars.md
9896

9997
.PHONY: fmt
10098
fmt: ## Run go fmt against code.
@@ -124,7 +122,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
124122
##@ Build
125123

126124
.PHONY: build
127-
build: manifests generate fmt vet ## Build manager binary.
125+
build: docs generate fmt vet ## Build manager binary.
128126
go build -o bin/$(REPO) ./cmd/$(REPO)/...
129127

130128
.PHONY: run
@@ -138,6 +136,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
138136
docker-build: ## Build docker image with the manager.
139137
$(CONTAINER_TOOL) build \
140138
--build-arg REPO=$(REPO) \
139+
${DOCKER_BUILD_ARGS} \
141140
-t $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \
142141
-t $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) .
143142

@@ -165,6 +164,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
165164
--push \
166165
--platform=$(PLATFORMS) \
167166
--build-arg REPO=$(REPO) \
167+
$(DOCKER_BUILD_ARGS) \
168168
--tag $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \
169169
--tag $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) \
170170
-f Dockerfile.cross .
@@ -238,7 +238,7 @@ LISTER_GEN = $(LOCALBIN)/lister-gen-$(CODEGENERATOR_VERSION)
238238
INFORMER_GEN = $(LOCALBIN)/informer-gen-$(CODEGENERATOR_VERSION)
239239
KIND = $(LOCALBIN)/kind-$(KIND_VERSION)
240240
ENVCONFIG_DOCS = $(LOCALBIN)/envconfig-docs-$(ENVCONFIG_DOCS_VERSION)
241-
DOC_PRINT = $(LOCALBIN)/doc-print-$(DOC_PRINT_VERSION)
241+
CRD_REF_DOCS = $(LOCALBIN)/crd-ref-docs-$(CRD_REF_DOCS_VERSION)
242242

243243
## Tool Versions
244244
KUSTOMIZE_VERSION ?= v5.4.1
@@ -248,7 +248,7 @@ GOLANGCI_LINT_VERSION ?= v1.59.1
248248
CODEGENERATOR_VERSION ?= v0.30.2
249249
KIND_VERSION ?= v0.23.0
250250
ENVCONFIG_DOCS_VERSION ?= latest
251-
DOC_PRINT_VERSION ?= latest
251+
CRD_REF_DOCS_VERSION ?= latest
252252

253253
.PHONY: kustomize
254254
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -261,17 +261,17 @@ $(CONTROLLER_GEN): $(LOCALBIN)
261261
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
262262

263263
.PHONY: install-tools
264-
install-tools: envconfig-docs doc-print client-gen lister-gen informer-gen controller-gen kustomize envtest
264+
install-tools: envconfig-docs crd-ref-docs client-gen lister-gen informer-gen controller-gen kustomize envtest
265265

266266
.PHONY: envconfig-docs
267267
envconfig-docs: $(ENVCONFIG_DOCS)
268268
$(ENVCONFIG_DOCS): $(LOCALBIN)
269269
$(call go-install-tool,$(ENVCONFIG_DOCS),github.com/f41gh7/envconfig-docs,$(ENVCONFIG_DOCS_VERSION))
270270

271-
.PHONY: doc-print
272-
doc-print: $(DOC_PRINT)
273-
$(DOC_PRINT): $(LOCALBIN)
274-
$(call go-install-tool,$(DOC_PRINT),github.com/f41gh7/doc-print,$(DOC_PRINT_VERSION))
271+
.PHONY: crd-ref-docs
272+
crd-ref-docs: $(CRD_REF_DOCS)
273+
$(CRD_REF_DOCS): $(LOCALBIN)
274+
$(call go-install-tool,$(CRD_REF_DOCS),github.com/elastic/crd-ref-docs,$(CRD_REF_DOCS_VERSION))
275275

276276
.PHONY: client-gen
277277
client-gen: $(CLIENT_GEN)

README.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,7 @@ VictoriaMetrics provides [helm charts](https://github.com/VictoriaMetrics/helm-c
6161

6262
## Kubernetes' compatibility versions
6363

64-
operator tested at kubernetes versions
65-
from 1.25 to 1.29
66-
67-
## Troubleshooting
68-
69-
- cannot apply crd at kubernetes 1.18 + version and kubectl reports error:
70-
```bash
71-
Error from server (Invalid): error when creating "release/crds/crd.yaml": CustomResourceDefinition.apiextensions.k8s.io "vmalertmanagers.operator.victoriametrics.com" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[initContainers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property, spec.validation.openAPIV3Schema.properties[spec].properties[containers].items.properties[ports].items.properties[protocol].default: Required value: this property is in x-kubernetes-list-map-keys, so it must have a default or be a required property]
72-
Error from server (Invalid): error when creating "release/crds/crd.yaml": CustomResourceDefinition.apiextensions.k8s.io "vmalerts.operator.victoriametrics.com" is invalid: [
73-
```
74-
upgrade to the latest release version. There is a bug with kubernetes objects at the early releases.
64+
operator tested on officially supported Kubernetes versions
7565

7666
## Community and contributions
7767

@@ -86,22 +76,23 @@ Feel free asking any questions regarding VictoriaMetrics:
8676

8777
## Development
8878

89-
- operator-sdk verson v1.0.0 + [https://github.com/operator-framework/operator-sdk]
90-
- golang 1.15 +
91-
- minikube or kind
79+
Dependencies:
80+
- kubebuilder v4
81+
- golang 1.22+
82+
- kubectl
83+
- docker
9284

9385
start:
9486
```bash
9587
make run
9688
```
9789

98-
for test execution run:
90+
### to run unit tests
9991
```bash
100-
#unit tests
101-
10292
make test
93+
```
10394

104-
# you need minikube or kind for e2e, do not run it on live cluster
105-
#e2e tests with local binary
106-
make e2e-local
95+
### to run e2e tests on automatically configured Kind cluster
96+
```bash
97+
# make test-e2e
10798
```

api/operator/v1beta1/vmagent_types.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type VMAgentSpec struct {
6464
// eventually make the size of the running cluster equal to the expected
6565
// size.
6666
// NOTE enable VMSingle deduplication for replica usage
67-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Number of pods",xDescriptors="urn:alm:descriptor:com.tectonic.ui:podCount,urn:alm:descriptor:io.kubernetes:custom"
6867
// +optional
6968
ReplicaCount *int32 `json:"replicaCount,omitempty"`
7069
// The number of old ReplicaSets to retain to allow rollback in deployment or
@@ -84,7 +83,6 @@ type VMAgentSpec struct {
8483
VolumeMounts []v1.VolumeMount `json:"volumeMounts,omitempty"`
8584
// Resources container resource request and limits, https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
8685
// if not specified - default setting will be used
87-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Resources",xDescriptors="urn:alm:descriptor:com.tectonic.ui:resourceRequirements"
8886
// +optional
8987
Resources v1.ResourceRequirements `json:"resources,omitempty"`
9088
// Affinity If specified, the pod's scheduling constraints.
@@ -100,7 +98,6 @@ type VMAgentSpec struct {
10098
// ServiceAccountName is the name of the ServiceAccount to use to run the
10199
// VMAgent Pods.
102100
// +optional
103-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="ServiceAccount name",xDescriptors="urn:alm:descriptor:io.kubernetes:ServiceAccount"
104101
ServiceAccountName string `json:"serviceAccountName,omitempty"`
105102
// SchedulerName - defines kubernetes scheduler name
106103
// +optional
@@ -186,15 +183,13 @@ type VMAgentSpec struct {
186183
// for vm it must looks like: http://victoria-metrics-single:8429/api/v1/write
187184
// or for cluster different url
188185
// https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/app/vmagent#splitting-data-streams-among-multiple-systems
189-
// +optional
190186
RemoteWrite []VMAgentRemoteWriteSpec `json:"remoteWrite"`
191187
// RemoteWriteSettings defines global settings for all remoteWrite urls.
192-
// + optional
188+
// +optional
193189
RemoteWriteSettings *VMAgentRemoteWriteSettings `json:"remoteWriteSettings,omitempty"`
194190
// RelabelConfig ConfigMap with global relabel config -remoteWrite.relabelConfig
195191
// This relabeling is applied to all the collected metrics before sending them to remote storage.
196192
// +optional
197-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Key at Configmap with relabelConfig name",xDescriptors="urn:alm:descriptor:io.kubernetes:ConfigMapKeySelector"
198193
RelabelConfig *v1.ConfigMapKeySelector `json:"relabelConfig,omitempty"`
199194
// InlineRelabelConfig - defines GlobalRelabelConfig for vmagent, can be defined directly at CRD.
200195
// +optional
@@ -493,7 +488,6 @@ type VMAgentRemoteWriteSpec struct {
493488

494489
// ConfigMap with relabeling config which is applied to metrics before sending them to the corresponding -remoteWrite.url
495490
// +optional
496-
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Key at Configmap with relabelConfig for remoteWrite",xDescriptors="urn:alm:descriptor:io.kubernetes:ConfigMapKeySelector"
497491
UrlRelabelConfig *v1.ConfigMapKeySelector `json:"urlRelabelConfig,omitempty"`
498492
// InlineUrlRelabelConfig defines relabeling config for remoteWriteURL, it can be defined at crd spec.
499493
// +optional
@@ -567,13 +561,10 @@ type VMAgentStatus struct {
567561

568562
// VMAgent - is a tiny but brave agent, which helps you collect metrics from various sources and stores them in VictoriaMetrics
569563
// or any other Prometheus-compatible storage system that supports the remote_write protocol.
570-
// +operator-sdk:gen-csv:customresourcedefinitions.displayName="VMAgent App"
571-
// +operator-sdk:gen-csv:customresourcedefinitions.resources="Deployment,apps"
572-
// +operator-sdk:gen-csv:customresourcedefinitions.resources="Service,v1"
573-
// +operator-sdk:gen-csv:customresourcedefinitions.resources="Secret,v1"
574564
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
575565
// +genclient
576566
// +k8s:openapi-gen=true
567+
// +kubebuilder:object:root=true
577568
// +kubebuilder:subresource:status
578569
// +kubebuilder:resource:path=vmagents,scope=Namespaced
579570
// +kubebuilder:subresource:scale:specpath=.spec.shardCount,statuspath=.status.shards,selectorpath=.status.selector

0 commit comments

Comments
 (0)