Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
2 changes: 2 additions & 0 deletions api/v1beta1/grafana_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type GrafanaSpec struct {
Ingress *IngressNetworkingV1 `json:"ingress,omitempty"`
// Route sets how the ingress object should look like with your grafana instance, this only works in Openshift.
Route *RouteOpenshiftV1 `json:"route,omitempty"`
// HTTPRoute sets how the ingress object should look like with your grafana instance, this only works use gateway api.
HTTPRoute *HTTPRouteV1 `json:"httpRoute,omitempty"`
// Service sets how the service object should look like with your grafana instance, contains a number of defaults.
Service *ServiceV1 `json:"service,omitempty"`
// Version sets the tag of the default image: docker.io/grafana/grafana.
Expand Down
8 changes: 8 additions & 0 deletions api/v1beta1/typeoverrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/strategicpatch"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// +kubebuilder:object:generate=true
Expand Down Expand Up @@ -327,6 +328,13 @@ type RouteOpenshiftV1 struct {
Spec *RouteOpenShiftV1Spec `json:"spec,omitempty"`
}

// +kubebuilder:object:generate=true

type HTTPRouteV1 struct {
ObjectMeta ObjectMeta `json:"metadata,omitempty"`
Spec gwapiv1.HTTPRouteSpec `json:"spec,omitempty"`
}

// RouteTargetReference specifies the target that resolve into endpoints. Only the 'Service'
// kind is allowed. Use 'weight' field to emphasize one over others.
type RouteTargetReference struct {
Expand Down
22 changes: 22 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

3,139 changes: 3,139 additions & 0 deletions config/crd/bases/grafana.integreatly.org_grafanas.yaml

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ rules:
- patch
- update
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gateways
verbs:
- get
- list
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- httproutes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- grafana.integreatly.org
resources:
Expand Down
2 changes: 2 additions & 0 deletions controllers/grafana_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type GrafanaReconciler struct {
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;patch
// +kubebuilder:rbac:groups="",resources=configmaps;secrets;serviceaccounts;services;persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=networking.k8s.io,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=httproutes,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=gateways,verbs=get;list;watch;

func (r *GrafanaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := logf.FromContext(ctx).WithName("GrafanaReconciler")
Expand Down
14 changes: 14 additions & 0 deletions controllers/model/grafana_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

func GetCommonLabels() map[string]string {
Expand Down Expand Up @@ -114,6 +115,19 @@ func GetGrafanaIngress(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *v12.
return ingress
}

func GetGrafanaHTTPRoute(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *gwapiv1.HTTPRoute {
httpRoute := &gwapiv1.HTTPRoute{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-httproute", cr.Name),
Namespace: cr.Namespace,
Labels: GetCommonLabels(),
},
}
controllerutil.SetControllerReference(cr, httpRoute, scheme) //nolint:errcheck

return httpRoute
}

func GetGrafanaRoute(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *routev1.Route {
route := &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Expand Down
Loading