コード例 #1
0
ファイル: deployments.go プロジェクト: richm/origin
// TODO: Reuse this from upstream once kubernetes/issues/21551 is fixed.
func describeContainers(spec kapi.PodSpec, w io.Writer) {
	for _, container := range spec.Containers {
		fmt.Fprintf(w, "  %v:\n", container.Name)
		fmt.Fprintf(w, "    Image:\t%s\n", container.Image)

		if len(container.Command) > 0 {
			fmt.Fprintf(w, "    Command:\n")
			for _, c := range container.Command {
				fmt.Fprintf(w, "      %s\n", c)
			}
		}
		if len(container.Args) > 0 {
			fmt.Fprintf(w, "    Args:\n")
			for _, arg := range container.Args {
				fmt.Fprintf(w, "      %s\n", arg)
			}
		}

		resourceToQoS := qosutil.GetQoS(&container)
		if len(resourceToQoS) > 0 {
			fmt.Fprintf(w, "    QoS Tier:\n")
		}
		for resource, qos := range resourceToQoS {
			fmt.Fprintf(w, "      %s:\t%s\n", resource, qos)
		}

		if len(container.Resources.Limits) > 0 {
			fmt.Fprintf(w, "    Limits:\n")
		}
		for name, quantity := range container.Resources.Limits {
			fmt.Fprintf(w, "      %s:\t%s\n", name, quantity.String())
		}

		if len(container.Resources.Requests) > 0 {
			fmt.Fprintf(w, "    Requests:\n")
		}
		for name, quantity := range container.Resources.Requests {
			fmt.Fprintf(w, "      %s:\t%s\n", name, quantity.String())
		}

		if container.LivenessProbe != nil {
			probe := kctl.DescribeProbe(container.LivenessProbe)
			fmt.Fprintf(w, "    Liveness:\t%s\n", probe)
		}
		if container.ReadinessProbe != nil {
			probe := kctl.DescribeProbe(container.ReadinessProbe)
			fmt.Fprintf(w, "    Readiness:\t%s\n", probe)
		}

		fmt.Fprintf(w, "    Environment Variables:\n")
		for _, e := range container.Env {
			fmt.Fprintf(w, "      %s:\t%s\n", e.Name, e.Value)
		}
	}
}
コード例 #2
0
ファイル: describe.go プロジェクト: ncantor/origin
func describeContainers(pod *api.Pod, out io.Writer) {
	statuses := map[string]api.ContainerStatus{}
	for _, status := range pod.Status.ContainerStatuses {
		statuses[status.Name] = status
	}

	for _, container := range pod.Spec.Containers {
		status := statuses[container.Name]
		state := status.State

		fmt.Fprintf(out, "  %v:\n", container.Name)
		fmt.Fprintf(out, "    Container ID:\t%s\n", status.ContainerID)
		fmt.Fprintf(out, "    Image:\t%s\n", container.Image)
		fmt.Fprintf(out, "    Image ID:\t%s\n", status.ImageID)

		resourceToQoS := qosutil.GetQoS(&container)
		if len(resourceToQoS) > 0 {
			fmt.Fprintf(out, "    QoS Tier:\n")
		}
		for resource, qos := range resourceToQoS {
			fmt.Fprintf(out, "      %s:\t%s\n", resource, qos)
		}

		if len(container.Resources.Limits) > 0 {
			fmt.Fprintf(out, "    Limits:\n")
		}
		for name, quantity := range container.Resources.Limits {
			fmt.Fprintf(out, "      %s:\t%s\n", name, quantity.String())
		}

		if len(container.Resources.Requests) > 0 {
			fmt.Fprintf(out, "    Requests:\n")
		}
		for name, quantity := range container.Resources.Requests {
			fmt.Fprintf(out, "      %s:\t%s\n", name, quantity.String())
		}

		describeStatus("State", state, out)
		if status.LastTerminationState.Terminated != nil {
			describeStatus("Last Termination State", status.LastTerminationState, out)
		}
		fmt.Fprintf(out, "    Ready:\t%v\n", printBool(status.Ready))
		fmt.Fprintf(out, "    Restart Count:\t%d\n", status.RestartCount)
		fmt.Fprintf(out, "    Environment Variables:\n")
		for _, e := range container.Env {
			if e.ValueFrom != nil && e.ValueFrom.FieldRef != nil {
				valueFrom := envValueFrom(pod, e)
				fmt.Fprintf(out, "      %s:\t%s (%s:%s)\n", e.Name, valueFrom, e.ValueFrom.FieldRef.APIVersion, e.ValueFrom.FieldRef.FieldPath)
			} else {
				fmt.Fprintf(out, "      %s:\t%s\n", e.Name, e.Value)
			}
		}
	}
}
コード例 #3
0
ファイル: pods.go プロジェクト: RomainVabre/origin
func isBestEffort(pod *api.Pod) bool {
	// TODO: when we have request/limits on a pod scope, we need to revisit this
	for _, container := range pod.Spec.Containers {
		qosPerResource := util.GetQoS(&container)
		for _, qos := range qosPerResource {
			if util.BestEffort == qos {
				return true
			}
		}
	}
	return false
}