Skip to content

Commit

Permalink
[ENHANCEMENT] get the operator up to date
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>
  • Loading branch information
ibakshay committed Oct 21, 2024
1 parent 4af0df8 commit 254f17c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
36 changes: 16 additions & 20 deletions config/crd/bases/perses.dev_perses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions config/samples/perses.dev_v1alpha1_perses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions config/samples/perses.dev_v1alpha1_persesdashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 24 additions & 6 deletions internal/perses/common/perses_client_factory.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ 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.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"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,
Expand Down

0 comments on commit 254f17c

Please sign in to comment.