Update ingress godeps

This commit is contained in:
Manuel de Brito Fontes 2016-08-10 14:53:55 -04:00
parent d43021b3f1
commit 28db8fb16d
1068 changed files with 461467 additions and 117300 deletions

View file

@ -28,7 +28,6 @@ import (
"strings"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/federation/apis/federation"
fed_clientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset"
"k8s.io/kubernetes/pkg/api"
@ -38,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/certificates"
"k8s.io/kubernetes/pkg/apis/extensions"
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
client "k8s.io/kubernetes/pkg/client/unversioned"
@ -48,8 +48,11 @@ import (
"k8s.io/kubernetes/pkg/kubelet/qos"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/types"
utilcertificates "k8s.io/kubernetes/pkg/util/certificates"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/golang/glog"
)
// Describer generates output for the named resource or an error
@ -101,16 +104,18 @@ func describerMap(c *client.Client) map[unversioned.GroupKind]Describer {
api.Kind("Endpoints"): &EndpointsDescriber{c},
api.Kind("ConfigMap"): &ConfigMapDescriber{c},
extensions.Kind("ReplicaSet"): &ReplicaSetDescriber{c},
extensions.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
extensions.Kind("NetworkPolicy"): &NetworkPolicyDescriber{c},
autoscaling.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
extensions.Kind("DaemonSet"): &DaemonSetDescriber{c},
extensions.Kind("Deployment"): &DeploymentDescriber{adapter.FromUnversionedClient(c)},
extensions.Kind("Job"): &JobDescriber{c},
batch.Kind("Job"): &JobDescriber{c},
apps.Kind("PetSet"): &PetSetDescriber{c},
extensions.Kind("Ingress"): &IngressDescriber{c},
extensions.Kind("ReplicaSet"): &ReplicaSetDescriber{c},
extensions.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
extensions.Kind("NetworkPolicy"): &NetworkPolicyDescriber{c},
autoscaling.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
extensions.Kind("DaemonSet"): &DaemonSetDescriber{c},
extensions.Kind("Deployment"): &DeploymentDescriber{adapter.FromUnversionedClient(c)},
extensions.Kind("Job"): &JobDescriber{c},
extensions.Kind("Ingress"): &IngressDescriber{c},
batch.Kind("Job"): &JobDescriber{c},
batch.Kind("ScheduledJob"): &ScheduledJobDescriber{adapter.FromUnversionedClient(c)},
apps.Kind("PetSet"): &PetSetDescriber{c},
certificates.Kind("CertificateSigningRequest"): &CertificateSigningRequestDescriber{c},
}
return m
@ -541,6 +546,7 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
}
describeVolumes(pod.Spec.Volumes, out, "")
fmt.Fprintf(out, "QoS Class:\t%s\n", qos.GetPodQOS(pod))
printTolerationsInAnnotationMultiline(out, "Tolerations", pod.Annotations)
if events != nil {
DescribeEvents(events, out)
}
@ -598,8 +604,12 @@ func describeVolumes(volumes []api.Volume, out io.Writer, space string) {
printPersistentVolumeClaimVolumeSource(volume.VolumeSource.PersistentVolumeClaim, out)
case volume.VolumeSource.RBD != nil:
printRBDVolumeSource(volume.VolumeSource.RBD, out)
case volume.VolumeSource.Quobyte != nil:
printQuobyteVolumeSource(volume.VolumeSource.Quobyte, out)
case volume.VolumeSource.DownwardAPI != nil:
printDownwardAPIVolumeSource(volume.VolumeSource.DownwardAPI, out)
case volume.VolumeSource.AzureDisk != nil:
printAzureDiskVolumeSource(volume.VolumeSource.AzureDisk, out)
default:
fmt.Fprintf(out, " <unknown>\n")
}
@ -659,6 +669,14 @@ func printNFSVolumeSource(nfs *api.NFSVolumeSource, out io.Writer) {
nfs.Server, nfs.Path, nfs.ReadOnly)
}
func printQuobyteVolumeSource(quobyte *api.QuobyteVolumeSource, out io.Writer) {
fmt.Fprintf(out, " Type:\tQuobyte (a Quobyte mount on the host that shares a pod's lifetime)\n"+
" Registry:\t%v\n"+
" Volume:\t%v\n"+
" ReadOnly:\t%v\n",
quobyte.Registry, quobyte.Volume, quobyte.ReadOnly)
}
func printISCSIVolumeSource(iscsi *api.ISCSIVolumeSource, out io.Writer) {
fmt.Fprintf(out, " Type:\tISCSI (an ISCSI Disk resource that is attached to a kubelet's host machine and then exposed to the pod)\n"+
" TargetPortal:\t%v\n"+
@ -710,6 +728,16 @@ func printDownwardAPIVolumeSource(d *api.DownwardAPIVolumeSource, out io.Writer)
}
}
func printAzureDiskVolumeSource(d *api.AzureDiskVolumeSource, out io.Writer) {
fmt.Fprintf(out, " Type:\tAzureDisk (an Azure Data Disk mount on the host and bind mount to the pod)\n"+
" DiskName:\t%v\n"+
" DiskURI:\t%v\n"+
" FSType:\t%v\n"+
" CachingMode:\t%v\n"+
" ReadOnly:\t%v\n",
d.DiskName, d.DataDiskURI, *d.FSType, *d.CachingMode, *d.ReadOnly)
}
type PersistentVolumeDescriber struct {
client.Interface
}
@ -759,6 +787,8 @@ func (d *PersistentVolumeDescriber) Describe(namespace, name string, describerSe
printGlusterfsVolumeSource(pv.Spec.Glusterfs, out)
case pv.Spec.RBD != nil:
printRBDVolumeSource(pv.Spec.RBD, out)
case pv.Spec.Quobyte != nil:
printQuobyteVolumeSource(pv.Spec.Quobyte, out)
}
if events != nil {
@ -931,7 +961,11 @@ func describeContainers(label string, containers []api.Container, containerStatu
if err != nil {
valueFrom = ""
}
fmt.Fprintf(out, " %s:\t%s (%s)\n", e.Name, valueFrom, e.ValueFrom.ResourceFieldRef.Resource)
resource := e.ValueFrom.ResourceFieldRef.Resource
if valueFrom == "0" && (resource == "limits.cpu" || resource == "limits.memory") {
valueFrom = "node allocatable"
}
fmt.Fprintf(out, " %s:\t%s (%s)\n", e.Name, valueFrom, resource)
case e.ValueFrom.SecretKeyRef != nil:
fmt.Fprintf(out, " %s:\t<set to the key '%s' in secret '%s'>\n", e.Name, e.ValueFrom.SecretKeyRef.Key, e.ValueFrom.SecretKeyRef.Name)
case e.ValueFrom.ConfigMapKeyRef != nil:
@ -1019,6 +1053,14 @@ func describeStatus(stateName string, state api.ContainerState, out io.Writer) {
}
}
func printBoolPtr(value *bool) string {
if value != nil {
return printBool(*value)
}
return "<unset>"
}
func printBool(value bool) string {
if value {
return "True"
@ -1148,18 +1190,18 @@ func describeReplicaSet(rs *extensions.ReplicaSet, events *api.EventList, runnin
// JobDescriber generates information about a job and the pods it has created.
type JobDescriber struct {
client *client.Client
client.Interface
}
func (d *JobDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
job, err := d.client.Extensions().Jobs(namespace).Get(name)
job, err := d.Batch().Jobs(namespace).Get(name)
if err != nil {
return "", err
}
var events *api.EventList
if describerSettings.ShowEvents {
events, _ = d.client.Events(namespace).Search(job)
events, _ = d.Events(namespace).Search(job)
}
return describeJob(job, events)
@ -1194,6 +1236,92 @@ func describeJob(job *batch.Job, events *api.EventList) (string, error) {
})
}
// ScheduledJobDescriber generates information about a scheduled job and the jobs it has created.
type ScheduledJobDescriber struct {
clientset.Interface
}
func (d *ScheduledJobDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
scheduledJob, err := d.Batch().ScheduledJobs(namespace).Get(name)
if err != nil {
return "", err
}
var events *api.EventList
if describerSettings.ShowEvents {
events, _ = d.Core().Events(namespace).Search(scheduledJob)
}
return describeScheduledJob(scheduledJob, events)
}
func describeScheduledJob(scheduledJob *batch.ScheduledJob, events *api.EventList) (string, error) {
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", scheduledJob.Name)
fmt.Fprintf(out, "Namespace:\t%s\n", scheduledJob.Namespace)
fmt.Fprintf(out, "Schedule:\t%s\n", scheduledJob.Spec.Schedule)
fmt.Fprintf(out, "Concurrency Policy:\t%s\n", scheduledJob.Spec.ConcurrencyPolicy)
fmt.Fprintf(out, "Suspend:\t%s\n", printBoolPtr(scheduledJob.Spec.Suspend))
if scheduledJob.Spec.StartingDeadlineSeconds != nil {
fmt.Fprintf(out, "Starting Deadline Seconds:\t%ds\n", *scheduledJob.Spec.StartingDeadlineSeconds)
} else {
fmt.Fprintf(out, "Starting Deadline Seconds:\t<unset>\n")
}
describeJobTemplate(scheduledJob.Spec.JobTemplate, out)
printLabelsMultiline(out, "Labels", scheduledJob.Labels)
if scheduledJob.Status.LastScheduleTime != nil {
fmt.Fprintf(out, "Last Schedule Time:\t%s\n", scheduledJob.Status.LastScheduleTime.Time.Format(time.RFC1123Z))
} else {
fmt.Fprintf(out, "Last Schedule Time:\t<unset>\n")
}
printActiveJobs(out, "Active Jobs", scheduledJob.Status.Active)
if events != nil {
DescribeEvents(events, out)
}
return nil
})
}
func describeJobTemplate(jobTemplate batch.JobTemplateSpec, out io.Writer) {
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&jobTemplate.Spec.Template.Spec))
if jobTemplate.Spec.Selector != nil {
selector, _ := unversioned.LabelSelectorAsSelector(jobTemplate.Spec.Selector)
fmt.Fprintf(out, "Selector:\t%s\n", selector)
} else {
fmt.Fprintf(out, "Selector:\t<unset>\n")
}
if jobTemplate.Spec.Parallelism != nil {
fmt.Fprintf(out, "Parallelism:\t%d\n", *jobTemplate.Spec.Parallelism)
} else {
fmt.Fprintf(out, "Parallelism:\t<unset>\n")
}
if jobTemplate.Spec.Completions != nil {
fmt.Fprintf(out, "Completions:\t%d\n", *jobTemplate.Spec.Completions)
} else {
fmt.Fprintf(out, "Completions:\t<unset>\n")
}
if jobTemplate.Spec.ActiveDeadlineSeconds != nil {
fmt.Fprintf(out, "Active Deadline Seconds:\t%ds\n", *jobTemplate.Spec.ActiveDeadlineSeconds)
}
describeVolumes(jobTemplate.Spec.Template.Spec.Volumes, out, "")
}
func printActiveJobs(out io.Writer, title string, jobs []api.ObjectReference) {
fmt.Fprintf(out, "%s:\t", title)
if len(jobs) == 0 {
fmt.Fprintln(out, "<none>")
return
}
for i, job := range jobs {
if i != 0 {
fmt.Fprint(out, ", ")
}
fmt.Fprintf(out, "%s", job.Name)
}
fmt.Fprintln(out, "")
}
// DaemonSetDescriber generates information about a daemon set and the pods it has created.
type DaemonSetDescriber struct {
client.Interface
@ -1446,6 +1574,12 @@ func describeService(service *api.Service, endpoints *api.Endpoints, events *api
fmt.Fprintf(out, "Selector:\t%s\n", labels.FormatLabels(service.Spec.Selector))
fmt.Fprintf(out, "Type:\t%s\n", service.Spec.Type)
fmt.Fprintf(out, "IP:\t%s\n", service.Spec.ClusterIP)
if len(service.Spec.ExternalIPs) > 0 {
fmt.Fprintf(out, "External IPs:\t%v\n", strings.Join(service.Spec.ExternalIPs, ","))
}
if service.Spec.ExternalName != "" {
fmt.Fprintf(out, "External Name:\t%s\n", service.Spec.ExternalName)
}
if len(service.Status.LoadBalancer.Ingress) > 0 {
list := buildIngressString(service.Status.LoadBalancer.Ingress)
fmt.Fprintf(out, "LoadBalancer Ingress:\t%s\n", list)
@ -1787,6 +1921,74 @@ func (p *PetSetDescriber) Describe(namespace, name string, describerSettings Des
})
}
type CertificateSigningRequestDescriber struct {
client *client.Client
}
func (p *CertificateSigningRequestDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
csr, err := p.client.Certificates().CertificateSigningRequests().Get(name)
if err != nil {
return "", err
}
cr, err := utilcertificates.ParseCertificateRequestObject(csr)
if err != nil {
return "", fmt.Errorf("Error parsing CSR: %v", err)
}
status, err := extractCSRStatus(csr)
if err != nil {
return "", err
}
printListHelper := func(out io.Writer, prefix, name string, values []string) {
if len(values) == 0 {
return
}
fmt.Fprintf(out, prefix+name+":\t")
fmt.Fprintf(out, strings.Join(values, "\n"+prefix+"\t"))
fmt.Fprintf(out, "\n")
}
return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", csr.Name)
fmt.Fprintf(out, "Labels:\t%s\n", labels.FormatLabels(csr.Labels))
fmt.Fprintf(out, "Annotations:\t%s\n", labels.FormatLabels(csr.Annotations))
fmt.Fprintf(out, "CreationTimestamp:\t%s\n", csr.CreationTimestamp.Time.Format(time.RFC1123Z))
fmt.Fprintf(out, "Requesting User:\t%s\n", csr.Spec.Username)
fmt.Fprintf(out, "Status:\t%s\n", status)
fmt.Fprintf(out, "Subject:\n")
fmt.Fprintf(out, "\tCommon Name:\t%s\n", cr.Subject.CommonName)
fmt.Fprintf(out, "\tSerial Number:\t%s\n", cr.Subject.SerialNumber)
printListHelper(out, "\t", "Organization", cr.Subject.Organization)
printListHelper(out, "\t", "Organizational Unit", cr.Subject.OrganizationalUnit)
printListHelper(out, "\t", "Country", cr.Subject.Country)
printListHelper(out, "\t", "Locality", cr.Subject.Locality)
printListHelper(out, "\t", "Province", cr.Subject.Province)
printListHelper(out, "\t", "StreetAddress", cr.Subject.StreetAddress)
printListHelper(out, "\t", "PostalCode", cr.Subject.PostalCode)
if len(cr.DNSNames)+len(cr.EmailAddresses)+len(cr.IPAddresses) > 0 {
fmt.Fprintf(out, "Subject Alternative Names:\n")
printListHelper(out, "\t", "DNS Names", cr.DNSNames)
printListHelper(out, "\t", "Email Addresses", cr.EmailAddresses)
var ipaddrs []string
for _, ipaddr := range cr.IPAddresses {
ipaddrs = append(ipaddrs, ipaddr.String())
}
printListHelper(out, "\t", "IP Addresses", ipaddrs)
}
if describerSettings.ShowEvents {
events, _ := p.client.Events(namespace).Search(csr)
if events != nil {
DescribeEvents(events, out)
}
}
return nil
})
}
// HorizontalPodAutoscalerDescriber generates information about a horizontal pod autoscaler.
type HorizontalPodAutoscalerDescriber struct {
client *client.Client
@ -2366,14 +2568,64 @@ func printTaintsMultilineWithIndent(out io.Writer, initialIndent, title, innerIn
}
sort.Strings(keys)
effects := []api.TaintEffect{api.TaintEffectNoSchedule, api.TaintEffectPreferNoSchedule}
for i, key := range keys {
for _, taint := range taints {
if taint.Key == key {
for _, effect := range effects {
for _, taint := range taints {
if taint.Key == key && taint.Effect == effect {
if i != 0 {
fmt.Fprint(out, initialIndent)
fmt.Fprint(out, innerIndent)
}
fmt.Fprintf(out, "%s=%s:%s\n", taint.Key, taint.Value, taint.Effect)
i++
}
}
}
}
}
// printTolerationsMultiline prints multiple tolerations with a proper alignment.
func printTolerationsInAnnotationMultiline(out io.Writer, title string, annotations map[string]string) {
tolerations, err := api.GetTolerationsFromPodAnnotations(annotations)
if err != nil {
tolerations = []api.Toleration{}
}
printTolerationsMultilineWithIndent(out, "", title, "\t", tolerations)
}
// printTolerationsMultilineWithIndent prints multiple tolerations with a user-defined alignment.
func printTolerationsMultilineWithIndent(out io.Writer, initialIndent, title, innerIndent string, tolerations []api.Toleration) {
fmt.Fprintf(out, "%s%s:%s", initialIndent, title, innerIndent)
if tolerations == nil || len(tolerations) == 0 {
fmt.Fprintln(out, "<none>")
return
}
// to print tolerations in the sorted order
keys := make([]string, 0, len(tolerations))
for _, toleration := range tolerations {
keys = append(keys, toleration.Key)
}
sort.Strings(keys)
for i, key := range keys {
for _, toleration := range tolerations {
if toleration.Key == key {
if i != 0 {
fmt.Fprint(out, initialIndent)
fmt.Fprint(out, innerIndent)
}
fmt.Fprintf(out, "%s=%s:%s\n", taint.Key, taint.Value, taint.Effect)
fmt.Fprintf(out, "%s=%s", toleration.Key, toleration.Value)
if len(toleration.Operator) != 0 {
fmt.Fprintf(out, ":%s", toleration.Operator)
}
if len(toleration.Effect) != 0 {
fmt.Fprintf(out, ":%s", toleration.Effect)
}
fmt.Fprintf(out, "\n")
i++
}
}