Back to Feast

Feast Operator with RBAC Configuration

examples/operator-rbac/1-setup-operator-rbac.ipynb

0.63.07.8 KB
Original Source

Feast Operator with RBAC Configuration

Objective

This demo provides a reference implementation of a runbook on how to enable Role-Based Access Control (RBAC) for Feast using the Feast Operator with the Kubernetes authentication type. This serves as useful reference material for a cluster admin / MLOps engineer.

The demo steps include deploying the Feast Operator, creating Feast instances with server components (registry, offline store, online store), and Feast client testing locally and fom the Kubernetes. The goal is to ensure secure access control for Feast instances deployed by the Feast Operator.

Please read these reference documents for understanding the Feast RBAC framework.

Deployment Architecture

In this notebook, we will deploy a distributed topology of Feast services, which includes:

  • Registry Server: Handles metadata storage for feature definitions.
  • Online Store Server: Uses the Registry Server to query metadata and is responsible for low-latency serving of features.
  • Offline Store Server: Uses the Registry Server to query metadata and provides access to batch data for historical feature retrieval.

Additionally, we will cover:

  • RBAC Configuration with Kubernetes Authentication for Feast resources.

Prerequisites

  • Kubernetes Cluster
  • kubectl Kubernetes CLI tool.

Install Prerequisites

The following commands install and configure all the prerequisites on a MacOS environment. You can find the equivalent instructions on the offical documentation pages:

  • Install the kubectl cli.
  • Install Kubernetes and Container runtime (e.g. Colima).
    • Alternatively, authenticate to an existing Kubernetes or OpenShift cluster.
bash
brew install colima kubectl
colima start -r containerd -k -m 3 -d 100 -c 2 --cpu-type max -a x86_64
colima list
python
!kubectl create ns feast
!kubectl config set-context --current --namespace feast

Validate the cluster setup:

python
!kubectl get ns feast

Feast Admin Steps:

Feast Admins or MLOps Engineers may require Kubernetes Cluster Admin roles when working with OpenShift or Kubernetes clusters. Below is the list of steps Required to set up Feast RBAC with the Operator by an Admin or MLOps Engineer.

  1. Install the Feast Operator
  2. Install the Feast services via FeatureStore CR
  3. Configure the RBAC Permissions
  4. Perform Feast Apply
  5. Setting Service Account and Role Binding

Install the Feast Operator

python
## Use this install command from a stable branch  
!kubectl apply -f ../../infra/feast-operator/dist/install.yaml

## OR, for the latest code/builds, use one the following commands from the 'master' branch
# !make -C ../../infra/feast-operator install deploy IMG=quay.io/feastdev-ci/feast-operator:develop FS_IMG=quay.io/feastdev-ci/feature-server:develop
# !make -C ../../infra/feast-operator install deploy IMG=quay.io/feastdev-ci/feast-operator:$(git rev-parse HEAD) FS_IMG=quay.io/feastdev-ci/feature-server:$(git rev-parse HEAD)

!kubectl wait --for=condition=available --timeout=5m deployment/feast-operator-controller-manager -n feast-operator-system

Install the Feast services via FeatureStore CR

Next, we'll use the running Feast Operator to install the feast services with Server components online, offline, registry with kubernetes Authorization set. Apply the included reference deployment to install and configure Feast with kubernetes Authorization .

python
!cat ../../infra/feast-operator/config/samples/v1_featurestore_kubernetes_auth.yaml
!kubectl apply -f ../../infra/feast-operator/config/samples/v1_featurestore_kubernetes_auth.yaml -n feast

Validate the running FeatureStore deployment

Validate the deployment status.

python
!kubectl get all
!kubectl wait --for=condition=available --timeout=8m deployment/feast-sample-kubernetes-auth

Validate that the FeatureStore CR is in a Ready state.

python
!kubectl get feast

Configure the RBAC Permissions

As we have created Kubernetes roles in FeatureStore CR to manage access control for Feast objects, the Python script permissions_apply.py will apply these roles to configure permissions. See the detailed code example below with comments.

python
#view the permissions  
!cat  permissions_apply.py
python
# Copy the Permissions to the pods under feature_repo directory
!kubectl cp permissions_apply.py $(kubectl get pods -l 'feast.dev/name=sample-kubernetes-auth' -ojsonpath="{.items[*].metadata.name}"):/feast-data/feast_rbac/feature_repo -c online
python
#view the feature_store.yaml configuration 
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- cat feature_store.yaml

Apply the Permissions and Feast Object to Registry

python
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- feast apply

List the applied permission details permissions on Feast Resources.

python
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- feast permissions list-roles
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- feast permissions list
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- feast permissions describe feast_admin_permission
!kubectl exec deploy/feast-sample-kubernetes-auth -itc online -- feast permissions describe feast_user_permission

Setting Up Service Account and RoleBinding

The steps below will:

  • Create three different ServiceAccounts for Feast.
  • Assign appropriate RoleBindings for access control.

Test Cases

User TypeServiceAccountRoleBinding AssignedExpected Behavior in output
Read-Onlyfeast-user-safeast-readerCan read from the feature store, but cannot write.
Unauthorizedfeast-unauthorized-user-saNoneAccess should be denied in test.py.
Adminfeast-admin-safeast-writerCan read and write feature store data.

Set Up a Read-Only Feast User

(ServiceAccount: feast-user-sa, Role: feast-reader)

python
# Step 1: Create the ServiceAccount
!echo "Creating ServiceAccount: feast-user-sa"
!kubectl create serviceaccount feast-user-sa -n feast

# Step 2: Assign RoleBinding (Read-Only Access for Feast)
!echo "Assigning Read-Only RoleBinding: feast-user-rolebinding"
!kubectl create rolebinding feast-user-rolebinding --role=feast-reader --serviceaccount=feast:feast-user-sa -n feast

Set Up an Unauthorized Feast User

(ServiceAccount: feast-unauthorized-user-sa, Role: None)

python
# Create the ServiceAccount (Without RoleBinding)
!echo "Creating Unauthorized ServiceAccount: feast-unauthorized-user-sa"
!kubectl create serviceaccount feast-unauthorized-user-sa -n feast

Set Up a Test Admin Feast User

(ServiceAccount: feast-admin-sa, Role: feast-writer)

python
# Create the ServiceAccount
!echo "Creating ServiceAccount: feast-admin-sa"
!kubectl create serviceaccount feast-admin-sa -n feast

# Assign RoleBinding (Admin Access for Feast)
!echo "Assigning Admin RoleBinding: feast-admin-rolebinding"
!kubectl create rolebinding feast-admin-rolebinding --role=feast-writer --serviceaccount=feast:feast-admin-sa -n feast

Next: Client example from Pod