common

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareLabels added in v1.1.0

func CompareLabels(source map[string]string, target map[string]string) bool

Types

type Endpoint added in v1.3.0

type Endpoint struct {
	// Hostname, either as a domain name or IP address.
	Host string `json:"host"`

	// List of ports opened for this endpoint on the hostname.
	Ports []ServicePort `json:"ports"`
}

Endpoint describes an endpoint that is host and a list of available ports for that host.

func GetExternalEndpoints added in v1.3.0

func GetExternalEndpoints(service *api.Service) []Endpoint

GetExternalEndpoints returns endpoints that are externally reachable for a service.

func GetInternalEndpoint added in v1.3.0

func GetInternalEndpoint(serviceName, namespace string, ports []api.ServicePort) Endpoint

GetInternalEndpoint returns internal endpoint name for the given service properties, e.g., "my-service.namespace 80/TCP" or "my-service 53/TCP,53/UDP".

type Event

type Event struct {
	ObjectMeta ObjectMeta `json:"objectMeta"`
	TypeMeta   TypeMeta   `json:"typeMeta"`

	// A human-readable description of the status of related object.
	Message string `json:"message"`

	// Component from which the event is generated.
	SourceComponent string `json:"sourceComponent"`

	Name string `json:"name"`

	// Reference to a piece of an object, which triggered an event. For example
	// "spec.containers{name}" refers to container within pod with given name, if no container
	// name is specified, for example "spec.containers[2]", then it refers to container with
	// index 2 in this pod.
	SubObject string `json:"object"`

	// The number of times this event has occurred.
	Count int32 `json:"count"`

	// The time at which the event was first recorded.
	FirstSeen v1.Time `json:"firstSeen"`

	// The time at which the most recent occurrence of this event was recorded.
	LastSeen v1.Time `json:"lastSeen"`

	// Short, machine understandable string that gives the reason
	// for this event being generated.
	Reason string `json:"reason"`

	// Event type (at the moment only normal and warning are supported).
	Type string `json:"type"`
}

Event is a single event representation.

type JobInfo

type JobInfo struct {
	// The number of actively running pods.
	// +optional
	Active int32 `json:"active,omitempty"`

	// The number of pods which reached phase Succeeded.
	// +optional
	Succeeded int32 `json:"succeeded,omitempty"`

	// The number of pods which reached phase Failed.
	// +optional
	Failed int32 `json:"failed,omitempty"`
}

type Object added in v1.3.0

type Object struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// for endpoint only
	Subsets interface{} `json:"subsets,omitempty"`
	// for secret and configmap
	Type interface{} `json:"type,omitempty"`
	Data interface{} `json:"data,omitempty"`

	Spec   interface{} `json:"spec,omitempty"`
	Status interface{} `json:"status,omitempty"`
}

TODO convert runtime.Object to real type for common kubernetes Object

type ObjectMeta

type ObjectMeta struct {
	// Name is unique within a namespace. Name is primarily intended for creation
	// idempotence and configuration definition.
	Name string `json:"name,omitempty"`

	// Namespace defines the space within which name must be unique. An empty namespace is
	// equivalent to the "default" namespace, but "default" is the canonical representation.
	// Not all objects are required to be scoped to a namespace - the value of this field for
	// those objects will be empty.
	Namespace string `json:"namespace,omitempty"`

	// Labels are key value pairs that may be used to scope and select individual resources.
	// Label keys are of the form:
	//     label-key ::= prefixed-name | name
	//     prefixed-name ::= prefix '/' name
	//     prefix ::= DNS_SUBDOMAIN
	//     name ::= DNS_LABEL
	// The prefix is optional.  If the prefix is not specified, the key is assumed to be private
	// to the user.  Other system components that wish to use labels must specify a prefix.
	Labels map[string]string `json:"labels,omitempty"`

	// Annotations are unstructured key value data stored with a resource that may be set by
	// external tooling. They are not queryable and should be preserved when modifying
	// objects.  Annotation keys have the same formatting restrictions as Label keys. See the
	// comments on Labels for details.
	Annotations map[string]string `json:"annotations,omitempty"`

	// CreationTimestamp is a timestamp representing the server time when this object was
	// created. It is not guaranteed to be set in happens-before order across separate operations.
	// Clients may not set this value. It is represented in RFC3339 form and is in UTC.
	CreationTimestamp metaV1.Time `json:"creationTimestamp,omitempty"`
}

ObjectMeta is metadata about an instance of a resource.

func NewObjectMeta

func NewObjectMeta(k8SObjectMeta metaV1.ObjectMeta) ObjectMeta

NewObjectMeta returns internal endpoint name for the given service properties, e.g., NewObjectMeta creates a new instance of ObjectMeta struct based on K8s object meta.

type PodInfo

type PodInfo struct {
	// Number of pods that are created.
	Current int32 `json:"current"`

	// Number of pods that are desired.
	Desired int32 `json:"desired"`

	// Number of pods that are currently running.
	Running int32 `json:"running"`

	// Number of pods that are currently waiting.
	Pending int32 `json:"pending"`

	// Number of pods that are failed.
	Failed int32 `json:"failed"`

	// Number of pods that are succeeded.
	Succeeded int32 `json:"succeeded"`

	// Unique warning messages related to pods in this resource.
	Warnings []Event `json:"warnings,omitempty"`
}

PodInfo represents aggregate information about controller's pods.

type Resource

type Resource struct {
	Usage *ResourceList `json:"usage"`
	Limit *ResourceList `json:"limit"`
}

type ResourceApp

type ResourceApp struct {
	Cpu    int64 `json:"cpu"`
	Memory int64 `json:"memory"`
	PodNum int64 `json:"pod_num"`
}

type ResourceKind

type ResourceKind string

ResourceKind is an unique name for each resource. It can used for API discovery and generic code that does things based on the kind. For example, there may be a generic "deleter" that based on resource kind, name and namespace deletes it.

type ResourceList

type ResourceList struct {
	Cpu    int64 `json:"cpu"`
	Memory int64 `json:"memory"`
}

func ContainersRequestResourceList added in v1.3.1

func ContainersRequestResourceList(containers []v1.Container) *ResourceList

func ContainersResourceList

func ContainersResourceList(containers []v1.Container) *ResourceList

func DeploymentResourceList

func DeploymentResourceList(deployment *v1beta1.Deployment) *ResourceList

func StatefulsetResourceList

func StatefulsetResourceList(statefulSet *v1beta1.StatefulSet) *ResourceList

type ServicePort added in v1.3.0

type ServicePort struct {
	// Positive port number.
	Port int32 `json:"port"`

	// Protocol name, e.g., TCP or UDP.
	Protocol api.Protocol `json:"protocol"`

	// The port on each node on which service is exposed.
	NodePort int32 `json:"nodePort"`
}

ServicePort is a pair of port and protocol, e.g. a service endpoint.

func GetServicePorts added in v1.3.0

func GetServicePorts(apiPorts []api.ServicePort) []ServicePort

GetServicePorts returns human readable name for the given service ports list.

type TypeMeta

type TypeMeta struct {
	// Kind is a string value representing the REST resource this object represents.
	// Servers may infer this from the endpoint the client submits requests to.
	// In smalllettercase.
	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
	Kind ResourceKind `json:"kind,omitempty"`
}

TypeMeta describes an individual object in an API response or request with strings representing the type of the object.

func NewTypeMeta added in v1.3.0

func NewTypeMeta(kind ResourceKind) TypeMeta

NewTypeMeta creates new type mete for the resource kind.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL