Skip to content

Commit e917b86

Browse files
Merge pull request #765 from fao89/mergedataplane
Bringing dataplane APIs and controllers
2 parents 8627b58 + e05abcb commit e917b86

File tree

210 files changed

+41479
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+41479
-111
lines changed

.github/workflows/docs.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Docs
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- .github/workflows/docs*
12+
- apis/client/v1beta1/**
13+
- apis/core/v1beta1/**
14+
- apis/dataplane/v1beta1/**
15+
- docs/**
16+
- Gemfile
17+
jobs:
18+
deploy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Install Go
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version: 1.20.x
25+
- uses: actions/checkout@v4
26+
with:
27+
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
28+
fetch-depth: 0
29+
- uses: ruby/[email protected]
30+
with:
31+
ruby-version: '3.2'
32+
33+
- name: Install Asciidoc
34+
run: make docs-dependencies
35+
- name: Build docs
36+
run: |
37+
make docs
38+
39+
- name: Prepare gh-pages branch
40+
run: |
41+
git restore docs/assemblies/custom_resources.adoc
42+
git config user.name github-actions
43+
git config user.email [email protected]
44+
45+
git branch -D gh-pages &>/dev/null || true
46+
git checkout -b gh-pages 4cd0193fc6c5bc7e76f3a0148d0447fb0d7fbe6a
47+
48+
- name: Commit asciidoc docs
49+
run: |
50+
mkdir user dev
51+
mv docs_build/ctlplane/index-upstream.html index.html
52+
git add index.html
53+
git commit -m "Rendered docs"
54+
55+
- name: Push rendered docs to gh-pages
56+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
57+
run: |
58+
git push --force origin gh-pages

.github/workflows/kustom.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Kustomize Build
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- config/samples/**
12+
jobs:
13+
kustomize:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Install Go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.20.x
20+
- uses: actions/checkout@v4
21+
with:
22+
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
23+
fetch-depth: 0
24+
- name: download kustomize
25+
run: |
26+
mkdir bin
27+
LINK=https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh
28+
curl -Ss $LINK | bash -s -- 5.0.1 ./bin
29+
- name: kustomize build
30+
run: |
31+
cd config/samples/dataplane
32+
33+
for d in */ ; do
34+
echo "=============== $d ==============="
35+
../../../bin/kustomize build --load-restrictor LoadRestrictionsNone "$d"
36+
done

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ CI_TOOLS_REPO
3737
# generated workspace file
3838
go.work
3939
go.work.sum
40+
41+
# docs
42+
.bundle/
43+
docs_build/
44+
Gemfile.lock
45+
local/

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
2727
# Build manager
2828
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
2929

30+
RUN cp -r config/services ${DEST_ROOT}/services
31+
3032
# Use distroless as minimal base image to package the manager binary
3133
# Refer to https://github.com/GoogleContainerTools/distroless for more details
3234
FROM $OPERATOR_BASE_IMAGE
@@ -56,13 +58,17 @@ LABEL com.redhat.component="${IMAGE_COMPONENT}" \
5658
io.openshift.tags="${IMAGE_TAGS}"
5759
### DO NOT EDIT LINES ABOVE
5860

59-
ENV USER_UID=$USER_ID
61+
ENV USER_UID=$USER_ID \
62+
OPERATOR_SERVICES=/usr/share/openstack-operator/services/
6063

6164
WORKDIR /
6265

6366
# Install operator binary to WORKDIR
6467
COPY --from=builder ${DEST_ROOT}/manager .
6568

69+
# Install services
70+
COPY --from=builder ${DEST_ROOT}/services ${OPERATOR_SERVICES}
71+
6672
USER $USER_ID
6773

6874
ENV PATH="/:${PATH}"

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'asciidoctor', '~> 2.0', '>= 2.0.20'
4+
5+
# Uncomment for ability to render pdf:
6+
# gem 'asciidoctor-pdf', '~> 2.0', '>= 2.0.20'
7+
8+
# Uncomment for ability to convert Markdown to AsciiDoc
9+
gem 'kramdown-asciidoc'

