From 771312ddfb3d1d969625042921d5e4d50c707814 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 8 Nov 2020 16:23:17 -0800 Subject: [PATCH] add steps to develop inside k8s --- Makefile | 2 +- README.md | 9 ++++++--- controllers/seaweed_maintenance.go | 4 +--- controllers/swadmin/seaweed_admin.go | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 521570b..43a1eaa 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ endif BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # Image URL to use all building/pushing image targets -IMG ?= seaweedfs/operator:latest +IMG ?= seaweedfs/operator:$(VERSION) # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) CRD_OPTIONS ?= "crd:trivialVersions=true" diff --git a/README.md b/README.md index 242b9b7..5ad73e6 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,13 @@ $ git clone https://github.com/seaweedfs/seaweedfs-operator $ cd seaweedfs-operator # register the CRD with the Kubernetes -$ make install +$ make deploy -# run the operator locally outside the Kubernetes cluster -$ make run ENABLE_WEBHOOKS=false +# build the operator image +$ make docker-build + +# load the image into Kind cluster +$ kind load docker-image seaweedfs/operator:v0.0.1 # From another terminal in the same directory $ kubectl apply -f config/samples/seaweed_v1_seaweed.yaml diff --git a/controllers/seaweed_maintenance.go b/controllers/seaweed_maintenance.go index 8cecbd4..445a736 100644 --- a/controllers/seaweed_maintenance.go +++ b/controllers/seaweed_maintenance.go @@ -11,12 +11,10 @@ import ( func (r *SeaweedReconciler) maintenance(m *seaweedv1.Seaweed) (done bool, result ctrl.Result, err error) { - masters := getMasterPeersString(m.Name, m.Spec.Master.Replicas) + masters := getMasterPeersString(m) r.Log.V(0).Info("wait to connect to masters", "masters", masters) - return ReconcileResult(nil) - // this step blocks since the operator can not access the masters when running from outside of the k8s cluster sa := swadmin.NewSeaweedAdmin(masters, ioutil.Discard) diff --git a/controllers/swadmin/seaweed_admin.go b/controllers/swadmin/seaweed_admin.go index 8fe26d5..bf45831 100644 --- a/controllers/swadmin/seaweed_admin.go +++ b/controllers/swadmin/seaweed_admin.go @@ -25,7 +25,6 @@ func NewSeaweedAdmin(masters string, output io.Writer) *SeaweedAdmin { reg, _ := regexp.Compile(`'.*?'|".*?"|\S+`) go commandEnv.MasterClient.KeepConnectedToMaster() - commandEnv.MasterClient.WaitUntilConnected() return &SeaweedAdmin{ commandEnv: commandEnv, @@ -45,6 +44,7 @@ func (sa *SeaweedAdmin) ProcessCommands(cmds string) error { } func (sa *SeaweedAdmin) ProcessCommand(cmd string) error { + sa.commandEnv.MasterClient.WaitUntilConnected() cmds := sa.commandReg.FindAllString(cmd, -1) if len(cmds) == 0 { return nil