Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
df95743
wip: rewrite reconciliation loop, migrate to go modules and use grafa…
pb82 Nov 10, 2019
ff96602
INTLY-4183-Updating grafana version
R-Lawton Nov 20, 2019
ce79073
travis should work with go modules
pb82 Nov 20, 2019
b1cc302
update go version requirement
pb82 Nov 20, 2019
dfa0309
update modules
pb82 Nov 20, 2019
d8573a2
update Dockerfile, remove templates
pb82 Nov 20, 2019
f52fbc5
basic dashboard api create/update/delete implemented
pb82 Nov 22, 2019
e7f3de0
implement dashboard logic: resync and updates
pb82 Nov 24, 2019
40ff24a
enable metrics
pb82 Nov 24, 2019
b6a092b
cleanup and version update
pb82 Nov 24, 2019
e297fc1
feat: import dashboards after grafana reinstall, improve unavailabili…
pb82 Nov 24, 2019
addeba5
wip - plugin installation
pb82 Nov 24, 2019
8b7bb76
wip: start working on a way to reset dashboards
pb82 Nov 25, 2019
2c1b8da
wip: resilient dashboards (should survive restarts)
pb82 Nov 25, 2019
211d1c2
remove dashboard wait time because it prevents updating plugins
pb82 Nov 25, 2019
f15e6b3
add oauth example
pb82 Nov 25, 2019
820a8d6
fix: persist admin user back to cr to prevent deploymetn from getting…
pb82 Nov 25, 2019
350b9b5
mount extra containers when specified in the cr
pb82 Nov 25, 2019
b480615
fix: missing arg to read grafana deployment
pb82 Nov 25, 2019
3bb2ba8
wip: set default resource requests and limits, hide empty config sect…
pb82 Nov 26, 2019
9acb449
feat: grafana admin credentials from secret
pb82 Nov 26, 2019
63db388
gofmt fixes
pb82 Nov 26, 2019
f45c0f9
graffanaServiceAccount modifications
R-Lawton Nov 28, 2019
f6a2413
update autogenerated code
pb82 Nov 28, 2019
b65d461
add datasources
StevenTobin Nov 29, 2019
2d25d10
delete datasources
pb82 Nov 29, 2019
fa462fd
adding permissions
R-Lawton Nov 29, 2019
275331e
add grafanadatasourceconfig to model
StevenTobin Nov 29, 2019
de46e59
mount datasources volume to provisioning directory
StevenTobin Nov 29, 2019
6789289
fix codee checks
StevenTobin Nov 29, 2019
08c705a
fixing forrmatting error
R-Lawton Nov 29, 2019
44302f9
comment changes and hardcode provisioning path
StevenTobin Nov 29, 2019
cae6afe
code check fixes
StevenTobin Nov 29, 2019
9cad949
updates to ensure new reconciler and grafana api work on vanilla kube
pb82 Nov 30, 2019
d33fc49
update permissions
pb82 Nov 30, 2019
8677d17
restart grafana on datasource change, do not reconcile datasources wh…
pb82 Dec 1, 2019
f63d7a6
implement datasource hashing
pb82 Dec 1, 2019
e711e83
improve datasource update handling
pb82 Dec 1, 2019
8b80abc
allow configuration of service ports and route target ports
pb82 Dec 1, 2019
908aede
wip: ensure config defaults
pb82 Dec 1, 2019
4a83a2e
wip: rework ini configuration
pb82 Dec 1, 2019
b2a6143
add client configuration options
pb82 Dec 1, 2019
318f7cd
update examples, only update datasource status if they have changed
pb82 Dec 1, 2019
ce9f3c2
rewrite ini config system
pb82 Dec 1, 2019
a757d2a
update oauth example
pb82 Dec 1, 2019
8d799f2
fix: service ports did not return existing
pb82 Dec 1, 2019
a5724f4
remove unused code
pb82 Dec 1, 2019
021347a
remove ini dependency
pb82 Dec 2, 2019
95fa747
add backwards compatibility options
pb82 Dec 2, 2019
74437bc
fix: correctly identify dashboards when scan all is enabled
pb82 Dec 2, 2019
63577da
update documentation
pb82 Dec 5, 2019
aac4c49
add changelog
pb82 Dec 5, 2019
df00168
add a note about the Grafana version
pb82 Dec 6, 2019
dee56ca
bump version to 3.0.0
pb82 Dec 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add client configuration options
  • Loading branch information
