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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Next Next commit
wip: rewrite reconciliation loop, migrate to go modules and use grafa…
…na client
  • Loading branch information
pb82 committed Dec 1, 2019
commit df95743ff08aacf69511a3288022ca6c86d5c1a4
The diff you're trying to view is too large. We only load the first 3000 changed files.
806 changes: 0 additions & 806 deletions Gopkg.lock

This file was deleted.

67 changes: 0 additions & 67 deletions Gopkg.toml

This file was deleted.

57 changes: 33 additions & 24 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
"github.com/integr8ly/grafana-operator/pkg/apis"
"github.com/integr8ly/grafana-operator/pkg/controller"
"github.com/integr8ly/grafana-operator/pkg/controller/common"
config2 "github.com/integr8ly/grafana-operator/pkg/controller/config"
"github.com/integr8ly/grafana-operator/pkg/controller/grafanadashboard"
"github.com/integr8ly/grafana-operator/version"
routev1 "github.com/openshift/api/route/v1"
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/ready"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"k8s.io/apimachinery/pkg/runtime/schema"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/rest"
"os"
Expand All @@ -29,7 +32,6 @@ var flagImage string
var flagImageTag string
var flagPluginsInitContainerImage string
var flagPluginsInitContainerTag string
var flagPodLabelValue string
var flagNamespaces string
var scanAll bool

Expand All @@ -46,16 +48,18 @@ func init() {
flagset.StringVar(&flagImageTag, "grafana-image-tag", "", "Overrides the default Grafana image tag")
flagset.StringVar(&flagPluginsInitContainerImage, "grafana-plugins-init-container-image", "", "Overrides the default Grafana Plugins Init Container image")
flagset.StringVar(&flagPluginsInitContainerTag, "grafana-plugins-init-container-tag", "", "Overrides the default Grafana Plugins Init Container tag")
flagset.StringVar(&flagPodLabelValue, "pod-label-value", common.PodLabelDefaultValue, "Overrides the default value of the app label")
flagset.StringVar(&flagNamespaces, "namespaces", "", "Namespaces to scope the interaction of the Grafana operator. Mutually exclusive with --scan-all")
flagset.BoolVar(&scanAll, "scan-all", false, "Scans all namespaces for dashboards")
flagset.Parse(os.Args[1:])
}

