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

feat: Add Feast Operator RBAC example with Kubernetes Authentication … #5077

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

redhatHameed
Copy link
Contributor

What this PR does / why we need it:

Adding Feast Operator RBAC example with Kubernetes Authentication

Which issue(s) this PR fixes:

Misc

@redhatHameed redhatHameed requested a review from a team as a code owner February 20, 2025 20:46
@redhatHameed
Copy link
Contributor Author

@tchughesiv @franciscojavierarceo @dmartinol when you get a chance, could you please provide review/feedback on this PR? Thanks!

@redhatHameed redhatHameed force-pushed the operator-rbac-example branch 2 times, most recently from 2bb0cd0 to 5f02b7b Compare February 25, 2025 18:37
@accorvin
Copy link

@redhatHameed one thing that's not obvious to me is how the test.py script makes use of the service account that is being used to connect to the feature store. I'm assuming it's automatically using some environment variable somewhere or something like that, but I'm not sure. Can we document that so it's more explicit?

I expect users will want to be able to connect to a feature store instance from a script that isn't running inside of a kubernetes pod, and I'm assuming doing so would require them to specify the token somewhere, so we should make it clear how they can do so.

@redhatHameed
Copy link
Contributor Author

@redhatHameed one thing that's not obvious to me is how the test.py script makes use of the service account that is being used to connect to the feature store. I'm assuming it's automatically using some environment variable somewhere or something like that, but I'm not sure. Can we document that so it's more explicit?

@accorvin Right, it's getting directly from the pod location. /var/run/secrets/kubernetes.io/serviceaccount/token
https://github.com/feast-dev/feast/blob/master/sdk/python/feast/permissions/client/kubernetes_auth_client_manager.py#L15
I will add this note.

I expect users will want to be able to connect to a feature store instance from a script that isn't running inside of a kubernetes pod, and I'm assuming doing so would require them to specify the token somewhere, so we should make it clear how they can do so.

That's also possible, we can use environment variable LOCAL_K8S_TOKEN https://github.com/feast-dev/feast/blob/master/sdk/python/feast/permissions/client/kubernetes_auth_client_manager.py#L50
let me change the example using locally instead from the pod and add missing document.

@redhatHameed redhatHameed marked this pull request as draft February 27, 2025 16:01
@redhatHameed redhatHameed force-pushed the operator-rbac-example branch 4 times, most recently from dfdc884 to 4a06332 Compare February 27, 2025 21:34
@redhatHameed redhatHameed marked this pull request as ready for review February 27, 2025 21:35
@redhatHameed
Copy link
Contributor Author

@accorvin can you take another look of this PR, I have updated the notebook to use local client instead of the pod. Thanks

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

I would contextualize some of the documentation that this is mostly relevant if you're an MLOps Engineer or Cluster Admin trying to add Feast to your k8s cluster.

@redhatHameed redhatHameed force-pushed the operator-rbac-example branch 4 times, most recently from d7eca8c to cbaa0ca Compare March 5, 2025 19:28
@redhatHameed redhatHameed force-pushed the operator-rbac-example branch from cbaa0ca to ed9f593 Compare March 5, 2025 19:29
@redhatHameed
Copy link
Contributor Author

I would contextualize some of the documentation that this is mostly relevant if you're an MLOps Engineer or Cluster Admin trying to add Feast to your k8s cluster.

@franciscojavierarceo Thanks yes make sense,

I have separated notebooks for setup operator and RBAC - > 1-setup-operator-rbac.ipynb which need to perform Admin or MLOps Engineer,

and client notebook -> 2-client.ipynb for specific to developer

Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

left some feedback.

"* `Registry Server`: Handles metadata storage for feature definitions.\n",
"* `Online Store Server`: Uses the `Registry Server` to query metadata and is responsible for low-latency serving of features.\n",
"* `Offline Store Server`: Uses the `Registry Server` to query metadata and provides access to batch data for historical feature retrieval.\n",
"* `Kubernetes` Authentication types for RBAC Configuration for Feast resources.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

The last 2 bullets doesn't seem to be related to "distributed topology of Feast services".
The last one in particular, it looks like it's an objective of the notebook rather any architectural component.

{
"metadata": {},
"cell_type": "markdown",
"source": "## Next Run Client notebook -> 2-client.ipynb"
Copy link
Contributor

Choose a reason for hiding this comment

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

can't this be a link instead?

"metadata": {},
"cell_type": "markdown",
"source": [
"## Configure the RBAC Permissions\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

This section code be a bit more descriptive on the intentions, to clarify what the code is doing

"start_time": "2025-03-05T18:50:19.362018Z"
}
},
"source": [
Copy link
Contributor

Choose a reason for hiding this comment

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

The same could be demonstrated by connecting a client to the registry server, w/o using the kubectl exec command. e.g., probably in the client notebook.
It probably depends on who's the target person we want to instruct with this notebook.

"source": [
"## Feast Client with RBAC\n",
"### RBAC Kubernetes Authentication\n",
"This Feast **Role-Based Access Control (RBAC)** in Kubernetes support authentication **inside a Kubernetes pod** and **outside a pod** when running a local script.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not clear about the "and outside a pod" part.
You mean that the RBAC solution authorizes the server endpoints against requests coming either from another K8s service or from an external client?
BTW: It's more intended to authorize than to authenticate

"- Developer just need create the binding with role and service account accordingly.\n",
"- Code Reference: \n",
"[Feast Kubernetes Auth Client Manager (Pod Token Usage)](https://github.com/feast-dev/feast/blob/master/sdk/python/feast/permissions/client/kubernetes_auth_client_manager.py#L15) \n",
"- See the example will use service account from pod [Example](https://github.com/feast-dev/feast/blob/master/examples/rbac-remote/client/k8s/)\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence seems confusing, any typo?

"Feast will use this token for authentication.\n",
"\n",
"Reference: \n",
"[Feast Authentication via `LOCAL_K8S_TOKEN`](https://github.com/feast-dev/feast/blob/master/sdk/python/feast/permissions/client/kubernetes_auth_client_manager.py#L50)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would link to the user guide instead, there's a reference here:
https://docs.feast.dev/master/getting-started/components/authz_manager#kubernetes-rbac-authorization

{
"metadata": {},
"cell_type": "markdown",
"source": "**The Operator creates the client ConfigMap containing the feature_store.yaml. We can retrieve it and port froward to local**",
Copy link
Contributor

Choose a reason for hiding this comment

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

what about The Operator creates the ConfigMap containing the feature_store.yaml for a client application

"metadata": {},
"cell_type": "markdown",
"source": [
"**Generating training data. The following test functions were copied from the `test_workflow.py` template but we added `try` blocks to print only \n",
Copy link
Contributor

Choose a reason for hiding this comment

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

all bold?

"name": "stdout",
"output_type": "stream",
"text": [
"An occurred while performing materialize incremental: \n",
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no evidence that this is a permission error, is there another issue on the client side that ew can attach to the notebook?

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

Successfully merging this pull request may close these issues.

6 participants