Skip to content

Commit

Permalink
add readme and remove not used env
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Mar 29, 2024
1 parent d538529 commit f0917bd
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 17 deletions.
19 changes: 19 additions & 0 deletions components/operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Function Operator

The Function Operator is a Kubernetes controller that install Serverless.

## Prerequisites
The Function Operator requires the following components to be installed:
- [Go](https://go.dev/)

## Development

### Run/Debug local sources locally

### Environment Variables

#### The Function Operator Uses These Environment Variables:

| Variable | Description | Default value |
|----------------------------------|------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **CHART_PATH** | Location of serverless chart | `/module-chart` |
4 changes: 2 additions & 2 deletions components/operator/controllers/serverless_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ type serverlessReconciler struct {
log *zap.SugaredLogger
}

func NewServerlessReconciler(client client.Client, config *rest.Config, recorder record.EventRecorder, log *zap.SugaredLogger, chartPath string, ns string) *serverlessReconciler {
func NewServerlessReconciler(client client.Client, config *rest.Config, recorder record.EventRecorder, log *zap.SugaredLogger, chartPath string) *serverlessReconciler {
cache := chart.NewSecretManifestCache(client)

return &serverlessReconciler{
initStateMachine: func(log *zap.SugaredLogger) state.StateReconciler {
return state.NewMachine(client, config, recorder, log, cache, chartPath, ns)
return state.NewMachine(client, config, recorder, log, cache, chartPath)
},
client: client,
log: log,
Expand Down
5 changes: 2 additions & 3 deletions components/operator/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ var _ = BeforeSuite(func() {
k8sManager.GetConfig(),
record.NewFakeRecorder(100),
reconcilerLogger.Sugar(),
chartPath,
"",
)).SetupWithManager(k8sManager)
chartPath)).
SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

go func() {
Expand Down
3 changes: 1 addition & 2 deletions components/operator/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package config
import "github.com/vrischmann/envconfig"

type Config struct {
ChartPath string `envconfig:"default=/module-chart"`
ServerlessManagerNamespace string `envconfig:"default=default"`
ChartPath string `envconfig:"default=/module-chart"`
}

func GetConfig(prefix string) (Config, error) {
Expand Down
1 change: 0 additions & 1 deletion components/operator/internal/state/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type stateFn func(context.Context, *reconciler, *systemState) (stateFn, *ctrl.Re
type cfg struct {
finalizer string
chartPath string
namespace string
managerPodUID string
}

Expand Down
3 changes: 1 addition & 2 deletions components/operator/internal/state/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ type StateReconciler interface {
Reconcile(ctx context.Context, v v1alpha1.Serverless) (ctrl.Result, error)
}

func NewMachine(client client.Client, config *rest.Config, recorder record.EventRecorder, log *zap.SugaredLogger, cache chart.ManifestCache, chartPath, namespace string) StateReconciler {
func NewMachine(client client.Client, config *rest.Config, recorder record.EventRecorder, log *zap.SugaredLogger, cache chart.ManifestCache, chartPath string) StateReconciler {
return &reconciler{
fn: sFnServedFilter,
cache: cache,
log: log,
cfg: cfg{
finalizer: v1alpha1.Finalizer,
chartPath: chartPath,
namespace: namespace,
managerPodUID: os.Getenv("SERVERLESS_MANAGER_UID"),
},
k8s: k8s{
Expand Down
5 changes: 2 additions & 3 deletions components/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), cleanupTimeout)
defer cancel()

setupLog.Info("cleaning orphan depricated resources")
setupLog.Info("cleaning orphan deprecated resources")
err = cleanupOrphanDeprecatedResources(ctx)
if err != nil {
setupLog.Error(err, "while removing orphan resources")
Expand Down Expand Up @@ -131,8 +131,7 @@ func main() {
mgr.GetClient(), mgr.GetConfig(),
mgr.GetEventRecorderFor("serverless-operator"),
reconcilerLogger.Sugar(),
cfg.ChartPath,
cfg.ServerlessManagerNamespace)
cfg.ChartPath)

if err = reconciler.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Serverless")
Expand Down
4 changes: 0 additions & 4 deletions config/operator/base/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ spec:
image: controller:latest
name: manager
env:
- name: SERVERLESS_MANAGER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SERVERLESS_MANAGER_UID
valueFrom:
fieldRef:
Expand Down

0 comments on commit f0917bd

Please sign in to comment.