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

Add docs on Hybrid operator #136

Open
3 of 11 tasks
varshaprasad96 opened this issue Nov 30, 2021 · 8 comments
Open
3 of 11 tasks

Add docs on Hybrid operator #136

varshaprasad96 opened this issue Nov 30, 2021 · 8 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@varshaprasad96
Copy link
Member

varshaprasad96 commented Nov 30, 2021

There are no docs related to hybrid operators. We would need docs to encourage users to start using hybrid operators which is an extension of Helm based operators.

Update:
The proposal is to have docs in a separate directory with the following high level contents:

  • Overview on Hybrid Operators
  • Quickstart on creating a hybrid operator
  • Tutorial on creating a hybrid operator

Subsections:

@jmrodri
Copy link
Member

jmrodri commented Nov 30, 2021

Transform this ticket into a meta issue for docs related items. During the Helm community meeting we brought up the issue of where to host it, for now let's focus on the content and deal with hosting later.

@jmrodri jmrodri self-assigned this Nov 30, 2021
@varshaprasad96
Copy link
Member Author

Updated this to be a meta-issue with sub sections.

@laxmikantbpandhare laxmikantbpandhare added the documentation Improvements or additions to documentation label Mar 22, 2022
@ryanm101
Copy link

ryanm101 commented Nov 27, 2023

Any update on this as I'm trying to make a hybrid operator and it's non-obvious.

e.g.

# Create the go modules file
go mod init example.com/m/v2

# Create the initial operator - API
operator-sdk init --plugins=helm  --domain=example.com  --kind=CMAPI  --helm-chart=../helm/cm/charts/cmapi

# Allow multiple Helm charts
echo "multigroup: true" >> ./PROJECT

# Create the UI operator
operator-sdk create api --helm-chart=../helm/cm/charts/cmui --kind=CMUI

# Add Reconciler
operator-sdk create api --group=api --kind CM --resource --controller --plugins=go/v4-alpha --version v1beta1

results in the error: FATA[0000] failed to create API: unable to run pre-scaffold tasks of "base.go.kubebuilder.io/v4-alpha": cmd/main.go file should present in the root directory

I know documentation is the bane of all things but it's rather critical to a project like this.

@varshaprasad96
Copy link
Member Author

@ryanm101 Detailed docs are available here: https://github.com/operator-framework/helm-operator-plugins/blob/main/docs/tutorial.md. Also a sample project generated using these commands can be referred here: https://github.com/operator-framework/helm-operator-plugins/tree/main/testdata/hybrid/memcached-operator.

The error you are witnessing here is because of the go/v4-alpha plugin version. The hybrid helm project currently isn't modified to support go/v4 plugins yet. I would suggest to use go/v3 for now. A separate issue needs to be created to add support for the recent scaffolding changes in v4 versions of go plugin.

@ryanm101
Copy link

ryanm101 commented Nov 27, 2023

So a bit more playing results in

go mod init example.com/m/v2



# Create the initial operator - API
operator-sdk init --plugins=hybrid.helm.sdk.operatorframework.io  --domain=example.com

echo "multigroup: true" >> ./PROJECT

# Create the UI operator
operator-sdk create api --helm-chart=../helm/cm/charts/cmapi --kind=CMAPI --plugins helm.sdk.operatorframework.io/v1
operator-sdk create api --helm-chart=../helm/cm/charts/cmui --kind=CMUI --plugins helm.sdk.operatorframework.io/v1

then operator-sdk create api --group=api --kind CM --resource --controller --plugins=go/v3 --version=v1alpha1 results in:

go: finding module for package example.com/m/v2/api/api/v1alpha1
go: example.com/m/v2 imports
        example.com/m/v2/api/api/v1alpha1: cannot find module providing package example.com/m/v2/api/api/v1alpha1: unrecognized import path "example.com/m/v2/api/api/v1alpha1": parse https://example.com/m/v2/api/api/v1alpha1?go-get=1: no go-import meta tags ()
Error: failed to create API: unable to run post-scaffold tasks of "base.go.kubebuilder.io/v3": exit status 1
Usage:
  operator-sdk create api [flags]

with go/v4-alpha i get:

FATA[0000] failed to create API: unable to run pre-scaffold tasks of "base.go.kubebuilder.io/v4-alpha": cmd/main.go file should present in the root directory 

Following Doc here: https://docs.openshift.com/container-platform/4.14/operators/operator_sdk/helm/osdk-hybrid-helm.html

@ryanm101
Copy link

Issue seems to be in the imports in main.go

it's looking in <rootdir>/api but it's creating everything in <rootdir>/apis

it's caused by multigroup.

setting all the components to single group works.

# Create the go modules file
go mod init example.com/m/v2

# Create the initial operator - API
echo "INITIALISING OPERATOR"
operator-sdk init --plugins=hybrid.helm.sdk.operatorframework.io --project-version="3" --domain=example.com
#operator-sdk edit --multigroup=true # fails

# Create the UI operator
operator-sdk create api --helm-chart=../helm/cm-api --kind=CMAPI --plugins helm.sdk.operatorframework.io/v1  --group cm
operator-sdk create api --helm-chart=../helm/cm-ui --kind=CMUI --plugins helm.sdk.operatorframework.io/v1  --group cm

echo "Adding Custom Controller"
operator-sdk create api --group cm --kind CM --resource --controller --plugins=go/v3 --version=v1

@ryanm101
Copy link

ryanm101 commented Nov 27, 2023

Though now i see

make build
make: *** No rule to make target `build'.  Stop.
operator-sdk version
operator-sdk version: "v1.32.0", commit: "4dcbbe343b29d325fd8a14cc60366335298b40a3", kubernetes version: "v1.26.0", go version: "go1.21.1", GOOS: "darwin", GOARCH: "arm64"

is it because i'm on a mac M1?

@varshaprasad96
Copy link
Member Author

@ryanm101 Could you share your Makefile which is scaffolded by the project?

is it because i'm on a mac M1?

It shouldn't matter, the build target should appear either ways. I see that in testdata:

build: manifests generate fmt vet ## Build manager binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants