From b812dd3d136a5105661948b577e8cfac86c9d94c Mon Sep 17 00:00:00 2001 From: Ann Taraday Date: Tue, 24 Oct 2023 15:59:16 +0200 Subject: [PATCH 1/3] Fix groupversion for multicasskop Also updated setup namespace for casskop(drop depricated usage of namespace) Fixes: #123 --- main.go | 4 ++-- multi-casskop/api/v2/groupversion_info.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 2ca80354..1e6b0493 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( "os" "path" "runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "strconv" "strings" "time" @@ -162,8 +163,7 @@ func main() { mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, - Port: 9443, - Namespace: namespace, + Cache: cache.Options{Namespaces: []string{namespace}}, HealthProbeBindAddress: probeAddr, }) if err != nil { diff --git a/multi-casskop/api/v2/groupversion_info.go b/multi-casskop/api/v2/groupversion_info.go index a7d43d00..b337ba6d 100644 --- a/multi-casskop/api/v2/groupversion_info.go +++ b/multi-casskop/api/v2/groupversion_info.go @@ -16,7 +16,7 @@ limitations under the License. // Package v2 contains API Schema definitions for the multicasskops.db.orange.com v2 API group // +kubebuilder:object:generate=true -// +groupName=multicasskops.db.orange.com +// +groupName=db.orange.com package v2 import ( @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "multicasskops.db.orange.com", Version: "v2"} + GroupVersion = schema.GroupVersion{Group: "db.orange.com", Version: "v2"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} From 5a5602da3dc4c7b618ba150dac0135c24ea618ed Mon Sep 17 00:00:00 2001 From: Ann Taraday Date: Thu, 26 Oct 2023 09:39:11 +0200 Subject: [PATCH 2/3] Drop readiness/liveness probes for multi-casskop Probes readz/healthz are not enabled for admiralty.io/multicluster-controller. --- charts/multi-casskop/templates/deployment.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/charts/multi-casskop/templates/deployment.yaml b/charts/multi-casskop/templates/deployment.yaml index 2ae59cfc..eb46a387 100644 --- a/charts/multi-casskop/templates/deployment.yaml +++ b/charts/multi-casskop/templates/deployment.yaml @@ -50,20 +50,6 @@ spec: {{- range .Values.k8s.remote }} - -r{{ . }} {{- end }} - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 4 - periodSeconds: 10 - failureThreshold: 1 - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 4 - periodSeconds: 10 - failureThreshold: 1 resources: {{ toYaml .Values.resources | indent 10 }} env: From 61521b5f94cd42b9515b2ecd7431b92bc2b56f81 Mon Sep 17 00:00:00 2001 From: Ann Taraday Date: Fri, 27 Oct 2023 12:42:27 +0200 Subject: [PATCH 3/3] Add dummy health checks for multi-casskop operator --- .../multi-casskop/templates/deployment.yaml | 14 +++++++++ multi-casskop/go.mod | 12 +++---- multi-casskop/go.sum | 7 ++++- multi-casskop/main.go | 31 ++++++++++++------- 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/charts/multi-casskop/templates/deployment.yaml b/charts/multi-casskop/templates/deployment.yaml index eb46a387..2ae59cfc 100644 --- a/charts/multi-casskop/templates/deployment.yaml +++ b/charts/multi-casskop/templates/deployment.yaml @@ -50,6 +50,20 @@ spec: {{- range .Values.k8s.remote }} - -r{{ . }} {{- end }} + readinessProbe: + httpGet: + path: /readyz + port: 8081 + initialDelaySeconds: 4 + periodSeconds: 10 + failureThreshold: 1 + livenessProbe: + httpGet: + path: /healthz + port: 8081 + initialDelaySeconds: 4 + periodSeconds: 10 + failureThreshold: 1 resources: {{ toYaml .Values.resources | indent 10 }} env: diff --git a/multi-casskop/go.mod b/multi-casskop/go.mod index 1c3381a5..afc5ba4a 100644 --- a/multi-casskop/go.mod +++ b/multi-casskop/go.mod @@ -16,13 +16,6 @@ require ( sigs.k8s.io/controller-runtime v0.15.0 ) -require ( - github.com/onsi/ginkgo v1.16.5 // indirect - github.com/onsi/gomega v1.19.0 // indirect -) - -replace github.com/cscetbon/casskop => ../ - require ( cloud.google.com/go v0.97.0 // indirect github.com/antihax/optional v1.0.0 // indirect @@ -36,11 +29,15 @@ require ( github.com/googleapis/gnostic v0.5.5 // indirect github.com/instaclustr/instaclustr-icarus-go-client v0.0.0-20210427160512-5264f1cbba08 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/onsi/ginkgo v1.16.5 // indirect + github.com/onsi/gomega v1.19.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect @@ -63,6 +60,7 @@ require ( replace ( github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible // Required by OLM + github.com/cscetbon/casskop => ../ github.com/go-logr/logr => github.com/go-logr/logr v0.4.0 github.com/go-logr/zapr => github.com/go-logr/zapr v1.2.4 github.com/operator-framework/operator-sdk => github.com/operator-framework/operator-sdk v1.13.0 diff --git a/multi-casskop/go.sum b/multi-casskop/go.sum index 896b6326..1fba24e3 100644 --- a/multi-casskop/go.sum +++ b/multi-casskop/go.sum @@ -520,8 +520,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= @@ -621,6 +622,7 @@ github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7ir github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c/go.mod h1:HUpKUBZnpzkdx0kD/+Yfuft+uD3zHGtXF/XJB14TUr4= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -669,6 +671,9 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.0.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= diff --git a/multi-casskop/main.go b/multi-casskop/main.go index 5dd41341..bfb9f32a 100644 --- a/multi-casskop/main.go +++ b/multi-casskop/main.go @@ -18,26 +18,22 @@ package main import ( "fmt" - "runtime" - - "github.com/cscetbon/casskop/multi-casskop/controllers" - apimachineryruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/sample-controller/pkg/signals" - - // "flag" "log" + "net/http" "os" + "runtime" "strings" - "github.com/jessevdk/go-flags" - - "k8s.io/client-go/rest" - "admiralty.io/multicluster-controller/pkg/cluster" "admiralty.io/multicluster-controller/pkg/manager" "admiralty.io/multicluster-service-account/pkg/config" + "github.com/cscetbon/casskop/multi-casskop/controllers" + "github.com/jessevdk/go-flags" "github.com/sirupsen/logrus" + apimachineryruntime "k8s.io/apimachinery/pkg/runtime" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + "k8s.io/client-go/rest" + "k8s.io/sample-controller/pkg/signals" kconfig "sigs.k8s.io/controller-runtime/pkg/client/config" ) @@ -162,6 +158,19 @@ func main() { m := manager.New() m.AddController(co) + // TODO: create more meaningful checks + http.HandleFunc("/readyz", func(writer http.ResponseWriter, request *http.Request) { + writer.WriteHeader(http.StatusOK) + }) + http.HandleFunc("/healthz", func(writer http.ResponseWriter, request *http.Request) { + writer.WriteHeader(http.StatusOK) + }) + go func() { + err := http.ListenAndServe(":8081", nil) + if err != nil { + log.Fatalf("failed to run readyness/liveness checks") + } + }() logrus.Info("Starting Manager.") if err := m.Start(signals.SetupSignalHandler()); err != nil {