pb82 committed Dec 1, 2019
commit b2a61431e2a822e736166fa8916b36681cdac5c6
3 changes: 3 additions & 0 deletions deploy/crds/Grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ spec:
labels:
type: object
description: Additional labels for the serviceaccount
client:
type: object
description: Grafana client settings
dashboardLabelSelectors:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions deploy/examples/oauth/Grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
containers:
- args:
- '-provider=openshift'
- '-pass-basic-auth=false'
- '-https-address=:9091'
- '-http-address='
- '-email-domain=*'
Expand Down Expand Up @@ -58,6 +59,7 @@ spec:
ingress:
enabled: True
targetPort: grafana
termination: reencrypt
serviceAccount:
annotations:
serviceaccounts.openshift.io/oauth-redirectreference.primary: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"grafana-route"}}'
Expand Down
138 changes: 73 additions & 65 deletions pkg/apis/integreatly/v1alpha1/grafana_types.go

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions pkg/apis/integreatly/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 6 additions & 1 deletion pkg/apis/integreatly/v1alpha1/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,17 @@ func schema_pkg_apis_integreatly_v1alpha1_GrafanaSpec(ref common.ReferenceCallba
Ref: ref("./pkg/apis/integreatly/v1alpha1.GrafanaServiceAccount"),
},
},
"client": {
SchemaProps: spec.SchemaProps{
Ref: ref("./pkg/apis/integreatly/v1alpha1.GrafanaClient"),
},
},
},
Required: []string{"config"},
},
},
Dependencies: []string{
"./pkg/apis/integreatly/v1alpha1.GrafanaConfig", "./pkg/apis/integreatly/v1alpha1.GrafanaDeployment", "./pkg/apis/integreatly/v1alpha1.GrafanaIngress", "./pkg/apis/integreatly/v1alpha1.GrafanaService", "./pkg/apis/integreatly/v1alpha1.GrafanaServiceAccount", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"},
"./pkg/apis/integreatly/v1alpha1.GrafanaClient", "./pkg/apis/integreatly/v1alpha1.GrafanaConfig", "./pkg/apis/integreatly/v1alpha1.GrafanaDeployment", "./pkg/apis/integreatly/v1alpha1.GrafanaIngress", "./pkg/apis/integreatly/v1alpha1.GrafanaService", "./pkg/apis/integreatly/v1alpha1.GrafanaServiceAccount", "k8s.io/api/core/v1.Container", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector"},
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controller/common/controllerState.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type ControllerState struct {
AdminPassword string
AdminUrl string
GrafanaReady bool
ClientTimeout int
}
22 changes: 20 additions & 2 deletions pkg/controller/grafana/grafana_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

const ControllerName = "grafana-controller"
const DefaultClientTimeoutSeconds = 5

var log = logf.Log.WithName(ControllerName)

Expand Down Expand Up @@ -202,14 +203,21 @@ func (r *ReconcileGrafana) manageError(cr *i8ly.Grafana, issue error) (reconcile

// Try to find a suitable url to grafana
func (r *ReconcileGrafana) getGrafanaAdminUrl(cr *i8ly.Grafana, state *common.ClusterState) (string, error) {
// If preferService is true, we skip the routes and try to access grafana
// by using the serivce.
preferService := false
if cr.Spec.Client != nil {
preferService = cr.Spec.Client.PreferService
}

// First try to use the route if it exists. Prefer the route because it also works
// when running the operator outside of the cluster
if state.GrafanaRoute != nil {
if state.GrafanaRoute != nil && !preferService {
return fmt.Sprintf("https://%v", state.GrafanaRoute.Spec.Host), nil
}

// Try the ingress first if on vanilla Kubernetes
if state.GrafanaIngress != nil {
if state.GrafanaIngress != nil && !preferService {
for _, ingress := range state.GrafanaIngress.Status.LoadBalancer.Ingress {
if ingress.Hostname != "" {
return fmt.Sprintf("https://%v", ingress.Hostname), nil
Expand Down Expand Up @@ -263,7 +271,17 @@ func (r *ReconcileGrafana) manageSuccess(cr *i8ly.Grafana, state *common.Cluster
AdminPassword: string(state.AdminSecret.Data[model.GrafanaAdminPasswordEnvVar]),
AdminUrl: url,
GrafanaReady: true,
ClientTimeout: DefaultClientTimeoutSeconds,
}

if cr.Spec.Client != nil && cr.Spec.Client.TimeoutSeconds != nil {
seconds := DefaultClientTimeoutSeconds
if seconds < 0 {
seconds = DefaultClientTimeoutSeconds
}
controllerState.ClientTimeout = seconds
}

common.ControllerEvents <- controllerState

log.Info("desired cluster state met")
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/grafanadashboard/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (r *ReconcileGrafanaDashboard) reconcileDashboards(request reconcile.Reques
}

// Prepare lists
dashboardsToDelete := []*i8ly.GrafanaDashboardRef{}
var dashboardsToDelete []*i8ly.GrafanaDashboardRef

// Check if a given dashboard (by name) is present in the list of
// dashboards in the namespace
Expand Down Expand Up @@ -304,7 +304,8 @@ func (r *ReconcileGrafanaDashboard) getClient() (GrafanaClient, error) {
return nil, defaultErrors.New("invalid credentials (password)")
}

return NewGrafanaClient(url, username, password), nil
duration := time.Duration(r.state.ClientTimeout)
return NewGrafanaClient(url, username, password, duration), nil
}

// Test if a given dashboard matches an array of label selectors
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/grafanadashboard/grafana_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type GrafanaClientImpl struct {
grafanaClient *sdk.Client
}

func NewGrafanaClient(url, user, password string) GrafanaClient {
func NewGrafanaClient(url, user, password string, timeoutSeconds time.Duration) GrafanaClient {
transport := http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
Expand All @@ -37,7 +37,7 @@ func NewGrafanaClient(url, user, password string) GrafanaClient {

client := &http.Client{
Transport: &transport,
Timeout: time.Second * 2,
Timeout: time.Second * timeoutSeconds,
}

return &GrafanaClientImpl{
Expand Down
19 changes: 18 additions & 1 deletion pkg/controller/model/grafanaRoute.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ func GetIngressTargetPort(cr *v1alpha1.Grafana) intstr.IntOrString {
return intstr.FromString(cr.Spec.Ingress.TargetPort)
}

func getTermination(cr *v1alpha1.Grafana) v1.TLSTerminationType {
if cr.Spec.Ingress == nil {
return v1.TLSTerminationEdge
}

switch cr.Spec.Ingress.Termination {
case v1.TLSTerminationEdge:
return v1.TLSTerminationEdge
case v1.TLSTerminationReencrypt:
return v1.TLSTerminationReencrypt
case v1.TLSTerminationPassthrough:
return v1.TLSTerminationPassthrough
default:
return v1.TLSTerminationEdge
}
}

func getRouteSpec(cr *v1alpha1.Grafana) v1.RouteSpec {
return v1.RouteSpec{
Path: GetPath(cr),
Expand All @@ -62,7 +79,7 @@ func getRouteSpec(cr *v1alpha1.Grafana) v1.RouteSpec {
TargetPort: GetIngressTargetPort(cr),
},
TLS: &v1.TLSConfig{
Termination: v1.TLSTerminationReencrypt,
Termination: getTermination(cr),
},
WildcardPolicy: "None",
}
Expand Down