Skip to content

Conversation

varshaprasad96
Copy link
Member

@varshaprasad96 varshaprasad96 commented Jun 30, 2021

This PR adds a new plugin for hybrid helm operator. It has the scaffolding required for init command.

Usage:
operator-sdk init --plugins=hybrid.helm.sdk.operatorframework.io --project-version="3" --repo=github.com/example/memcached-operator

This scaffolds the following files:

├── Makefile
├── PROJECT
├── config
│   ├── default
│   │   ├── kustomization.yaml
│   │   ├── manager_auth_proxy_patch.yaml
│   │   └── manager_config_patch.yaml
│   ├── manager
│   │   ├── controller_manager_config.yaml
│   │   ├── kustomization.yaml
│   │   └── manager.yaml
│   ├── manifests
│   │   └── kustomization.yaml
│   ├── prometheus
│   │   ├── kustomization.yaml
│   │   └── monitor.yaml
│   ├── rbac
│   │   ├── auth_proxy_client_clusterrole.yaml
│   │   ├── auth_proxy_role.yaml
│   │   ├── auth_proxy_role_binding.yaml
│   │   ├── auth_proxy_service.yaml
│   │   ├── kustomization.yaml
│   │   ├── leader_election_role.yaml
│   │   ├── leader_election_role_binding.yaml
│   │   ├── role.yaml
│   │   ├── role_binding.yaml
│   │   └── service_account.yaml
│   └── scorecard
│       ├── bases
│       │   └── config.yaml
│       ├── kustomization.yaml
│       └── patches
│           ├── basic.config.yaml
│           └── olm.config.yaml
├── go.mod
├── go.sum
├── hack
│   └── boilerplate.go.txt
├── main.go
└── watches.yaml

Note: This scaffolding is when kustomize and scorecard plugins are bundled with hybrid operator plugin. Once this is done, we can either create api using helm or go/v3 plugins.

Ex:
Go plugin:

➜  hybrid-helm-operator: operator-sdk create api --group=cache --version v1alpha1 --kind Memcached --resource --controller --plugins=go/v3
Writing kustomize manifests for you to edit...
Writing scaffold for you to edit...
api/v1alpha1/memcached_types.go
controllers/memcached_controller.go
Update dependencies:
$ go mod tidy
Running make:
$ make generate
go: creating new go.mod: module tmp
Downloading sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1
go get: added sigs.k8s.io/controller-tools v0.4.1
/Users/vnarsing/go/src/github.com/example-inc/hybrid-helm-operator/bin/controller-gen object:headerFile="" paths="./..."

Helm plugin:

➜  hybrid-helm-operator: operator-sdk create api --helm-chart=gremlin --helm-chart-repo=https://helm.gremlin.com/ --plugins=helm
Writing kustomize manifests for you to edit...
Created helm-charts/gremlin
Generating RBAC rules
WARN[0001] The RBAC rules generated in config/rbac/role.yaml are based on the chart's default manifest. Some rules may be missing for resources that are only enabled with custom values, and some existing rules may be overly broad. Double check the rules generated in config/rbac/role.yaml to ensure they meet the operator's permission requirements.

The pkg/plugins/hybrid/v1alpha/testdata has been manually generated and added for reference in this PR. A testdata generator script needs to be implemented which writes the scaffolding directly from plugin (instead of wiring it with SDK) in a follow up PR.

@varshaprasad96
Copy link
Member Author

cc: @fabianvf @jmrodri

@coveralls
Copy link

coveralls commented Jun 30, 2021

Pull Request Test Coverage Report for Build 994610534

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.734%

Totals Coverage Status
Change from base Build 983493779: 0.0%
Covered Lines: 1381
Relevant Lines: 1539

💛 - Coveralls

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>
Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

We want main.go set up such that if you ran create api from the helm plugin we would begin reconciling those resources, which means on init we want to scaffold out the code responsible for loading the watches and setting up the reconcilers. Once that's in there everything else looks good to me

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>
@varshaprasad96 varshaprasad96 requested a review from fabianvf July 1, 2021 03:40
Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
Copy link
Member

Choose a reason for hiding this comment

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

I think we also need to copy the helm-charts directory

Copy link
Member

Choose a reason for hiding this comment

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

and generally probably need to be closer to the helm-operator base image though that can be a longer term thing

Copy link
Member Author

@varshaprasad96 varshaprasad96 Jul 2, 2021

Choose a reason for hiding this comment

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

added the helm chart repository. I have made the entry point to be the manager binary (for now), in a follow up Ill test it out and remove it (as entry point) if not needed.

@varshaprasad96 varshaprasad96 requested a review from fabianvf July 2, 2021 19:12
Copy link
Member

@fabianvf fabianvf left a comment

Choose a reason for hiding this comment

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

/lgtm
good first pass, needs some followup but this definitely serves as a good POC

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 2, 2021
@fabianvf fabianvf merged commit 51e53f5 into operator-framework:main Jul 4, 2021
varshaprasad96 added a commit to varshaprasad96/helm-operator-plugins that referenced this pull request Jul 26, 2021
* Add hybrid operator plugin

* Add testdata for hybrid operator plugin

* Fix lint

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>

* add logic to load watches in main.go

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>

* Add dockerfile and build commands

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>

* fix: dockerfile

Signed-off-by: varshaprasad96 <varshaprasad96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps area/sdk area/testing lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants