Skip to content

Commit

Permalink
manifest readiness update for odh-operator v2
Browse files Browse the repository at this point in the history
Signed-off-by: Vedant Mahabaleshwarkar <vmahabal@redhat.com>
  • Loading branch information
VedantMahabaleshwarkar committed Sep 29, 2023
1 parent e24d77a commit eabc672
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 39 deletions.
26 changes: 25 additions & 1 deletion config/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../default
- ../prometheus
- ../overlays/odh

namespace: opendatahub
configMapGenerator:
- envs:
- params.env
name: odh-model-controller-parameters
generatorOptions:
disableNameSuffixHash: true

vars:
- fieldref:
fieldPath: metadata.namespace
name: mesh-namespace
objref:
apiVersion: v1
kind: ConfigMap
name: odh-model-controller-parameters
- fieldref:
fieldPath: data.odh-model-controller
name: odh-model-controller
objref:
apiVersion: v1
kind: ConfigMap
name: odh-model-controller-parameters
1 change: 1 addition & 0 deletions config/base/params.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
odh-model-controller=quay.io/opendatahub/odh-model-controller:fast
5 changes: 0 additions & 5 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
bases:
- ../rbac
- ../manager
- ../crd/external

# Adds namespace to all resources.
namespace: odh-model-controller-system

6 changes: 0 additions & 6 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
resources:
- manager.yaml
- namespace.yaml

generatorOptions:
disableNameSuffixHash: true
Expand All @@ -9,8 +8,3 @@ configMapGenerator:
- files:
- controller_manager_config.yaml
name: manager-config

images:
- name: controller
newName: quay.io/opendatahub/odh-model-controller
newTag: stable
3 changes: 3 additions & 0 deletions config/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- ../../crd/external
- ../../manager/namespace.yaml
10 changes: 10 additions & 0 deletions config/overlays/odh/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../default

patchesStrategicMerge:
- odh_model_controller_manager_patch.yaml

configurations:
- params.yaml
18 changes: 18 additions & 0 deletions config/overlays/odh/odh_model_controller_manager_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: odh-model-controller
spec:
replicas: 3
template:
spec:
containers:
- args:
- --leader-elect
- "--monitoring-namespace"
- "$(MONITORING_NS)"
image: $(odh-model-controller)
env:
- name: MONITORING_NS
value: kserve
name: manager
7 changes: 7 additions & 0 deletions config/overlays/odh/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
varReference:
- path: metadata/name
kind: ClusterRoleBinding
apiGroup: authorization.openshift.io
- path: spec/template/spec/containers[]/image
kind: Deployment
apiVersion: apps/v1
2 changes: 2 additions & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ resources:
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml
- kserve_prometheus_clusterrole.yaml

1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ rules:
- networking.k8s.io
resources:
- networkpolicies
- ingresses
verbs:
- create
- delete
Expand Down
47 changes: 20 additions & 27 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,13 @@ func main() {
var enableLeaderElection bool
var monitoringNS string
var probeAddr string
var kserveEnabled bool
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&monitoringNS, "monitoring-namespace", "",
"The Namespace where the monitoring stack's Prometheus resides.")
flag.BoolVar(&kserveEnabled, "kserve-enabled", true,
"Enable Kserve Metrics. "+
"Enabling will disable modelmesh controllers and only create kserve monitoring controller.")

opts := zap.Options{
Development: true,
Expand Down Expand Up @@ -147,32 +143,29 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "InferenceService")
os.Exit(1)
}
if !kserveEnabled {
setupLog.Info("ModelMesh deployment mode, skipping setup of kserve controllers.")
if err = (&controllers.StorageSecretReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("StorageSecret"),
Scheme: mgr.GetScheme(),
if err = (&controllers.StorageSecretReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("StorageSecret"),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "StorageSecret")
os.Exit(1)
}

if monitoringNS != "" {
setupLog.Info("Monitoring namespace provided, setting up monitoring controller.")
if err = (&controllers.MonitoringReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("MonitoringReconciler"),
Scheme: mgr.GetScheme(),
MonitoringNS: monitoringNS,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "StorageSecret")
setupLog.Error(err, "unable to create controller", "controller", "MonitoringReconciler")
os.Exit(1)
}

if monitoringNS != "" {
setupLog.Info("Monitoring namespace provided, setting up monitoring controller.")
if err = (&controllers.MonitoringReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("MonitoringReconciler"),
Scheme: mgr.GetScheme(),
MonitoringNS: monitoringNS,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "MonitoringReconciler")
os.Exit(1)
}
} else {
setupLog.Info("Monitoring namespace not provided, skipping setup of monitoring controller. To enable " +
"monitoring for ModelServing, please provide a monitoring namespace via the (--monitoring-namespace) flag.")
}
} else {
setupLog.Info("Monitoring namespace not provided, skipping setup of monitoring controller. To enable " +
"monitoring for ModelServing, please provide a monitoring namespace via the (--monitoring-namespace) flag.")
}

//+kubebuilder:scaffold:builder
Expand Down

0 comments on commit eabc672

Please sign in to comment.