// Starts a separate controller for the dashboard reconciliation in the background
func startDashboardController(ns string, cfg *rest.Config, signalHandler <-chan struct{}) {
func startDashboardController(ns string, cfg *rest.Config, signalHandler <-chan struct{}, autodetectChannel chan schema.GroupVersionKind) {
// Create a new Cmd to provide shared dependencies and start components
dashboardMgr, err := manager.New(cfg, manager.Options{Namespace: ns})
dashboardMgr, err := manager.New(cfg, manager.Options{
MetricsBindAddress: "0",
Namespace: ns,
})
if err != nil {
log.Error(err, "")
os.Exit(1)
Expand All @@ -68,7 +72,7 @@ func startDashboardController(ns string, cfg *rest.Config, signalHandler <-chan
}

// Use a separate manager for the dashboard controller
grafanadashboard.Add(dashboardMgr)
grafanadashboard.Add(dashboardMgr, autodetectChannel)

go func() {
if err := dashboardMgr.Start(signalHandler); err != nil {
Expand Down Expand Up @@ -115,14 +119,13 @@ func main() {
}

// Controller configuration
controllerConfig := common.GetControllerConfig()
controllerConfig.AddConfigItem(common.ConfigGrafanaImage, flagImage)
controllerConfig.AddConfigItem(common.ConfigGrafanaImageTag, flagImageTag)
controllerConfig.AddConfigItem(common.ConfigPluginsInitContainerImage, flagPluginsInitContainerImage)
controllerConfig.AddConfigItem(common.ConfigPluginsInitContainerTag, flagPluginsInitContainerTag)
controllerConfig.AddConfigItem(common.ConfigPodLabelValue, flagPodLabelValue)
controllerConfig.AddConfigItem(common.ConfigOperatorNamespace, namespace)
controllerConfig.AddConfigItem(common.ConfigDashboardLabelSelector, "")
controllerConfig := config2.GetControllerConfig()
controllerConfig.AddConfigItem(config2.ConfigGrafanaImage, flagImage)
controllerConfig.AddConfigItem(config2.ConfigGrafanaImageTag, flagImageTag)
controllerConfig.AddConfigItem(config2.ConfigPluginsInitContainerImage, flagPluginsInitContainerImage)
controllerConfig.AddConfigItem(config2.ConfigPluginsInitContainerTag, flagPluginsInitContainerTag)
controllerConfig.AddConfigItem(config2.ConfigOperatorNamespace, namespace)
controllerConfig.AddConfigItem(config2.ConfigDashboardLabelSelector, "")

// Get the namespaces to scan for dashboards
// It's either the same namespace as the controller's or it's all namespaces if the
Expand Down Expand Up @@ -169,34 +172,40 @@ func main() {

log.Info("Registering Components.")

// Starting the resource auto-detection for the grafana controller
autodetect, err := common.NewAutoDetect(mgr)
if err != nil {
log.Error(err, "failed to start the background process to auto-detect the operator capabilities")
} else {
autodetect.Start()
defer autodetect.Stop()
}

// Setup Scheme for all resources
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "")
os.Exit(1)
}

// Setup Scheme for OpenShift routes
if err := routev1.AddToScheme(mgr.GetScheme()); err != nil {
log.Error(err, "")
os.Exit(1)
}

// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
if err := controller.AddToManager(mgr, autodetect.SubscriptionChannel); err != nil {
log.Error(err, "")
os.Exit(1)
}

log.Info("Starting the Cmd.")

// Starting the resource auto-detection for the grafana controller
autodetect, err := common.NewAutoDetect(mgr)
if err != nil {
log.Error(err, "failed to start the background process to auto-detect the operator capabilities")
} else {
autodetect.Start()
defer autodetect.Stop()
}

signalHandler := signals.SetupSignalHandler()

// Start one dashboard controller per watch namespace
for _, ns := range dashboardNamespaces {
startDashboardController(ns, cfg, signalHandler)
startDashboardController(ns, cfg, signalHandler, autodetect.SubscriptionChannel)
}

if err := mgr.Start(signalHandler); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions deploy/crds/Grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
plural: grafanas
singular: grafana
scope: Namespaced
subresources:
status: {}
version: v1alpha1
validation:
openAPIV3Schema:
Expand Down Expand Up @@ -86,6 +88,15 @@ spec:
type:
type: string
description: Service type (NodePort, ClusterIP or LoadBalancer)
deployment:
type: object
properties:
annotations:
type: object
description: Additional annotations for the service
labels:
type: object
description: Additional labels for the service
dashboardLabelSelectors:
type: array
items:
Expand Down
9 changes: 2 additions & 7 deletions deploy/crds/GrafanaDashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ spec:
plural: grafanadashboards
singular: grafanadashboard
scope: Namespaced
subresources:
status: {}
version: v1alpha1
validation:
openAPIV3Schema:
properties:
status:
properties:
messages:
type: array
items:
description: Dashboard Status Message
type: object
spec:
properties:
name:
Expand Down
4 changes: 2 additions & 2 deletions deploy/crds/GrafanaDataSource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
plural: grafanadatasources
singular: grafanadatasource
scope: Namespaced
subresources:
status: {}
version: v1alpha1
validation:
openAPIV3Schema:
Expand All @@ -31,5 +33,3 @@ spec:
items:
description: Grafana Datasource Object
type: object
status:
type: object
54 changes: 54 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module github.com/integr8ly/grafana-operator

go 1.13

require (
cloud.google.com/go v0.35.1 // indirect
github.com/blang/semver v3.5.1+incompatible
github.com/ghodss/yaml v1.0.1-0.20180820084758-c7ce16629ff4
github.com/go-ini/ini v1.42.0
github.com/go-logr/logr v0.1.0
github.com/go-openapi/spec v0.19.0
github.com/go-openapi/swag v0.18.0 // indirect
github.com/google/uuid v1.1.0 // indirect
github.com/grafana-tools/sdk v0.0.0-20191103185352-c717bbeb00ed
github.com/openshift/api v3.9.1-0.20190424152011-77b8897ec79a+incompatible
github.com/operator-framework/operator-sdk v0.12.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/common v0.7.0 // indirect
github.com/prometheus/procfs v0.0.7 // indirect
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/client-go v11.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d
sigs.k8s.io/controller-runtime v0.3.0
)

// Pinned to kubernetes-1.15.4
replace (
k8s.io/api => k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190918201827-3de75813f604
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190817020851-f2f3a405f61d
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190918200908-1e17798da8c1
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190918202139-0b14c719ca62
k8s.io/client-go => k8s.io/client-go v0.0.0-20190918200256-06eb1244587a
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190918203125-ae665f80358a
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20190918202959-c340507a5d48
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190612205613-18da4a14b22b
k8s.io/component-base => k8s.io/component-base v0.0.0-20190918200425-ed2f0867c778
k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190817025403-3ae76f584e79
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20190918203248-97c07dcbb623
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20190918201136-c3a845f1fbb2
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20190918202837-c54ce30c680e
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20190918202429-08c8357f8e2d
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20190918202713-c34a54b3ec8e
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20190918202550-958285cf3eef
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20190918203421-225f0541b3ea
k8s.io/metrics => k8s.io/metrics v0.0.0-20190918202012-3c1ca76f5bda
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20190918201353-5cc279503896
)

// replace gopkg.in/fsnotify.v1 v1.4.7 => github.com/fsnotify/fsnotify v1.4.7
Loading