Makefile

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ DOCKER_BUILD_ARGS ?=
7676
.PHONY: all
7777
all: build
7878

79+
##@ Docs
80+
81+
.PHONY: docs-dependencies
82+
docs-dependencies: .bundle
83+
84+
.PHONY: .bundle
85+
.bundle:
86+
if ! type bundle; then \
87+
echo "Bundler not found. On Linux run 'sudo dnf install /usr/bin/bundle' to install it."; \
88+
exit 1; \
89+
fi
90+
91+
bundle config set --local path 'local/bundle'; bundle install
92+
93+
.PHONY: docs
94+
docs: manifests docs-dependencies crd-to-markdown ## Build docs
95+
CRD_MARKDOWN=$(CRD_MARKDOWN) MAKE=$(MAKE) ./docs/build_docs.sh
96+
97+
.PHONY: docs-preview
98+
docs-preview: docs
99+
cd docs; $(MAKE) open-html
100+
101+
.PHONY: docs-watch
102+
docs-watch: docs-preview
103+
cd docs; $(MAKE) watch-html
104+
105+
.PHONY: docs-clean
106+
docs-clean:
107+
rm -r docs_build
108+
79109
##@ General
80110

81111
# The help target prints out all targets with their descriptions organized
@@ -133,11 +163,21 @@ golangci-lint:
133163
$(LOCALBIN)/golangci-lint run --fix
134164

135165
.PHONY: test
136-
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
166+
test: manifests generate gowork fmt vet envtest ginkgo ginkgo-run ## Run ginkgo tests with dependencies.
167+
168+
.PHONY: ginkgo-run
169+
ginkgo-run: ## Run ginkgo.
137170
source hack/export_related_images.sh && \
138171
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" \
139172
OPERATOR_TEMPLATES="$(PWD)/templates" \
140-
$(GINKGO) --trace --cover --coverpkg=../../pkg/openstack,../../pkg/openstackclient,../../pkg/util,../../controllers,../../apis/client/v1beta1,../../apis/core/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/... ./apis/client/...
173+
$(GINKGO) --trace --cover --coverpkg=../../pkg/openstack,../../pkg/openstackclient,../../pkg/util,../../controllers,../../apis/client/v1beta1,../../apis/core/v1beta1,../../apis/dataplane/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/... ./apis/client/...
174+
175+
.PHONY: test-all
176+
test-all: test golint golangci golangci-lint ## Run all tests.
177+
178+
.PHONY: cover
179+
cover: test ## Run tests and display functional test coverage
180+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go tool cover -html=cover.out
141181

142182
##@ Build
143183

@@ -176,7 +216,7 @@ docker-buildx: ## Build and push docker image for the manager for cross-platfor
176216
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
177217
- docker buildx create --name project-v3-builder
178218
docker buildx use project-v3-builder
179-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
219+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
180220
- docker buildx rm project-v3-builder
181221
rm Dockerfile.cross
182222

@@ -214,11 +254,15 @@ $(LOCALBIN):
214254
KUSTOMIZE ?= $(LOCALBIN)/kustomize
215255
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
216256
ENVTEST ?= $(LOCALBIN)/setup-envtest
257+
CRD_MARKDOWN ?= $(LOCALBIN)/crd-to-markdown
217258
GINKGO ?= $(LOCALBIN)/ginkgo
259+
KUTTL ?= $(LOCALBIN)/kubectl-kuttl
218260

219261
## Tool Versions
220262
KUSTOMIZE_VERSION ?= v3.8.7
221263
CONTROLLER_TOOLS_VERSION ?= v0.11.1
264+
CRD_MARKDOWN_VERSION ?= v0.0.3
265+
KUTTL_VERSION ?= 0.15.0
222266

223267
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
224268
.PHONY: kustomize
@@ -236,6 +280,11 @@ $(CONTROLLER_GEN): $(LOCALBIN)
236280
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
237281
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
238282

283+
.PHONY: crd-to-markdown
284+
crd-to-markdown: $(CRD_MARKDOWN) ## Download crd-to-markdown locally if necessary.
285+
$(CRD_MARKDOWN): $(LOCALBIN)
286+
test -s $(LOCALBIN)/crd-to-markdown || GOBIN=$(LOCALBIN) go install github.com/clamoriniere/crd-to-markdown@$(CRD_MARKDOWN_VERSION)
287+
239288
.PHONY: envtest
240289
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
241290
$(ENVTEST): $(LOCALBIN)
@@ -246,6 +295,16 @@ ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
246295
$(GINKGO): $(LOCALBIN)
247296
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo
248297

298+
.PHONY: kuttl-test
299+
kuttl-test: ## Run kuttl tests
300+
$(LOCALBIN)/kubectl-kuttl test --config kuttl-test.yaml tests/kuttl/tests $(KUTTL_ARGS)
301+
302+
.PHONY: kuttl
303+
kuttl: $(KUTTL) ## Download kubectl-kuttl locally if necessary.
304+
$(KUTTL): $(LOCALBIN)
305+
test -s $(LOCALBIN)/kubectl-kuttl || curl -L -o $(LOCALBIN)/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_VERSION)/kubectl-kuttl_$(KUTTL_VERSION)_linux_x86_64
306+
chmod +x $(LOCALBIN)/kubectl-kuttl
307+
249308
.PHONY: operator-sdk
250309
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
251310
operator-sdk: ## Download operator-sdk locally if necessary.
@@ -296,6 +355,12 @@ OPM = $(shell which opm)
296355
endif
297356
endif
298357

358+
.PHONY: yq
359+
yq: ## Download and install yq in local env
360+
test -s $(LOCALBIN)/yq || ( cd $(LOCALBIN) &&\
361+
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64.tar.gz -O - |\
362+
tar xz && mv yq_linux_amd64 $(LOCALBIN)/yq )
363+
299364
# Build make variables to export for shell
300365
MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^(IMAGE)|.*?(REGISTRY)$$/')
301366
SHELL_EXPORT = $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
@@ -394,6 +459,10 @@ run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
394459
source hack/export_related_images.sh && \
395460
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
396461

462+
.PHONY: webhook-cleanup
463+
webhook-cleanup:
464+
/bin/bash hack/clean_local_webhook.sh
465+
397466
# refresh the bundle extra data based on go.mod entries
398467
# bundle extra data includes:
399468
# - extracted ENV vars from all operators (required for webhooks)

OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
approvers:
33
- ci-approvers
44
- openstack-approvers
5+
- dataplane-approvers
56

67
reviewers:
78
- ci-approvers
89
- openstack-approvers
10+
- dataplane-approvers

OWNERS_ALIASES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@ aliases:
55
- lewisdenny
66
- frenzyfriday
77
- viroel
8+
docs-approvers:
9+
- igallagh-redhat
810
openstack-approvers:
911
- abays
1012
- dprince
1113
- olliewalsh
1214
- stuggi
15+
dataplane-approvers:
16+
- fao89
17+
- fultonj
18+
- rebtoor
19+
- slagle
20+
- bshephar
21+
- rabi
22+
- jpodivin

PROJECT

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,35 @@ resources:
4646
defaulting: true
4747
validation: true
4848
webhookVersion: v1
49+
- api:
50+
crdVersion: v1
51+
namespaced: true
52+
controller: true
53+
domain: openstack.org
54+
group: dataplane
55+
kind: OpenStackDataPlaneNodeSet
56+
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
57+
version: v1beta1
58+
webhooks:
59+
defaulting: true
60+
validation: true
61+
webhookVersion: v1
62+
- api:
63+
crdVersion: v1
64+
namespaced: true
65+
controller: true
66+
domain: openstack.org
67+
group: dataplane
68+
kind: OpenStackDataPlaneService
69+
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
70+
version: v1beta1
71+
- api:
72+
crdVersion: v1
73+
namespaced: true
74+
controller: true
75+
domain: openstack.org
76+
group: dataplane
77+
kind: OpenStackDataPlaneDeployment
78+
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
79+
version: v1beta1
4980
version: "3"

0 commit comments

Comments
 (0)