Skip to content

Comments

[Feature] Add BanyanDB CRD & Controllers#70

Merged
wu-sheng merged 19 commits intoapache:masterfrom
SzyWilliam:banyandb_crd
Sep 24, 2022
Merged

[Feature] Add BanyanDB CRD & Controllers#70
wu-sheng merged 19 commits intoapache:masterfrom
SzyWilliam:banyandb_crd

Conversation

@SzyWilliam
Copy link
Member

Original Issue

apache/skywalking#9396

What changes brought in this PR

In this PR, I add CRD for BanyanDB.

  1. Use StatefulSet as BanyanDB's underlying controller, so that we can benefit from its stable network identifiers or storage, plus future extensions.
  2. Use Service as BanyanDB's networking identifier for internal access & communication.
  3. Use LocalPV as BanyanDB's default storage choice.

@wu-sheng wu-sheng requested a review from hanahmily July 29, 2022 04:09
@wu-sheng
Copy link
Member

I can't see an e2e to verify this.
SWCK should be verified whether it really could deploy.

@dashanji
Copy link
Member

dashanji commented Jul 29, 2022

@wu-sheng @lujiajing1126 This is a draft pr for the osapp project. The student @SzyWilliam should still be coding, but I'm not familiar with some features of Banyandb, so could you please confirm whether the Spec field can meet all the current banyandb requirements?

@wu-sheng
Copy link
Member

Then this PR should be labeled aa draft or use issue or discussion panel to talk.
PR could trigger mail notifications for reviewers.

@wu-sheng
Copy link
Member

BTW, I think you ping a wrong people.

@SzyWilliam SzyWilliam marked this pull request as draft July 29, 2022 05:33

// BanyanDB Storage
// +kubebuilder:validation:Optional
Storage corev1.PersistentVolumeClaim `json:"storage,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be an array. BanyanDB support placing files into separate storage.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

State BanyanDBState `json:"state,omitempty"`
// Represents the latest available observations of the underlying statefulset's current state.
// +kubebuilder:validation:Optional
Conditions []appsv1.StatefulSetCondition `json:"conditions,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Deployment is good to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


const (
Ready BanyanDBState = iota
Reconciling
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate on Reconciling? Add more comments to all states.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've deleted this field.

Storage corev1.PersistentVolumeClaim `json:"storage,omitempty"`
}

type BanyanDBState int8

Choose a reason for hiding this comment

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

string is much better for readability and inspection

Copy link
Member Author

Choose a reason for hiding this comment

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

I've deleted this BanyanDBState


// BanyanDB Storage
// +kubebuilder:validation:Optional
Storage corev1.PersistentVolumeClaim `json:"storage,omitempty"`

Choose a reason for hiding this comment

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

We only need *corev1.PersistentVolumeClaimSpec here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Have to support multi-storages, the type could be []corev1.PersistentVolumeClaim

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@lujiajing1126
Copy link

@wu-sheng @lujiajing1126 This is a draft pr for the osapp project. The student @SzyWilliam should still be coding, but I'm not familiar with some features of Banyandb, so could you please confirm whether the Spec field can meet all the current banyandb requirements?

As I understand, since the current version of BanyanDB only has a single node, Deployment can meet our requirement.

The operator for VictoriaMetrics and its VMSingle CRD can be a good reference for us.

@SzyWilliam
Copy link
Member Author

As I understand, since the current version of BanyanDB only has a single node, Deployment can meet our requirement.
@lujiajing1126 Thanks for your reply! If we consider future extensions, a StatefulSet will be great for a BanyanDB cluster since it provides bindings on pv & network identifier. Why don't we use StatefulSet now?

@lujiajing1126
Copy link

@lujiajing1126 Thanks for your reply! If we consider future extensions, a StatefulSet will be great for a BanyanDB cluster since it provides bindings on pv & network identifier. Why don't we use StatefulSet now?

Actually, I'm neutral about the choice. I would just say Deployment is definitely much simpler and thus has lower cost. The cluster version is on our roadmap but with very few details. It is not possible for us now to cover all what we need in the future.

@hanahmily
Copy link
Contributor

Deployment is better here. The cluster mode will know each node's roles, we don't leverage statefulset to get stable and ordered network endpoints and pv.

