Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bringing dataplane APIs and controllers #765

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build Docs
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- .github/workflows/docs*
- apis/client/v1beta1/**
- apis/core/v1beta1/**
- apis/dataplane/v1beta1/**
- docs/**
- Gemfile
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- uses: actions/checkout@v4
with:
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
fetch-depth: 0
- uses: ruby/[email protected]
with:
ruby-version: '3.2'

- name: Install Asciidoc
run: make docs-dependencies
- name: Build docs
run: |
make docs

- name: Prepare gh-pages branch
run: |
git restore docs/assemblies/custom_resources.adoc
git config user.name github-actions
git config user.email [email protected]

git branch -D gh-pages &>/dev/null || true
git checkout -b gh-pages 4cd0193fc6c5bc7e76f3a0148d0447fb0d7fbe6a

- name: Commit asciidoc docs
run: |
mkdir user dev
mv docs_build/ctlplane/index-upstream.html index.html
git add index.html
git commit -m "Rendered docs"

- name: Push rendered docs to gh-pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git push --force origin gh-pages
36 changes: 36 additions & 0 deletions .github/workflows/kustom.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Kustomize Build
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- config/samples/**
jobs:
kustomize:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- uses: actions/checkout@v4
with:
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
fetch-depth: 0
- name: download kustomize
run: |
mkdir bin
LINK=https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh
curl -Ss $LINK | bash -s -- 5.0.1 ./bin
- name: kustomize build
run: |
cd config/samples/dataplane

for d in */ ; do
echo "=============== $d ==============="
../../../bin/kustomize build --load-restrictor LoadRestrictionsNone "$d"
done
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ CI_TOOLS_REPO
# generated workspace file
go.work
go.work.sum

# docs
.bundle/
docs_build/
Gemfile.lock
local/
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
# Build manager
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

RUN cp -r config/services ${DEST_ROOT}/services

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM $OPERATOR_BASE_IMAGE
Expand Down Expand Up @@ -56,13 +58,17 @@ LABEL com.redhat.component="${IMAGE_COMPONENT}" \
io.openshift.tags="${IMAGE_TAGS}"
### DO NOT EDIT LINES ABOVE

ENV USER_UID=$USER_ID
ENV USER_UID=$USER_ID \
OPERATOR_SERVICES=/usr/share/openstack-operator/services/

WORKDIR /

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

# Install services
COPY --from=builder ${DEST_ROOT}/services ${OPERATOR_SERVICES}

USER $USER_ID

ENV PATH="/:${PATH}"
Expand Down
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'

gem 'asciidoctor', '~> 2.0', '>= 2.0.20'

# Uncomment for ability to render pdf:
# gem 'asciidoctor-pdf', '~> 2.0', '>= 2.0.20'

# Uncomment for ability to convert Markdown to AsciiDoc
gem 'kramdown-asciidoc'
75 changes: 72 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ DOCKER_BUILD_ARGS ?=
.PHONY: all
all: build

##@ Docs

.PHONY: docs-dependencies
docs-dependencies: .bundle

.PHONY: .bundle
.bundle:
if ! type bundle; then \
echo "Bundler not found. On Linux run 'sudo dnf install /usr/bin/bundle' to install it."; \
exit 1; \
fi

bundle config set --local path 'local/bundle'; bundle install

.PHONY: docs
docs: manifests docs-dependencies crd-to-markdown ## Build docs
CRD_MARKDOWN=$(CRD_MARKDOWN) MAKE=$(MAKE) ./docs/build_docs.sh

.PHONY: docs-preview
docs-preview: docs
cd docs; $(MAKE) open-html

.PHONY: docs-watch
docs-watch: docs-preview
cd docs; $(MAKE) watch-html

.PHONY: docs-clean
docs-clean:
rm -r docs_build

##@ General

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

.PHONY: test
test: manifests generate gowork fmt vet envtest ginkgo ## Run tests.
test: manifests generate gowork fmt vet envtest ginkgo ginkgo-run ## Run ginkgo tests with dependencies.

.PHONY: ginkgo-run
ginkgo-run: ## Run ginkgo.
source hack/export_related_images.sh && \
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) -v debug --bin-dir $(LOCALBIN) use $(ENVTEST_K8S_VERSION) -p path)" \
OPERATOR_TEMPLATES="$(PWD)/templates" \
$(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/...
$(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/...

.PHONY: test-all
test-all: test golint golangci golangci-lint ## Run all tests.

.PHONY: cover
cover: test ## Run tests and display functional test coverage
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go tool cover -html=cover.out

##@ Build

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

Expand Down Expand Up @@ -214,11 +254,15 @@ $(LOCALBIN):
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CRD_MARKDOWN ?= $(LOCALBIN)/crd-to-markdown
GINKGO ?= $(LOCALBIN)/ginkgo
KUTTL ?= $(LOCALBIN)/kubectl-kuttl

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.11.1
CRD_MARKDOWN_VERSION ?= v0.0.3
KUTTL_VERSION ?= 0.15.0

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

.PHONY: crd-to-markdown
crd-to-markdown: $(CRD_MARKDOWN) ## Download crd-to-markdown locally if necessary.
$(CRD_MARKDOWN): $(LOCALBIN)
test -s $(LOCALBIN)/crd-to-markdown || GOBIN=$(LOCALBIN) go install github.com/clamoriniere/crd-to-markdown@$(CRD_MARKDOWN_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand All @@ -246,6 +295,16 @@ ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
$(GINKGO): $(LOCALBIN)
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo

.PHONY: kuttl-test
kuttl-test: ## Run kuttl tests
$(LOCALBIN)/kubectl-kuttl test --config kuttl-test.yaml tests/kuttl/tests $(KUTTL_ARGS)

.PHONY: kuttl
kuttl: $(KUTTL) ## Download kubectl-kuttl locally if necessary.
$(KUTTL): $(LOCALBIN)
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
chmod +x $(LOCALBIN)/kubectl-kuttl

.PHONY: operator-sdk
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
operator-sdk: ## Download operator-sdk locally if necessary.
Expand Down Expand Up @@ -296,6 +355,12 @@ OPM = $(shell which opm)
endif
endif

.PHONY: yq
yq: ## Download and install yq in local env
test -s $(LOCALBIN)/yq || ( cd $(LOCALBIN) &&\
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 $(LOCALBIN)/yq )

# Build make variables to export for shell
MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^(IMAGE)|.*?(REGISTRY)$$/')
SHELL_EXPORT = $(foreach v,$(MAKE_ENV),$(v)='$($(v))')
Expand Down Expand Up @@ -394,6 +459,10 @@ run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
source hack/export_related_images.sh && \
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"

.PHONY: webhook-cleanup
webhook-cleanup:
/bin/bash hack/clean_local_webhook.sh

# refresh the bundle extra data based on go.mod entries
# bundle extra data includes:
# - extracted ENV vars from all operators (required for webhooks)
Expand Down
2 changes: 2 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
approvers:
- ci-approvers
- openstack-approvers
- dataplane-approvers

reviewers:
- ci-approvers
- openstack-approvers
- dataplane-approvers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the dataplane team own the entire repo?
@abays @dprince @olliewalsh @stuggi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its probably useful to introduce responsibilities. same the other way round. I guess we don't want to own the dataplane parts. but there will be shared things where it will be hard to separate ownership. I think we can do that in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to sticking with a single OWNERS file.

10 changes: 10 additions & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ aliases:
- lewisdenny
- frenzyfriday
- viroel
docs-approvers:
- igallagh-redhat
openstack-approvers:
- abays
- dprince
- olliewalsh
- stuggi
dataplane-approvers:
- fao89
- fultonj
- rebtoor
- slagle
- bshephar
- rabi
- jpodivin
31 changes: 31 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,35 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: dataplane
kind: OpenStackDataPlaneNodeSet
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
version: v1beta1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: dataplane
kind: OpenStackDataPlaneService
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openstack.org
group: dataplane
kind: OpenStackDataPlaneDeployment
path: github.com/openstack-k8s-operators/openstack-operator/apis/dataplane/v1beta1
version: v1beta1
version: "3"
Loading
Loading