add cluster and controller methods for getting status

This commit is contained in:
Murat Kabilov
2017-08-15 12:11:06 +02:00
parent 4ee28e3818
commit 82f58b57d8
4 changed files with 238 additions and 0 deletions
+17
View File
@@ -644,3 +644,20 @@ func (c *Cluster) initInfrastructureRoles() error {
}
return nil
}
// GetStatus provides status of the cluster
func (c *Cluster) GetStatus() *spec.ClusterStatus {
return &spec.ClusterStatus{
Cluster: c.Spec.ClusterName,
Team: c.Spec.TeamID,
Status: c.Status,
Spec: c.Spec,
MasterService: c.GetServiceMaster(),
ReplicaService: c.GetServiceReplica(),
Endpoint: c.GetEndpoint(),
StatefulSet: c.GetStatefulSet(),
Error: c.Error,
}
}
+20
View File
@@ -419,3 +419,23 @@ func (c *Cluster) createRoles() (err error) {
// TODO: figure out what to do with duplicate names (humans and robots) among pgUsers
return c.syncRoles(false)
}
// GetServiceMaster returns cluster's kubernetes master Service
func (c *Cluster) GetServiceMaster() *v1.Service {
return c.Service[master]
}
// GetServiceReplica returns cluster's kubernetes replica Service
func (c *Cluster) GetServiceReplica() *v1.Service {
return c.Service[replica]
}
// GetEndpoint returns cluster's kubernetes Endpoint
func (c *Cluster) GetEndpoint() *v1.Endpoints {
return c.Endpoint
}
// GetStatefulSet returns cluster's kubernetes StatefulSet
func (c *Cluster) GetStatefulSet() *v1beta1.StatefulSet {
return c.Statefulset
}