kubernetes

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationSpinnakerArtifactLocation   = `artifact.spinnaker.io/location`
	AnnotationSpinnakerArtifactName       = `artifact.spinnaker.io/name`
	AnnotationSpinnakerArtifactType       = `artifact.spinnaker.io/type`
	AnnotationSpinnakerMonikerApplication = `moniker.spinnaker.io/application`
	AnnotationSpinnakerMonikerCluster     = `moniker.spinnaker.io/cluster`
	AnnotationSpinnakerStrategyVersioned  = `strategy.spinnaker.io/versioned`
)
View Source
const (
	// https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
	LabelKubernetesName           = `app.kubernetes.io/name`
	LabelKubernetesManagedBy      = `app.kubernetes.io/managed-by`
	LabelSpinnakerMonikerSequence = `moniker.spinnaker.io/sequence`
)
View Source
const (
	// https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
	AnnotationSpinnakerArtifactVersion = `artifact.spinnaker.io/version`
	AnnotationSpinnakerMonikerSequence = `moniker.spinnaker.io/sequence`
)
View Source
const (
	ControllerInstanceKey = `KubeController`
)

Variables

This section is empty.

Functions

func AddSpinnakerAnnotations

func AddSpinnakerAnnotations(u *unstructured.Unstructured, application string) error

AddSpinnakerAnnotations adds Spinnaker-defined annotations to a given unstructured resource.

func AddSpinnakerLabels

func AddSpinnakerLabels(u *unstructured.Unstructured, application string) error

AddSpinnakerLabels labels a given unstructured Kubernetes resource with Spinnaker defined labels.

func AddSpinnakerVersionAnnotations

func AddSpinnakerVersionAnnotations(u *unstructured.Unstructured, version SpinnakerVersion) error

AddSpinnakerVersionAnnotations adds the following annotations: `artifact.spinnaker.io/version` `moniker.spinnaker.io/sequence` to the manifest to identify the version number of that resource.

func AddSpinnakerVersionLabels

func AddSpinnakerVersionLabels(u *unstructured.Unstructured, version SpinnakerVersion) error

AddSpinnakerVersionLabels adds the `moniker.spinnaker.io/sequence` label to the manifest to identify the version number of that resource.

func AnnotateTemplate

func AnnotateTemplate(u *unstructured.Unstructured, key, value string) error

AnnotateTemplate annotates the nested string map located at .spec.template.metadata.annotations.

func GetCurrentVersion

func GetCurrentVersion(ul *unstructured.UnstructuredList, kind, name string) string

GetCurrentVersion returns the latest "Spinnaker version" from an unstructured list of Kubernetes resources.

func IsVersioned

func IsVersioned(u unstructured.Unstructured) bool

IsVersioned returns true is a given Kubernetes unstructured resource is "versioned". A resource is version if its annotation `strategy.spinnaker.io/versioned` is set to "true" or if it is of kind Pod, ReplicaSet, ConfigMap, or Secret.

See https://spinnaker.io/reference/providers/kubernetes-v2/#workloads for more info.

func NewRequirement

func NewRequirement(op string, key string, values []string) (*labels.Requirement, error)

func SetDefaultNamespaceIfScopedAndNoneSet

func SetDefaultNamespaceIfScopedAndNoneSet(u *unstructured.Unstructured, helper *resource.Helper)

func SetNamespaceIfScoped

func SetNamespaceIfScoped(namespace string, u *unstructured.Unstructured, helper *resource.Helper)

func SortManifests

func SortManifests(manifests []unstructured.Unstructured) []unstructured.Unstructured

SortManifests takes in a list of manifests and sorts them by the priority of their kind. The kind's priorities are defined above in the var 'priorities'. Lower numbered priorities should be deployed first.

func ToUnstructured

func ToUnstructured(manifest map[string]interface{}) (unstructured.Unstructured, error)

ToUnstructured converts a map[string]interface{} to a kubernetes unstructured.Unstructured object. An unstructured's "Object" field is technically just a map[string]interface{}, so we could do the following:

return unstructured.Unstructured{ Object: manifest }

and not have this function return an error, but we miss out on some validation that happens during `kubectl`, such as when you attempt to apply a bad manifest, like something without "kind" specified. Example:

$ k apply -f bad.yaml --validate=false error: unable to decode "bad.yaml": Object 'Kind' is missing in '{}'

If we decide to not cycle through the encoding/decoding process, these errors will be deferred to when the manifest gets applied, and will fail with some error like

error applying manifest (kind: , apiVersion: v1, name: bad-gke): no matches for kind "" in version "apps/v1"

For now, we are not deferring the error.

Types

type Clientset

type Clientset interface {
	PodLogs(string, string, string) (string, error)
}

type Controller

type Controller interface {
	NewClient(*rest.Config) (Client, error)
	NewClientset(*rest.Config) (Clientset, error)
}

Controller holds the ability to generate a new dynamic kubernetes client.

func ControllerInstance

func ControllerInstance(c *gin.Context) Controller

func NewController

func NewController() Controller

NewController returns an instance of Controller.

type DaemonSet

type DaemonSet struct {
	// contains filtered or unexported fields
}

func NewDaemonSet

func NewDaemonSet(m map[string]interface{}) *DaemonSet

func (*DaemonSet) Object

func (ds *DaemonSet) Object() *v1.DaemonSet

func (*DaemonSet) Status

func (ds *DaemonSet) Status() manifest.Status

type Deployment

type Deployment struct {
	// contains filtered or unexported fields
}

func NewDeployment

func NewDeployment(m map[string]interface{}) *Deployment

func (*Deployment) Object

func (d *Deployment) Object() *v1.Deployment

func (*Deployment) Status

func (d *Deployment) Status() manifest.Status

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	// contains filtered or unexported fields
}

func NewHorizontalPodAutoscaler

func NewHorizontalPodAutoscaler(m map[string]interface{}) *HorizontalPodAutoscaler

func (*HorizontalPodAutoscaler) Object

func (*HorizontalPodAutoscaler) Status

func (hpa *HorizontalPodAutoscaler) Status() manifest.Status

type Job

type Job struct {
	// contains filtered or unexported fields
}

func NewJob

func NewJob(m map[string]interface{}) *Job

func (*Job) Object

func (j *Job) Object() *v1.Job

func (*Job) Status

func (j *Job) Status() manifest.Status

type ManifestFilter

type ManifestFilter struct {
	// contains filtered or unexported fields
}

func NewManifestFilter

func NewManifestFilter(items []unstructured.Unstructured) *ManifestFilter

func (*ManifestFilter) FilterOnClusterAnnotation

func (f *ManifestFilter) FilterOnClusterAnnotation(cluster string) []unstructured.Unstructured

func (*ManifestFilter) FilterOnLabel

func (f *ManifestFilter) FilterOnLabel(label string) []unstructured.Unstructured

type Metadata

type Metadata struct {
	Name      string
	Namespace string
	Group     string
	Version   string
	Resource  string
	Kind      string
}

type Pod

type Pod struct {
	// contains filtered or unexported fields
}

func NewPod

func NewPod(m map[string]interface{}) *Pod

func (*Pod) Object

func (p *Pod) Object() *v1.Pod

func (*Pod) Status

func (p *Pod) Status() manifest.Status

type Provider

type Provider struct {
	Name          string              `json:"name" gorm:"primary_key"`
	Host          string              `json:"host"`
	CAData        string              `json:"caData" gorm:"size:8192"`
	BearerToken   string              `json:"bearerToken,omitempty" gorm:"size:2048"`
	TokenProvider string              `json:"tokenProvider,omitempty" gorm:"size:32;not null;default:'google'"`
	Permissions   ProviderPermissions `json:"permissions" gorm:"-"`
}

func (Provider) TableName

func (Provider) TableName() string

type ProviderPermissions

type ProviderPermissions struct {
	Read  []string `json:"read" gorm:"-"`
	Write []string `json:"write" gorm:"-"`
}

type ReplicaSet

type ReplicaSet struct {
	// contains filtered or unexported fields
}

func NewReplicaSet

func NewReplicaSet(m map[string]interface{}) *ReplicaSet

func (*ReplicaSet) Object

func (rs *ReplicaSet) Object() *v1.ReplicaSet

func (*ReplicaSet) Status

func (rs *ReplicaSet) Status() manifest.Status

type Resource

type Resource struct {
	AccountName  string    `json:"accountName"`
	ID           string    `json:"id" gorm:"primary_key"`
	Timestamp    time.Time `json:"timestamp,omitempty" gorm:"type:timestamp;DEFAULT:current_timestamp"`
	TaskID       string    `json:"taskId"`
	TaskType     string    `json:"-"`
	APIGroup     string    `json:"apiGroup"`
	Name         string    `json:"name"`
	ArtifactName string    `json:"_"`
	Namespace    string    `json:"namespace"`
	Resource     string    `json:"resource"`
	Version      string    `json:"version"`
	Kind         string    `json:"kind"`
	SpinnakerApp string    `json:"spinnakerApp"`
	Cluster      string    `json:"-"`
}

func (Resource) TableName

func (Resource) TableName() string

type SpinnakerVersion

type SpinnakerVersion struct {
	Long  string
	Short string
}

func IncrementVersion

func IncrementVersion(currentVersion string) SpinnakerVersion

type StatefulSet

type StatefulSet struct {
	// contains filtered or unexported fields
}

func NewStatefulSet

func NewStatefulSet(m map[string]interface{}) *StatefulSet

func (*StatefulSet) Object

func (ss *StatefulSet) Object() *v1.StatefulSet

func (*StatefulSet) Status

func (ss *StatefulSet) Status() manifest.Status

Directories

Path Synopsis
cached
disk/diskfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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