diff --git a/config/crd/bases/perses.dev_perses.yaml b/config/crd/bases/perses.dev_perses.yaml index ad6a3d7..6ac367c 100644 --- a/config/crd/bases/perses.dev_perses.yaml +++ b/config/crd/bases/perses.dev_perses.yaml @@ -228,8 +228,8 @@ spec: cleanup_interval: description: The interval at which to trigger the cleanup of ephemeral dashboards, based on their TTLs. - format: int64 - type: integer + format: duration + type: string enable: description: When true user will be able to use the ephemeral dashboard at project level. @@ -243,8 +243,8 @@ spec: EphemeralDashboardsCleanupInterval is the interval at which the ephemeral dashboards are cleaned up DEPRECATED. Please use the config EphemeralDashboard instead. - format: int64 - type: integer + format: duration + type: string frontend: description: Frontend contains any config that will be used by the frontend itself. @@ -513,8 +513,8 @@ spec: type: object refresh_interval: description: Refresh interval to re-query the endpoint. - format: int64 - type: integer + format: duration + type: string required: - discovery_name type: object @@ -529,8 +529,8 @@ spec: type: array interval: description: Interval is the refresh frequency - format: int64 - type: integer + format: duration + type: string type: object schemas: description: Schemas contain the configuration to get access to @@ -539,12 +539,8 @@ spec: datasources_path: type: string interval: - description: |- - Duration wraps time.Duration. It is used to parse the custom duration format - from YAML. - This type should not propagate beyond the scope of input/output processing. - format: int64 - type: integer + format: duration + type: string panels_path: type: string queries_path: @@ -564,8 +560,8 @@ spec: access_token_ttl: description: AccessTokenTTL is the time to live of the access token. By default, it is 15 minutes. - format: int64 - type: integer + format: duration + type: string disable_sign_up: description: |- DisableSignUp deactivates the Sign-up page in the UI. @@ -843,8 +839,8 @@ spec: RefreshTokenTTL is the time to live of the refresh token. The refresh token is used to get a new access token when it is expired. By default, it is 24 hours. - format: int64 - type: integer + format: duration + type: string required: - disable_sign_up - providers @@ -857,8 +853,8 @@ spec: description: CheckLatestUpdateInterval that checks if the RBAC cache needs to be refreshed with db content. Only for SQL database setup. - format: int64 - type: integer + format: duration + type: string guest_permissions: description: Default permissions for guest users (logged-in users) diff --git a/config/samples/perses.dev_v1alpha1_perses.yaml b/config/samples/perses.dev_v1alpha1_perses.yaml index 21b1718..c653ebc 100644 --- a/config/samples/perses.dev_v1alpha1_perses.yaml +++ b/config/samples/perses.dev_v1alpha1_perses.yaml @@ -19,4 +19,7 @@ spec: queries_path: "/etc/perses/cue/schemas/queries" datasources_path: "/etc/perses/cue/schemas/datasources" variables_path: "/etc/perses/cue/schemas/variables" + ephemeral_dashboard: + enable: false + cleanup_interval: "1s" containerPort: 8080 diff --git a/config/samples/perses.dev_v1alpha1_persesdashboard.yaml b/config/samples/perses.dev_v1alpha1_persesdashboard.yaml index 0733629..6a7d9e6 100644 --- a/config/samples/perses.dev_v1alpha1_persesdashboard.yaml +++ b/config/samples/perses.dev_v1alpha1_persesdashboard.yaml @@ -9,6 +9,9 @@ metadata: app.kubernetes.io/created-by: perses-operator name: perses-dashboard-sample spec: + display: + name: Perses Dashboard Sample + description: This is a sample dashboard duration: 5m datasources: PrometheusLocal: diff --git a/internal/perses/common/perses_client_factory.go b/internal/perses/common/perses_client_factory.go index 43bbcb0..434dd3d 100644 --- a/internal/perses/common/perses_client_factory.go +++ b/internal/perses/common/perses_client_factory.go @@ -1,11 +1,13 @@ package common import ( + "flag" "fmt" persesv1alpha1 "github.com/perses/perses-operator/api/v1alpha1" v1 "github.com/perses/perses/pkg/client/api/v1" - "github.com/perses/perses/pkg/client/perseshttp" + clientConfig "github.com/perses/perses/pkg/client/config" + "github.com/perses/perses/pkg/model/api/v1/common" ) type PersesClientFactory interface { @@ -19,10 +21,21 @@ func NewWithConfig() PersesClientFactory { } func (f *PersesClientFactoryWithConfig) CreateClient(perses persesv1alpha1.Perses) (v1.ClientInterface, error) { - restClient, err := perseshttp.NewFromConfig(perseshttp.RestConfigClient{ - URL: fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", perses.Name, perses.Namespace, perses.Spec.ContainerPort), - }) + var urlStr string + + if flag.Lookup("perses-server-url").Value.String() != "" { + urlStr = flag.Lookup("perses-server-url").Value.String() + } else { + urlStr = fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", perses.Name, perses.Namespace, perses.Spec.ContainerPort) + } + parsedURL, err := common.ParseURL(urlStr) + if err != nil { + return nil, err + } + restClient, err := clientConfig.NewRESTClient(clientConfig.RestConfigClient{ + URL: &common.URL{URL: parsedURL.URL}, + }) if err != nil { return nil, err } @@ -41,8 +54,13 @@ func NewWithURL(url string) PersesClientFactory { } func (f *PersesClientFactoryWithURL) CreateClient(config persesv1alpha1.Perses) (v1.ClientInterface, error) { - restClient, err := perseshttp.NewFromConfig(perseshttp.RestConfigClient{ - URL: f.url, + urStr := f.url + parsedURL, err := common.ParseURL(urStr) + if err != nil { + return nil, err + } + restClient, err := clientConfig.NewRESTClient(clientConfig.RestConfigClient{ + URL: &common.URL{URL: parsedURL.URL}, }) if err != nil { diff --git a/main.go b/main.go index be3beb0..53de9b0 100644 --- a/main.go +++ b/main.go @@ -60,6 +60,7 @@ func main() { var probeAddr string var persesImage string var enableHTTP2 bool + var persesServerURL string flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") @@ -67,6 +68,7 @@ func main() { "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") flag.StringVar(&persesImage, "perses-default-base-image", "docker.io/persesdev/perses:latest", "The default image used for the Perses deployment operands") + flag.StringVar(&persesServerURL, "perses-server-url", "", "The Perses backend server URL") flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.") opts := zap.Options{ Development: true,