Skip to content

Commit

Permalink
fix(tas): Remove generic deployment watcher (#400)
Browse files Browse the repository at this point in the history
* fix(tas): Remove generic deployment watcher

* Remove ServingRuntime dependency
  • Loading branch information
ruivieira authored Feb 10, 2025
1 parent 6ec0cdf commit 2b77e19
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1,994 deletions.
112 changes: 55 additions & 57 deletions .github/workflows/smoke.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
name: Smoke test

on:
pull_request:
branches:
- main
pull_request:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push operator container image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: true
tags: smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
node_image: kindest/node:v1.24.17
cluster_name: kind

- name: Load the operator image into Kind
run: |
kind load docker-image smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
- name: Install kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- name: Apply CRDs
run: |
kubectl apply -f tests/crds/monitoring.coreos.com_servicemonitors.yaml
kubectl apply -f tests/crds/route_crd.yaml
kubectl apply -f tests/crds/serving.kserve.io_inferenceservices.yaml
kubectl apply -f tests/crds/serving.kserve.io_servingruntimes.yaml
kustomize build config/crd | kubectl apply -f -
- name: Update params.env file
run: |
sed -i 's|trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest|trustyaiOperatorImage=smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}|' config/base/params.env
- name: Deploy the operator with kustomize
run: |
kubectl create namespace system
kustomize build config/base | kubectl apply -n system -f -
- name: Run smoke tests
run: ./tests/smoke/test_smoke.sh

deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push operator container image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: true
tags: smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}

- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
with:
node_image: kindest/node:v1.24.17
cluster_name: kind

- name: Load the operator image into Kind
run: |
kind load docker-image smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}
- name: Install kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
- name: Apply CRDs
run: |
kubectl apply -f tests/crds/monitoring.coreos.com_servicemonitors.yaml
kubectl apply -f tests/crds/route_crd.yaml
kubectl apply -f tests/crds/serving.kserve.io_inferenceservices.yaml
kustomize build config/crd | kubectl apply -f -
- name: Update params.env file
run: |
sed -i 's|trustyaiOperatorImage=quay.io/trustyai/trustyai-service-operator:latest|trustyaiOperatorImage=smoke/operator:pr-${{ github.event.pull_request.number || env.PR_NUMBER }}|' config/base/params.env
- name: Deploy the operator with kustomize
run: |
kubectl create namespace system
kustomize build config/base | kubectl apply -n system -f -
- name: Run smoke tests
run: ./tests/smoke/test_smoke.sh

env:
PR_NUMBER: "default-pr-number"
KUBECONFIG: "${HOME}/.kube/config"
PR_NUMBER: "default-pr-number"
KUBECONFIG: "${HOME}/.kube/config"
20 changes: 0 additions & 20 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,6 @@ rules:
- patch
- update
- watch
- apiGroups:
- serving.kserve.io
resources:
- servingruntimes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- serving.kserve.io
resources:
- servingruntimes/status
verbs:
- get
- patch
- update
- apiGroups:
- trustyai.opendatahub.io
resources:
Expand Down
22 changes: 0 additions & 22 deletions controllers/tas/trustyaiservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ import (
goerrors "errors"
"time"

kservev1alpha1 "github.com/kserve/kserve/pkg/apis/serving/v1alpha1"
kservev1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"
trustyaiopendatahubiov1alpha1 "github.com/trustyai-explainability/trustyai-service-operator/api/tas/v1alpha1"
"github.com/trustyai-explainability/trustyai-service-operator/controllers/utils"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -69,8 +67,6 @@ type TrustyAIServiceReconciler struct {
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=persistentvolumes,verbs=list;get;watch
//+kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=list;get;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=serving.kserve.io,resources=servingruntimes,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=serving.kserve.io,resources=servingruntimes/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=list;watch;get;create;update;patch;delete
//+kubebuilder:rbac:groups=serving.kserve.io,resources=inferenceservices,verbs=list;watch;get;update;patch
//+kubebuilder:rbac:groups=serving.kserve.io,resources=inferenceservices/finalizers,verbs=list;watch;get;update;patch;delete
Expand Down Expand Up @@ -281,27 +277,9 @@ func (r *TrustyAIServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ

// SetupWithManager sets up the controller with the Manager.
func (r *TrustyAIServiceReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Watch ServingRuntime objects (not managed by this controller)
if err := mgr.GetFieldIndexer().IndexField(context.Background(), &appsv1.Deployment{}, ".metadata.controller", func(rawObj client.Object) []string {
// Grab the deployment object and extract the owner
deployment := rawObj.(*appsv1.Deployment)
owner := metav1.GetControllerOf(deployment)
if owner == nil {
return nil
}
// Retain ServingRuntimes only
if owner.APIVersion != kservev1beta1.APIVersion || owner.Kind != "ServingRuntime" {
return nil
}
return []string{owner.Name}
}); err != nil {
return err
}

return ctrl.NewControllerManagedBy(mgr).
For(&trustyaiopendatahubiov1alpha1.TrustyAIService{}).
Owns(&appsv1.Deployment{}).
Watches(&kservev1beta1.InferenceService{}, &handler.EnqueueRequestForObject{}).
Watches(&kservev1alpha1.ServingRuntime{}, &handler.EnqueueRequestForObject{}).
Complete(r)
}
Loading

0 comments on commit 2b77e19

Please sign in to comment.