@SzyWilliam SzyWilliam force-pushed the banyandb_crd branch 2 times, most recently from 329d794 to 4b324c1 Compare September 7, 2022 03:08
@SzyWilliam SzyWilliam marked this pull request as ready for review September 7, 2022 06:08
@SzyWilliam
Copy link
Member Author

@dashanji @hanahmily @lujiajing1126 Hi, I've completed a minimal working BanyanDB CRD&Controller for SWCK. It passes e2e tests. Please take a look at this, thanks!
There are still some advanced features to be added, like TLS config for banyandb. I plan to add these features in future PRs.

@SzyWilliam SzyWilliam requested review from hanahmily and lujiajing1126 and removed request for hanahmily and lujiajing1126 September 20, 2022 07:14
@SzyWilliam
Copy link
Member Author

@dashanji Thanks for your reviews! I've completed the full banyandb crd & controller implementation with corresponding e2e tests. @wu-sheng @hanahmily @lujiajing1126 Please take a look at it~🫰

Copy link
Contributor

@hanahmily hanahmily left a comment

Choose a reason for hiding this comment

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

You have to expose the HTTP port and add a new HTTP-based service.

The HTTP service should support the ingress to route traffic to it.

# specific language governing permissions and limitations
# under the License.

kind: ClusterRole
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this role since the server doesn't touch the API server?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I have removed ClusterRole & ClusterRoleBinding

@SzyWilliam
Copy link
Member Author

@hanahmily Thanks for the reviews! I've exposed HTTP port and added an ingress resource to route HTTP requests, PTAL. I have a question: according to banyandb github page, we do not support http server for now. Does banyandb support HTTP server now? If so, how I can query data using HTTP?

@hanahmily
Copy link
Contributor

we do not support http server for now. Does banyandb support HTTP server now?

We supported the HTTP server in the main branch. It will be released in v0.2.0.

If so, how I can query data using HTTP?

bydbctl will take it. The primitive commands will be released in v0.2.0 with the HTTP server.

And you could access the HTTP endpoint directly. The API specifications are at https://github.com/apache/skywalking-banyandb/blob/main/api/proto/openapi

Copy link
Contributor

@hanahmily hanahmily left a comment

Choose a reason for hiding this comment

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

Please add a new service to serve HTTP/17913

@SzyWilliam
Copy link
Member Author

@hanahmily Thanks for the reply and providing framework on Service. I'll use separate gRPC Service and HTTP service. I plan to use bydbctl to verify banyandb data storage in E2E Tests after 0.2.0 release, so I'll just add a todo for now.

@SzyWilliam
Copy link
Member Author

I've made changes on code:

  1. separate grpc & http into two service resources, expose 17912/17913 respectively.
  2. remove unused ports 2121 6060.
    @hanahmily Please take a look at it again, thanks!

hanahmily
hanahmily previously approved these changes Sep 23, 2022
Copy link
Contributor

@hanahmily hanahmily left a comment

Choose a reason for hiding this comment

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

LGTM @SzyWilliam @dashanji Great job!

@wu-sheng
Copy link
Member

It is great to see this PR is getting ready after months of work. Congrats.

@wu-sheng wu-sheng requested a review from dashanji September 23, 2022 01:15
dashanji
dashanji previously approved these changes Sep 23, 2022
Copy link
Member

@dashanji dashanji left a comment

Choose a reason for hiding this comment

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

LGTM!

@wu-sheng
Copy link
Member

@lujiajing1126 We need your confirmation here. Please recheck.

overlay.AvailableReplicas = deployment.Status.AvailableReplicas
}
if apiequal.Semantic.DeepDerivative(overlay, banyanDB.Status) {
log.Info("Status keeps the same as before")
Copy link

@lujiajing1126 lujiajing1126 Sep 23, 2022

Choose a reason for hiding this comment

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

I think we have to return here to avoid unexpected reconciliation? @dashanji

Copy link
Member

Choose a reason for hiding this comment

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

Make sense. We could return here to avoid update the same resources. Thanks for the catching, and the other controllers have the same questions. Could you please update them together ? @SzyWilliam

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@SzyWilliam SzyWilliam dismissed stale reviews from dashanji and hanahmily via fbd2742 September 24, 2022 01:55
@SzyWilliam
Copy link
Member Author

@lujiajing1126 Thanks for the careful review! I've made changes on code, please take a look again.

Copy link

@lujiajing1126 lujiajing1126 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants