deployment

package
v2.1.1-0...-11cc7cf Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DescriptionAnnotationKey is annotation key for a description.
	DescriptionAnnotationKey = "description"
)

Variables

This section is empty.

Functions

func DeployApp

func DeployApp(spec *AppDeploymentSpec, client client.Interface) error

DeployApp deploys an app based on the given configuration. The app is deployed using the given client. App deployment consists of a deployment and an optional service. Both of them share common labels.

func DeployAppFromFile

func DeployAppFromFile(cfg *rest.Config, spec *AppDeploymentFromFileSpec) (bool, error)

DeployAppFromFile deploys an app based on the given yaml or json file.

func FindNewReplicaSet

func FindNewReplicaSet(deployment *apps.Deployment, rsList []*apps.ReplicaSet) *apps.ReplicaSet

FindNewReplicaSet returns the new RS this given deployment targets (the one with the same pod template).

func FindOldReplicaSets

func FindOldReplicaSets(deployment *apps.Deployment, rsList []*apps.ReplicaSet) ([]*apps.ReplicaSet,
	[]*apps.ReplicaSet, error)

FindOldReplicaSets returns the old replica sets targeted by the given Deployment, with the given slice of RSes. Note that the first set of old replica sets doesn't include the ones with no pods, and the second set of old replica sets include all old replica sets.

func GetDeploymentNewReplicaSet

func GetDeploymentNewReplicaSet(client client.Interface, dsQuery *dataselect.DataSelectQuery,
	namespace string, deploymentName string) (*replicaset.ReplicaSet, error)

GetDeploymentNewReplicaSet returns old replica sets targeting Deployment with given name

func GetDeploymentOldReplicaSets

func GetDeploymentOldReplicaSets(client client.Interface, dsQuery *dataselect.DataSelectQuery,
	namespace string, deploymentName string) (*replicaset.ReplicaSetList, error)

GetDeploymentOldReplicaSets returns old replica sets targeting Deployment with given name

func GetDeploymentPods

func GetDeploymentPods(client client.Interface, metricClient metricapi.MetricClient,
	dsQuery *dataselect.DataSelectQuery, namespace, deploymentName string) (*pod.PodList, error)

GetDeploymentPods returns list of pods targeting deployment.

func GetNewReplicaSetTemplate

func GetNewReplicaSetTemplate(deployment *apps.Deployment) v1.PodTemplateSpec

GetNewReplicaSetTemplate returns the desired PodTemplateSpec for the new ReplicaSet corresponding to the given ReplicaSet. Callers of this helper need to set the DefaultDeploymentUniqueLabelKey k/v pair.

Types

type AppDeploymentFromFileResponse

type AppDeploymentFromFileResponse struct {
	// Name of the file
	Name string `json:"name"`

	// File content
	Content string `json:"content"`

	// Error after create resource
	Error string `json:"error"`
}

AppDeploymentFromFileResponse is a specification for deployment from file

type AppDeploymentFromFileSpec

type AppDeploymentFromFileSpec struct {
	// Name of the file
	Name string `json:"name"`

	// Namespace that object should be deployed in
	Namespace string `json:"namespace"`

	// File content
	Content string `json:"content"`

	// Whether validate content before creation or not
	Validate bool `json:"validate"`
}

AppDeploymentFromFileSpec is a specification for deployment from file

type AppDeploymentSpec

type AppDeploymentSpec struct {
	// Name of the application.
	Name string `json:"name"`

	// Docker image path for the application.
	ContainerImage string `json:"containerImage"`

	// The name of an image pull secret in case of a private docker repository.
	ImagePullSecret *string `json:"imagePullSecret"`

	// Command that is executed instead of container entrypoint, if specified.
	ContainerCommand *string `json:"containerCommand"`

	// Arguments for the specified container command or container entrypoint (if command is not
	// specified here).
	ContainerCommandArgs *string `json:"containerCommandArgs"`

	// Number of replicas of the image to maintain.
	Replicas int32 `json:"replicas"`

	// Port mappings for the service that is created. The service is created if there is at least
	// one port mapping.
	PortMappings []PortMapping `json:"portMappings"`

	// List of user-defined environment variables.
	Variables []EnvironmentVariable `json:"variables"`

	// Whether the created service is external.
	IsExternal bool `json:"isExternal"`

	// Description of the deployment.
	Description *string `json:"description"`

	// Target namespace of the application.
	Namespace string `json:"namespace"`

	// Optional memory requirement for the container.
	MemoryRequirement *resource.Quantity `json:"memoryRequirement"`

	// Optional CPU requirement for the container.
	CpuRequirement *resource.Quantity `json:"cpuRequirement"`

	// Labels that will be defined on Pods/RCs/Services
	Labels []Label `json:"labels"`

	// Whether to run the container as privileged user (essentially equivalent to root on the host).
	RunAsPrivileged bool `json:"runAsPrivileged"`
}

AppDeploymentSpec is a specification for an app deployment.

type Deployment

type Deployment struct {
	ObjectMeta api.ObjectMeta `json:"objectMeta"`
	TypeMeta   api.TypeMeta   `json:"typeMeta"`

	// Aggregate information about pods belonging to this Deployment.
	Pods common.PodInfo `json:"pods"`

	// Container images of the Deployment.
	ContainerImages []string `json:"containerImages"`

	// Init Container images of the Deployment.
	InitContainerImages []string `json:"initContainerImages"`
}

Deployment is a presentation layer view of Kubernetes Deployment resource. This means it is Deployment plus additional augmented data we can get from other sources (like services that target the same pods).

type DeploymentCell

type DeploymentCell apps.Deployment

func (DeploymentCell) GetProperty

GetProperty is used to get property of the deployment

func (DeploymentCell) GetResourceSelector

func (self DeploymentCell) GetResourceSelector() *metricapi.ResourceSelector

type DeploymentDetail

type DeploymentDetail struct {
	// Extends list item structure.
	Deployment `json:",inline"`

	// Label selector of the service.
	Selector map[string]string `json:"selector"`

	// Status information on the deployment
	StatusInfo `json:"statusInfo"`

	// Conditions describe the state of a deployment at a certain point.
	Conditions []common.Condition `json:"conditions"`

	// The deployment strategy to use to replace existing pods with new ones.
	// Valid options: Recreate, RollingUpdate
	Strategy apps.DeploymentStrategyType `json:"strategy"`

	// Min ready seconds
	MinReadySeconds int32 `json:"minReadySeconds"`

	// Rolling update strategy containing maxSurge and maxUnavailable
	RollingUpdateStrategy *RollingUpdateStrategy `json:"rollingUpdateStrategy,omitempty"`

	// Optional field that specifies the number of old Replica Sets to retain to allow rollback.
	RevisionHistoryLimit *int32 `json:"revisionHistoryLimit"`

	// List of non-critical errors, that occurred during resource retrieval.
	Errors []error `json:"errors"`
}

DeploymentDetail is a presentation layer view of Kubernetes Deployment resource.

func GetDeploymentDetail

func GetDeploymentDetail(client client.Interface, namespace string, deploymentName string) (*DeploymentDetail, error)

GetDeploymentDetail returns model object of deployment and error, if any.

type DeploymentList

type DeploymentList struct {
	ListMeta          api.ListMeta       `json:"listMeta"`
	CumulativeMetrics []metricapi.Metric `json:"cumulativeMetrics"`

	// Basic information about resources status on the list.
	Status common.ResourceStatus `json:"status"`

	// Unordered list of Deployments.
	Deployments []Deployment `json:"deployments"`

	// List of non-critical errors, that occurred during resource retrieval.
	Errors []error `json:"errors"`
}

DeploymentList contains a list of Deployments in the cluster.

func GetDeploymentList

func GetDeploymentList(client client.Interface, nsQuery *common.NamespaceQuery, dsQuery *dataselect.DataSelectQuery,
	metricClient metricapi.MetricClient) (*DeploymentList, error)

GetDeploymentList returns a list of all Deployments in the cluster.

func GetDeploymentListFromChannels

func GetDeploymentListFromChannels(channels *common.ResourceChannels, dsQuery *dataselect.DataSelectQuery,
	metricClient metricapi.MetricClient) (*DeploymentList, error)

GetDeploymentListFromChannels returns a list of all Deployments in the cluster reading required resource list once from the channels.

type EnvironmentVariable

type EnvironmentVariable struct {
	// Name of the variable. Must be a C_IDENTIFIER.
	Name string `json:"name"`

	// Value of the variable, as defined in Kubernetes core API.
	Value string `json:"value"`
}

EnvironmentVariable represents a named variable accessible for containers.

type Label

type Label struct {
	// Label key
	Key string `json:"key"`

	// Label value
	Value string `json:"value"`
}

Label is a structure representing label assignable to Pod/RC/Service

type PortMapping

type PortMapping struct {
	// Port that will be exposed on the service.
	Port int32 `json:"port"`

	// Docker image path for the application.
	TargetPort int32 `json:"targetPort"`

	// IP protocol for the mapping, e.g., "TCP" or "UDP".
	Protocol api.Protocol `json:"protocol"`
}

PortMapping is a specification of port mapping for an application deployment.

type Protocols

type Protocols struct {
	// Array containing supported protocol types e.g., ["TCP", "UDP"]
	Protocols []api.Protocol `json:"protocols"`
}

Protocols is a structure representing supported protocol types for a service

func GetAvailableProtocols

func GetAvailableProtocols() *Protocols

GetAvailableProtocols returns list of available protocols. Currently it is TCP and UDP.

type RollingUpdateStrategy

type RollingUpdateStrategy struct {
	MaxSurge       *intstr.IntOrString `json:"maxSurge"`
	MaxUnavailable *intstr.IntOrString `json:"maxUnavailable"`
}

RollingUpdateStrategy is behavior of a rolling update. See RollingUpdateDeployment K8s object.

type StatusInfo

type StatusInfo struct {
	// Total number of desired replicas on the deployment
	Replicas int32 `json:"replicas"`

	// Number of non-terminated pods that have the desired template spec
	Updated int32 `json:"updated"`

	// Number of available pods (ready for at least minReadySeconds)
	// targeted by this deployment
	Available int32 `json:"available"`

	// Total number of unavailable pods targeted by this deployment.
	Unavailable int32 `json:"unavailable"`
}

StatusInfo is the status information of the deployment

func GetStatusInfo

func GetStatusInfo(deploymentStatus *apps.DeploymentStatus) StatusInfo

GetStatusInfo is used to get the status information from the *apps.DeploymentStatus

Jump to

Keyboard shortcuts

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