diff --git a/Makefile b/Makefile index f401c475d..8d982f415 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ run: crd .PHONY: run-openshift run-openshift: crd - @bash -c 'trap "exit 0" INT; OPERATOR_NAME=${OPERATOR_NAME} KUBERNETES_CONFIG=${KUBERNETES_CONFIG} WATCH_NAMESPACE=${WATCH_NAMESPACE} go run -ldflags ${LD_FLAGS} main.go start --openshift=true' + @bash -c 'trap "exit 0" INT; OPERATOR_NAME=${OPERATOR_NAME} KUBERNETES_CONFIG=${KUBERNETES_CONFIG} WATCH_NAMESPACE=${WATCH_NAMESPACE} go run -ldflags ${LD_FLAGS} main.go start --platform=openshift' .PHONY: es es: diff --git a/README.adoc b/README.adoc index e373fd567..2efe22c24 100644 --- a/README.adoc +++ b/README.adoc @@ -149,7 +149,7 @@ NAME HOSTS ADDRESS PORTS AGE simplest-query * 192.168.122.34 80 3m ---- -IMPORTANT: an `Ingress` object is *not* created when the operator is started with the `--openshift=true` flag as, such as when using the resource `operator-openshift.yaml`. +IMPORTANT: an `Ingress` object is *not* created when the operator is started with the `--platform=openshift` flag, such as when using the resource `operator-openshift.yaml`. In this example, the Jaeger UI is available at http://192.168.122.34 diff --git a/deploy/operator-openshift.yaml b/deploy/operator-openshift.yaml index 7060b6ac8..fcb86572c 100644 --- a/deploy/operator-openshift.yaml +++ b/deploy/operator-openshift.yaml @@ -18,7 +18,7 @@ spec: ports: - containerPort: 60000 name: metrics - args: ["start", "--openshift=true"] + args: ["start", "--platform=openshift"] imagePullPolicy: Always env: - name: WATCH_NAMESPACE diff --git a/pkg/apis/io/v1alpha1/types.go b/pkg/apis/io/v1alpha1/types.go index f9921075e..62af0ed26 100644 --- a/pkg/apis/io/v1alpha1/types.go +++ b/pkg/apis/io/v1alpha1/types.go @@ -6,6 +6,14 @@ import ( // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +const ( + // FlagPlatformOpenShift represents the value for the 'platform' flag for OpenShift + FlagPlatformOpenShift = "openshift" + + // FlagPlatformKubernetes represents the value for the 'platform' flag for Kubernetes + FlagPlatformKubernetes = "kubernetes" +) + // JaegerList is a list of Jaeger structs type JaegerList struct { metav1.TypeMeta `json:",inline"` @@ -32,7 +40,6 @@ type JaegerSpec struct { Agent JaegerAgentSpec `json:"agent"` Storage JaegerStorageSpec `json:"storage"` Ingress JaegerIngressSpec `json:"ingress"` - Route JaegerRouteSpec `json:"route"` } // JaegerStatus defines what is to be returned from a status query @@ -53,11 +60,6 @@ type JaegerIngressSpec struct { Enabled *bool `json:"enabled"` } -// JaegerRouteSpec defines the options to be used when deploying the query route (OpenShift-specific) -type JaegerRouteSpec struct { - Enabled *bool `json:"enabled"` -} - // JaegerAllInOneSpec defines the options to be used when deploying the query type JaegerAllInOneSpec struct { Image string `json:"image"` diff --git a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go index 4333b4fc6..6384c3808 100644 --- a/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/io/v1alpha1/zz_generated.deepcopy.go @@ -207,27 +207,6 @@ func (in *JaegerQuerySpec) DeepCopy() *JaegerQuerySpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JaegerRouteSpec) DeepCopyInto(out *JaegerRouteSpec) { - *out = *in - if in.Enabled != nil { - in, out := &in.Enabled, &out.Enabled - *out = new(bool) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JaegerRouteSpec. -func (in *JaegerRouteSpec) DeepCopy() *JaegerRouteSpec { - if in == nil { - return nil - } - out := new(JaegerRouteSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { *out = *in @@ -237,7 +216,6 @@ func (in *JaegerSpec) DeepCopyInto(out *JaegerSpec) { in.Agent.DeepCopyInto(&out.Agent) in.Storage.DeepCopyInto(&out.Storage) in.Ingress.DeepCopyInto(&out.Ingress) - in.Route.DeepCopyInto(&out.Route) return } diff --git a/pkg/cmd/start/main.go b/pkg/cmd/start/main.go index 3941f6704..a69a43ce2 100644 --- a/pkg/cmd/start/main.go +++ b/pkg/cmd/start/main.go @@ -48,8 +48,8 @@ func NewStartCommand() *cobra.Command { cmd.Flags().String("jaeger-cassandra-schema-image", "jaegertracing/jaeger-cassandra-schema", "The Docker image for the Jaeger Cassandra Schema") viper.BindPFlag("jaeger-cassandra-schema-image", cmd.Flags().Lookup("jaeger-cassandra-schema-image")) - cmd.Flags().Bool("openshift", false, "Whether the operator should use OpenShift-specific features, like Routes and OAuth proxy for the UIs") - viper.BindPFlag("openshift", cmd.Flags().Lookup("openshift")) + cmd.Flags().String("platform", "kubernetes", "The target platform the operator will run. Possible values: 'kubernetes' and 'openshift'") + viper.BindPFlag("platform", cmd.Flags().Lookup("platform")) return cmd } diff --git a/pkg/controller/all-in-one.go b/pkg/controller/all-in-one.go index 648804b24..d4c73ac9d 100644 --- a/pkg/controller/all-in-one.go +++ b/pkg/controller/all-in-one.go @@ -42,7 +42,7 @@ func (c *allInOneController) Create() []sdk.Object { os = append(os, svc) } - if viper.GetBool("openshift") { + if viper.GetString("platform") == v1alpha1.FlagPlatformOpenShift { qr := route.NewQueryRoute(c.jaeger).Get() if nil != qr { os = append(os, qr) diff --git a/pkg/controller/all-in-one_test.go b/pkg/controller/all-in-one_test.go index 9578512ab..d0cf6975c 100644 --- a/pkg/controller/all-in-one_test.go +++ b/pkg/controller/all-in-one_test.go @@ -26,7 +26,7 @@ func TestCreateAllInOneDeployment(t *testing.T) { } func TestCreateAllInOneDeploymentOnOpenShift(t *testing.T) { - viper.Set("openshift", true) + viper.Set("platform", "openshift") defer viper.Reset() name := "TestCreateAllInOneDeploymentOnOpenShift" c := newAllInOneController(context.TODO(), v1alpha1.NewJaeger(name)) @@ -83,14 +83,12 @@ func assertDeploymentsAndServicesForAllInOne(t *testing.T, name string, objs []s // the ingress rule, if we are not on openshift var ingresses map[string]bool var routes map[string]bool - if viper.GetBool("openshift") { - fmt.Println("openshift deployment!") + if viper.GetString("platform") == v1alpha1.FlagPlatformOpenShift { ingresses = map[string]bool{} routes = map[string]bool{ fmt.Sprintf("%s", name): false, } } else { - fmt.Println("NOT openshift deployment!") ingresses = map[string]bool{ fmt.Sprintf("%s-query", name): false, } diff --git a/pkg/controller/production.go b/pkg/controller/production.go index 99184b5cf..88fd509fb 100644 --- a/pkg/controller/production.go +++ b/pkg/controller/production.go @@ -50,7 +50,7 @@ func (c *productionController) Create() []sdk.Object { components = append(components, svc) } - if viper.GetBool("openshift") { + if viper.GetString("platform") == v1alpha1.FlagPlatformOpenShift { qr := route.NewQueryRoute(c.jaeger).Get() if nil != qr { components = append(components, qr) diff --git a/pkg/controller/production_test.go b/pkg/controller/production_test.go index 950485c2c..38cae1082 100644 --- a/pkg/controller/production_test.go +++ b/pkg/controller/production_test.go @@ -27,7 +27,7 @@ func TestCreateProductionDeployment(t *testing.T) { } func TestCreateProductionDeploymentOnOpenShift(t *testing.T) { - viper.Set("openshift", true) + viper.Set("platform", "openshift") defer viper.Reset() name := "TestCreateProductionDeploymentOnOpenShift" c := newProductionController(context.TODO(), v1alpha1.NewJaeger(name)) @@ -116,7 +116,7 @@ func assertDeploymentsAndServicesForProduction(t *testing.T, name string, objs [ var ingresses map[string]bool var routes map[string]bool - if viper.GetBool("openshift") { + if viper.GetString("platform") == v1alpha1.FlagPlatformOpenShift { ingresses = map[string]bool{} routes = map[string]bool{ fmt.Sprintf("%s", name): false, diff --git a/pkg/route/query.go b/pkg/route/query.go index 908c1054d..6c9ed8f8c 100644 --- a/pkg/route/query.go +++ b/pkg/route/query.go @@ -23,7 +23,7 @@ func NewQueryRoute(jaeger *v1alpha1.Jaeger) *QueryRoute { // Get returns an ingress specification for the current instance func (r *QueryRoute) Get() *v1.Route { - if r.jaeger.Spec.Route.Enabled != nil && *r.jaeger.Spec.Route.Enabled == false { + if r.jaeger.Spec.Ingress.Enabled != nil && *r.jaeger.Spec.Ingress.Enabled == false { return nil } diff --git a/pkg/route/query_test.go b/pkg/route/query_test.go index 179b4f991..36b1ac420 100644 --- a/pkg/route/query_test.go +++ b/pkg/route/query_test.go @@ -23,7 +23,7 @@ func TestQueryRouteDisabled(t *testing.T) { enabled := false name := "TestQueryRouteDisabled" jaeger := v1alpha1.NewJaeger(name) - jaeger.Spec.Route.Enabled = &enabled + jaeger.Spec.Ingress.Enabled = &enabled route := NewQueryRoute(jaeger) dep := route.Get() @@ -35,7 +35,7 @@ func TestQueryRouteEnabled(t *testing.T) { enabled := true name := "TestQueryRouteEnabled" jaeger := v1alpha1.NewJaeger(name) - jaeger.Spec.Route.Enabled = &enabled + jaeger.Spec.Ingress.Enabled = &enabled route := NewQueryRoute(jaeger) dep := route.Get()