Ejemplo n.º 1
0
func buildRCObject(kube webservice.KubeClient, ns, rcname string) (*replicationController, error) {
	readyReplicas, err := countReadyReplicas(kube, ns, rcname)
	if err != nil {
		return nil, err
	}
	specReplicas, err := kube.GetSpecReplicas(ns, rcname)
	if err != nil {
		return nil, err
	}
	rc := replicationController{
		readyReplicas: readyReplicas,
		specReplicas:  specReplicas,
	}
	return &rc, nil
}
Ejemplo n.º 2
0
func countReadyReplicas(kube webservice.KubeClient, ns, rcname string) (uint, error) {
	pods, err := kube.GetPodsForController(ns, rcname)
	if err != nil {
		return 0, err
	}
	var count uint
	for _, p := range *pods {
		for _, c := range p.Status.Conditions {
			if c.Type == "Ready" && c.Status == "True" {
				count++
				break
			}
		}
	}
	return count, nil
}