// NewReplicationController returns the ReplicationController and a set of all the NodeIDs covered by the ReplicationController func NewReplicationController(g osgraph.Graph, rcNode *kubegraph.ReplicationControllerNode) (ReplicationController, IntSet) { covered := IntSet{} covered.Insert(rcNode.ID()) rcView := ReplicationController{} rcView.RC = rcNode for _, uncastPodNode := range g.PredecessorNodesByEdgeKind(rcNode, kubeedges.ManagedByRCEdgeKind) { podNode := uncastPodNode.(*kubegraph.PodNode) covered.Insert(podNode.ID()) rcView.OwnedPods = append(rcView.OwnedPods, podNode) // check to see if this pod is managed by more than one RC uncastOwningRCs := g.SuccessorNodesByEdgeKind(podNode, kubeedges.ManagedByRCEdgeKind) if len(uncastOwningRCs) > 1 { for _, uncastOwningRC := range uncastOwningRCs { if uncastOwningRC.ID() == rcNode.ID() { continue } conflictingRC := uncastOwningRC.(*kubegraph.ReplicationControllerNode) rcView.ConflictingRCs = append(rcView.ConflictingRCs, conflictingRC) conflictingPods, ok := rcView.ConflictingRCIDToPods[conflictingRC.ID()] if !ok { conflictingPods = []*kubegraph.PodNode{} } conflictingPods = append(conflictingPods, podNode) rcView.ConflictingRCIDToPods[conflictingRC.ID()] = conflictingPods } } } return rcView, covered }
func describeRCInServiceGroup(rcNode *kubegraph.ReplicationControllerNode) []string { if rcNode.ReplicationController.Spec.Template == nil { return []string{} } images := []string{} for _, container := range rcNode.ReplicationController.Spec.Template.Spec.Containers { images = append(images, container.Image) } lines := []string{fmt.Sprintf("%s runs %s", rcNode.ResourceString(), strings.Join(images, ", "))} lines = append(lines, describeRCStatus(rcNode.ReplicationController)) return lines }