github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/latest/monitoring/monitoring.go (about)

     1  package monitoring
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/boom/api/latest/monitoring/admin"
     5  	"github.com/caos/orbos/internal/operator/boom/api/latest/monitoring/auth"
     6  	"github.com/caos/orbos/internal/operator/boom/api/latest/network"
     7  	"github.com/caos/orbos/internal/operator/boom/api/latest/storage"
     8  	"github.com/caos/orbos/pkg/kubernetes/k8s"
     9  )
    10  
    11  type Monitoring struct {
    12  	//Flag if tool should be deployed
    13  	//@default: false
    14  	Deploy bool `json:"deploy" yaml:"deploy"`
    15  	//Spec for the definition of the admin account
    16  	Admin *admin.Admin `json:"admin,omitempty" yaml:"admin,omitempty"`
    17  	//Spec for additional datasources
    18  	Datasources []*Datasource `json:"datasources,omitempty" yaml:"datasources,omitempty"`
    19  	//Spec for additional Dashboardproviders
    20  	DashboardProviders []*Provider `json:"dashboardproviders,omitempty" yaml:"dashboardproviders,omitempty"`
    21  	//Spec to define how the persistence should be handled
    22  	Storage *storage.Spec `json:"storage,omitempty" yaml:"storage,omitempty"`
    23  	//Network configuration, used for SSO and external access
    24  	Network *network.Network `json:"network,omitempty" yaml:"network,omitempty"`
    25  	//Authorization and Authentication configuration for SSO
    26  	Auth *auth.Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
    27  	//List of plugins which get added to the grafana instance
    28  	Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
    29  	//NodeSelector for deployment
    30  	NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
    31  	//Tolerations to run grafana on nodes
    32  	Tolerations k8s.Tolerations `json:"tolerations,omitempty" yaml:"tolerations,omitempty"`
    33  	//Resource requirements
    34  	Resources *k8s.Resources `json:"resources,omitempty" yaml:"resources,omitempty"`
    35  	//Overwrite used image
    36  	OverwriteImage string `json:"overwriteImage,omitempty" yaml:"overwriteImage,omitempty"`
    37  	//Overwrite used image version
    38  	OverwriteVersion string `json:"overwriteVersion,omitempty" yaml:"overwriteVersion,omitempty"`
    39  }
    40  
    41  func (m *Monitoring) InitSecrets() {
    42  	if m.Admin == nil {
    43  		m.Admin = &admin.Admin{}
    44  	}
    45  	m.Admin.InitSecrets()
    46  
    47  	if m.Auth == nil {
    48  		m.Auth = &auth.Auth{}
    49  	}
    50  	m.Auth.InitSecrets()
    51  }
    52  
    53  func (m *Monitoring) IsZero() bool {
    54  	if !m.Deploy &&
    55  		(m.Admin == nil || m.Admin.IsZero()) &&
    56  		(m.Auth == nil || m.Auth.IsZero()) &&
    57  		m.Datasources == nil &&
    58  		m.DashboardProviders == nil &&
    59  		m.Storage == nil &&
    60  		m.Network == nil &&
    61  		m.Plugins == nil &&
    62  		m.NodeSelector == nil &&
    63  		m.Tolerations == nil &&
    64  		m.Resources == nil {
    65  		return true
    66  	}
    67  
    68  	return false
    69  }
    70  
    71  type Datasource struct {
    72  	//Name of the datasource
    73  	Name string `json:"name,omitempty" yaml:"name,omitempty"`
    74  	//Type of the datasource (for example prometheus)
    75  	Type string `json:"type,omitempty" yaml:"type,omitempty"`
    76  	//URL to the datasource
    77  	Url string `json:"url,omitempty" yaml:"url,omitempty"`
    78  	//Access defintion of the datasource
    79  	Access string `json:"access,omitempty" yaml:"access,omitempty"`
    80  	//Boolean if datasource should be used as default
    81  	IsDefault bool `json:"isDefault,omitempty" yaml:"isDefault,omitempty"`
    82  }
    83  
    84  type Provider struct {
    85  	//ConfigMaps in which the dashboards are stored
    86  	ConfigMaps []string `json:"configMaps,omitempty" yaml:"configMaps,omitempty"`
    87  	//Local folder in which the dashboards are mounted
    88  	Folder string `json:"folder,omitempty" yaml:"folder,omitempty"`
    89  }