Skip to content

Commit

Permalink
Use Ingress to configure Route, added 'platform' flag, removed 'opens…
Browse files Browse the repository at this point in the history
…hift' flag

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling committed Nov 7, 2018
1 parent b37f3f2 commit 78de5ca
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
ports:
- containerPort: 60000
name: metrics
args: ["start", "--openshift=true"]
args: ["start", "--platform=openshift"]
imagePullPolicy: Always
env:
- name: WATCH_NAMESPACE
Expand Down
14 changes: 8 additions & 6 deletions pkg/apis/io/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand All @@ -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"`
Expand Down
22 changes: 0 additions & 22 deletions pkg/apis/io/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/all-in-one.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/all-in-one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/production.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/route/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/route/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 78de5ca

Please sign in to comment.