Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Cluster Health Monitoring #648

Merged
merged 3 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions helm/minio-operator/crds/minio.min.io_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3440,6 +3440,17 @@ spec:
type: object
currentState:
type: string
drivesHealing:
format: int32
type: integer
drivesOffline:
format: int32
type: integer
drivesOnline:
format: int32
type: integer
healthStatus:
type: string
pools:
items:
properties:
Expand All @@ -3458,6 +3469,9 @@ spec:
type: integer
syncVersion:
type: string
writeQuorum:
format: int32
type: integer
required:
- availableReplicas
- certificates
Expand Down Expand Up @@ -6915,6 +6929,17 @@ spec:
type: object
currentState:
type: string
drivesHealing:
format: int32
type: integer
drivesOffline:
format: int32
type: integer
drivesOnline:
format: int32
type: integer
healthStatus:
type: string
pools:
items:
properties:
Expand All @@ -6933,6 +6958,9 @@ spec:
type: integer
syncVersion:
type: string
writeQuorum:
format: int32
type: integer
required:
- availableReplicas
- certificates
Expand Down
11 changes: 0 additions & 11 deletions pkg/apis/minio.min.io/v1/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,9 @@

package v1

import "os"

// ClusterDomain is used to store the Kubernetes cluster domain
var ClusterDomain string

// KESIdentity is the public identity generated for MinIO Server based on
// Used only during KES Deployments
var KESIdentity string

// InitGlobals initiates the global variables while Operator starts
func InitGlobals(t *Tenant) {
var ok bool
ClusterDomain, ok = os.LookupEnv("CLUSTER_DOMAIN")
if !ok {
ClusterDomain = "cluster.local"
}
}
5 changes: 5 additions & 0 deletions pkg/apis/minio.min.io/v2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,8 @@ const tenantMinIOImageEnv = "TENANT_MINIO_IMAGE"
const tenantConsoleImageEnv = "TENANT_CONSOLE_IMAGE"

const tenantKesImageEnv = "TENANT_KES_IMAGE"

const monitoringIntervalEnv = "MONITORING_INTERVAL"

// DefaultMonitoringInterval is how often we run monitoring on tenants
const DefaultMonitoringInterval = 3
29 changes: 29 additions & 0 deletions pkg/apis/minio.min.io/v2/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ var (
tenantMinIOImageOnce sync.Once
tenantConsoleImageOnce sync.Once
tenantKesImageOnce sync.Once
monitoringIntervalOnce sync.Once
k8sClusterDomain string
tenantMinIOImage string
tenantConsoleImage string
tenantKesImage string
monitoringInterval int
)

// GetPodCAFromFile assumes the operator is running inside a k8s pod and extract the
Expand Down Expand Up @@ -921,3 +923,30 @@ func GetTenantKesImage() string {
})
return tenantKesImage
}

// GetMonitoringInterval returns how ofter we should query tenants for cluster/health
func GetMonitoringInterval() int {
monitoringIntervalOnce.Do(func() {
monitoringIntervalStr := envGet(monitoringIntervalEnv, "")
if monitoringIntervalStr == "" {
monitoringInterval = DefaultMonitoringInterval
}
val, err := strconv.Atoi(monitoringIntervalStr)
if err != nil {
monitoringInterval = DefaultMonitoringInterval
} else {
monitoringInterval = val
}
})
return monitoringInterval
}

// GetTenantServiceURL gets tenant's service url with the proper scheme and port
func (t *Tenant) GetTenantServiceURL() (svcURL string) {
dvaldivia marked this conversation as resolved.
Show resolved Hide resolved
scheme := "http"
if t.TLS() {
scheme = "https"
}
svc := t.MinIOServerHostAddress()
return fmt.Sprintf("%s://%s", scheme, svc)
}
32 changes: 32 additions & 0 deletions pkg/apis/minio.min.io/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ type PoolStatus struct {
State PoolState `json:"state"`
}

// HealthStatus represents whether the tenant is healthy, with decreased service or offline
type HealthStatus string

const (
// HealthStatusGreen indicates a healthy tenant: all drives online
HealthStatusGreen HealthStatus = "green"
// HealthStatusYellow indicates a decreased resilience tenant, some drives offline
HealthStatusYellow HealthStatus = "yellow"
// HealthStatusRed indicates a the tenant is offline, or lost write quorum
HealthStatusRed HealthStatus = "red"
)

// TenantStatus is the status for a Tenant resource
type TenantStatus struct {
CurrentState string `json:"currentState"`
Expand All @@ -373,6 +385,26 @@ type TenantStatus struct {
// All the pools get an individual status
// +nullable
Pools []PoolStatus `json:"pools"`
// *Optional* +
//
// Minimum number of disks that need to be online
WriteQuorum int32 `json:"writeQuorum,omitempty"`
// *Optional* +
//
// Total number of drives online for the tenant
DrivesOnline int32 `json:"drivesOnline,omitempty"`
// *Optional* +
//
// Total number of drives offline
DrivesOffline int32 `json:"drivesOffline,omitempty"`
// *Optional* +
//
// Drives with healing going on
DrivesHealing int32 `json:"drivesHealing,omitempty"`
// *Optional* +
//
// Health State of the tenant
HealthStatus HealthStatus `json:"healthStatus,omitempty"`
}

// CertificateConfig (`certConfig`) defines controlling attributes associated to any TLS certificate automatically generated by the Operator as part of tenant creation. These fields have no effect if `spec.autoCert: false`.
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/cluster/main-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ func (c *Controller) Start(threadiness int, stopCh <-chan struct{}) error {
go wait.Until(c.runWorker, time.Second, stopCh)
}

// Launch a goroutine to monitor all Tenants
go c.recurrentTenantStatusMonitor(stopCh)

return nil
}

Expand Down
Loading