Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Update operator version to reflect kubeflow version #285

Merged
merged 7 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,28 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client/config"
logf "sigs.k8s.io/controller-runtime/pkg/log"
log "github.com/sirupsen/logrus"
adrian555 marked this conversation as resolved.
Show resolved Hide resolved
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

// Kubeflow operator version
var (
Version string = "1.0.0"
)

// Change below variables to serve metrics on different host or port.
var (
metricsHost = "0.0.0.0"
metricsPort int32 = 8383
operatorMetricsPort int32 = 8686
)
var log = logf.Log.WithName("cmd")

func printVersion() {
log.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
log.Info(fmt.Sprintf("Version of operator-sdk: %v", sdkVersion.Version))
log.Infof("Go Version: %s", runtime.Version())
log.Infof("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH)
log.Infof("Version of operator-sdk: %v", sdkVersion.Version)
log.Infof("Kubeflow version: %v", Version)
}

func main() {
Expand All @@ -55,36 +60,26 @@ func main() {

pflag.Parse()

// Use a zap logr.Logger implementation. If none of the zap
// flags are configured (or if the zap flag set is not being
// used), this defaults to a production zap logger.
//
// The logger instantiated here can be changed to any logger
// implementing the logr.Logger interface. This logger will
// be propagated through the whole operator, generating
// uniform and structured logs.
logf.SetLogger(zap.Logger())

printVersion()

namespace, err := k8sutil.GetWatchNamespace()
if err != nil {
log.Error(err, "Failed to get watch namespace")
log.Errorf("Failed to get watch namespace. Error %v.", err)
os.Exit(1)
}

// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
log.Error(err, "")
log.Errorf("Error: %v.", err)
os.Exit(1)
}

ctx := context.TODO()
// Become the leader before proceeding
err = leader.Become(ctx, "kfctl-lock")
if err != nil {
log.Error(err, "")
log.Errorf("Error: %v.", err)
os.Exit(1)
}

Expand All @@ -96,26 +91,26 @@ func main() {
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
})
if err != nil {
log.Error(err, "")
log.Errorf("Error: %v.", err)
os.Exit(1)
}

log.Info("Registering Components.")

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "")
log.Errorf("Error: %v.", err)
os.Exit(1)
}

// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
log.Error(err, "")
log.Errorf("Error: %v.", err)
os.Exit(1)
}

if err = serveCRMetrics(cfg); err != nil {
log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
log.Errorf("Could not generate and serve custom resource metrics. Error: %v.", err.Error())
}

// Add to the below struct any other metrics ports you want to expose.
Expand All @@ -126,27 +121,27 @@ func main() {
// Create Service object to expose the metrics port(s).
service, err := metrics.CreateMetricsService(ctx, cfg, servicePorts)
if err != nil {
log.Info("Could not create metrics Service", "error", err.Error())
log.Errorf("Could not create metrics Service. Error: %v.", err.Error())
}

// CreateServiceMonitors will automatically create the prometheus-operator ServiceMonitor resources
// necessary to configure Prometheus to scrape metrics from this operator.
services := []*v1.Service{service}
_, err = metrics.CreateServiceMonitors(cfg, namespace, services)
if err != nil {
log.Info("Could not create ServiceMonitor object", "error", err.Error())
log.Errorf("Could not create ServiceMonitor object. Error: %v.", err.Error())
// If this operator is deployed to a cluster without the prometheus-operator running, it will return
// ErrServiceMonitorNotPresent, which can be used to safely skip ServiceMonitor creation.
if err == metrics.ErrServiceMonitorNotPresent {
log.Info("Install prometheus-operator in your cluster to create ServiceMonitor objects", "error", err.Error())
log.Errorf("Install prometheus-operator in your cluster to create ServiceMonitor objects. Error: %v.", err.Error())
}
}

log.Info("Starting the Cmd.")
log.Infof("Starting the Cmd.")

// Start the Cmd
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {
log.Error(err, "Manager exited non-zero")
log.Errorf("Manager exited non-zero. Error: %v.", err)
os.Exit(1)
}
}
Expand Down

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions deploy/olm-catalog/kubeflow/1.0.0/kfdef.apps.kubeflow.org.crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: kfdefs.kfdef.apps.kubeflow.org
labels:
component: kubeflow-operator
spec:
group: kfdef.apps.kubeflow.org
names:
kind: KfDef
listKind: KfDefList
plural: kfdefs
singular: kfdef
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: KfDef is the Schema for the kfdefs API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: KfDefSpec defines the desired state of KfDef
type: object
status:
description: KfDefStatus defines the observed state of KfDef
type: object
type: object
version: v1
versions:
- name: v1
served: true
storage: true

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/olm-catalog/kubeflow/kubeflow.package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
channels:
- currentCSV: kubeflow.v0.1.0
- currentCSV: kubeflow.v1.0.0
name: alpha
defaultChannel: alpha
packageName: kubeflow
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
containers:
- name: kubeflow-operator
# Replace this with the built image name
image: aipipeline/kubeflow-operator:v0.1.0
image: aipipeline/kubeflow-operator:v1.0.0
command:
- kfctl
imagePullPolicy: Always
Expand Down