v1alpha1

package
v0.6.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KoliPrefixValue    = "kolihub.io"
	ReleaseExpireAfter = 20
)

KoliPrefixValue is used for creating annotations and labels

View Source
const (
	// BrokerSystemNamespace is the portion name of a system namespace of the broker.
	// E.g.: system-[customer]-[org]
	BrokerSystemNamespace = "system"

	// BrokerSystemCustomer is the portion name of a system namespace of the broker.
	// E.g.: [namespace]-org-[org]
	BrokerSystemCustomer = "org"
	// GitRepositoryPathPrefix is used to construct the URL path of the repositories
	GitRepositoryPathPrefix = "repos"
	// GitReleasesPathPrefix is used to construct the URL path of the releases
	GitReleasesPathPrefix = "releases"
)
View Source
const (
	// GroupName is the group name use in this package
	GroupName = "platform.koli.io"
	// SystemNamespace it's where the global resources are persisted
	SystemNamespace = "koli-system"
)
View Source
const (
	// AnnotationNamespaceOwner is a string representing the owner of a namespace
	AnnotationNamespaceOwner = "kolihub.io/owner"
	// AnnotationBuild it's a boolean indicating to start a build, after it start the value
	// must be updated to "false"
	AnnotationBuild = "kolihub.io/build"
	// AnnotationBuildRevision is a integer indicating the revision for each new builds, MUST be incremented on
	// each new build
	AnnotationBuildRevision = "kolihub.io/buildrevision"
	// AnnotationAutoDeploy boolean indicating to deploy a new app after the build
	AnnotationAutoDeploy = "kolihub.io/autodeploy" // DEPRECATED
	// AnnotationGitRepository it's a string holding information about the name of the repository, e.g.: owner/repository
	AnnotationGitRepository = "kolihub.io/gitrepository"
	// AnnotationGitRemote it's a string containing information about the remote git repository, e.g.: https://github.com/kolihub/koli
	AnnotationGitRemote = "kolihub.io/gitremote"
	// AnnotationGitRevision it's a string SHA refering to a commit
	AnnotationGitRevision = "kolihub.io/gitrevision"
	// AnnotationGitBranch is the name of the branch to accept webhook requests
	AnnotationGitBranch = "kolihub.io/gitbranch"
	// AnnotationAuthToken it's a string credential to communication with the release server
	AnnotationAuthToken = "kolihub.io/authtoken"
	// AnnotationBuildSource it's the source of the request which triggered the build: github (webhook), local, gitstep, etc
	AnnotationBuildSource = "kolihub.io/source"

	// AnnotationGitCompare information comparing the last commit with the current one
	// https://help.github.com/articles/comparing-commits-across-time/
	AnnotationGitCompare = "kolihub.io/gitcompare"
	// AnnotationGitHubSecretHook contains the webhook secret for validating requests
	AnnotationGitHubSecretHook = "kolihub.io/hook-secret"
	// AnnotationGitHubUser refers to the user who connected the repository
	// the access token of this user will be used to query the GitHub api
	AnnotationGitHubUser = "kolihub.io/gituser"
	// AnnotationSetupStorage it's a boolean indicating to setup the storage onto resources (deploy, statefulset),
	// after the setup finished the value must be turned to "false"
	AnnotationSetupStorage = "kolihub.io/setup-storage"
	// AnnotationApp is used to identify the deployment from a parent resource
	AnnotationApp = "kolihub.io/app"
)
View Source
const (
	// LabelAllowKongTraffic is a key which accepts a boolean string to enable/disable network traffic
	// flow between the kong namespace and all namespaces that has this annotation.
	LabelAllowKongTraffic = "kolihub.io/allow-kong-traffic"
	// LabelCustomer it's a string representing the name of the customer in the platform
	LabelCustomer = "kolihub.io/customer"
	// LabelOrganization it's a string representing the name of the organization in the platform
	LabelOrganization = "kolihub.io/org"
	// LabelClusterPlan refers to the specified plan of the resource (statefulset, deployment)
	LabelClusterPlan = "kolihub.io/clusterplan"
	// LabelStoragePlan refers to the specified storage plan of the resource (statefulset, deployment)
	LabelStoragePlan = "kolihub.io/storage-plan"
	// LabelDefault indicates a resource as default (boolean)
	LabelDefault = "kolihub.io/default"
)
View Source
const (
	// ResourceNamespace , number
	ResourceNamespace api.ResourceName = "namespaces"
)

Variables

View Source
var (
	// SchemeBuilder collects functions that add things to a scheme. It's to allow
	// code to compile without explicitly referencing generated types. You should
	// declare one in each package that will have generated deep copy or conversion
	// functions.
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
	// AddToScheme applies all the stored functions to the scheme. A non-nil error
	// indicates that one function failed and the attempt was abandoned.
	AddToScheme = SchemeBuilder.AddToScheme
)
View Source
var (
	// RoleVerbs are the registered verbs allowed by default in the platform
	RoleVerbs = []string{
		"get", "watch", "list", "exec", "port-forward", "logs", "scale",
		"attach", "create", "describe", "delete", "update",
	}

	// RoleResources are the registered resources allowed by default in the platform
	RoleResources = []string{
		"pods", "deployments", "namespaces", "replicasets",
		"resourcequotas", "horizontalpodautoscalers",
	}
)
View Source
var PlatformRegisteredRoles []PlatformRole

PlatformRegisteredRoles contains all the cluster roles provisioned on the platform

View Source
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}

SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

Functions

func DeploymentDeepCopy

func DeploymentDeepCopy(d *extensions.Deployment) (*extensions.Deployment, error)

DeploymentDeepCopy creates a deep-copy from the specified resource

func GetAddonManagementRule

func GetAddonManagementRule() []rbac.PolicyRule

GetAddonManagementRule returns a policy which enables the management of addons resources

func GetAttachRule

func GetAttachRule() []rbac.PolicyRule

GetAttachRule returns a policy which enables the execution of attach command on pods

func GetAutoScaleRule

func GetAutoScaleRule() []rbac.PolicyRule

GetAutoScaleRule returns a policy which enables the execution of autoscale command on deployments

func GetExecRule

func GetExecRule() []rbac.PolicyRule

GetExecRule returns a policy which enables the execution the exec command on pods

func GetPodManagementRule

func GetPodManagementRule() []rbac.PolicyRule

GetPodManagementRule returns a policy which enables the execution of exec, portforward, autoscale and attach commands

func GetPortForwardRule

func GetPortForwardRule() []rbac.PolicyRule

GetPortForwardRule returns a policy which enables the execution of portforward command on pods

func GetRoles

func GetRoles() []*rbac.ClusterRole

GetRoles returns all the roles used by the platform

func Kind

func Kind(kind string) schema.GroupKind

Kind takes an unqualified kind and returns a Group qualified GroupKind

func NamespaceDeepCopy

func NamespaceDeepCopy(ns *v1.Namespace) (*v1.Namespace, error)

NamespaceDeepCopy creates a deep-copy from a Namespace

func Resource

func Resource(resource string) schema.GroupResource

Resource takes an unqualified resource and returns a Group qualified GroupResource

func StatefulSetDeepCopy

func StatefulSetDeepCopy(petset *v1beta1.StatefulSet) (*v1beta1.StatefulSet, error)

StatefulSetDeepCopy creates a deep-copy from a StatefulSet https://github.com/kubernetes/kubernetes/blob/master/docs/devel/controllers.md

Types

type Addon

type Addon struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AddonSpec `json:"spec"`
}

Addon defines integration with external resources

func (*Addon) GetImage

func (a *Addon) GetImage() string

GetImage gets the BaseImage + Version

func (*Addon) GetReplicas

func (a *Addon) GetReplicas() *int32

GetReplicas returns the size of replicas, if is less than 1 sets a default value

type AddonList

type AddonList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []Addon `json:"items"`
}

AddonList is a list of Addons.

type AddonSpec

type AddonSpec struct {
	Type      string      `json:"type"`
	BaseImage string      `json:"baseImage"`
	Version   string      `json:"version"`
	Replicas  int32       `json:"replicas"`
	Port      int32       `json:"port"`
	Env       []v1.EnvVar `json:"env"`
	// More info: http://releases.k8s.io/HEAD/docs/user-guide/containers.md#containers-and-commands
	Args []string `json:"args,omitempty"`
}

AddonSpec holds specification parameters of an addon

type Domain

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

	Spec   DomainSpec   `json:"spec,omitempty"`
	Status DomainStatus `json:"status,omitempty"`
}

Domain are a way for users to "claim" a domain and be able to create ingresses

func (*Domain) GetDomain

func (d *Domain) GetDomain() string

func (*Domain) GetDomainType

func (d *Domain) GetDomainType() string

GetDomainType returns the type of the resource: 'primary' or 'shared'

func (*Domain) GetPrimaryDomain

func (d *Domain) GetPrimaryDomain() string

GetPrimaryDomain returns the primary domain of the resource

func (*Domain) HasDelegate

func (d *Domain) HasDelegate(namespace string) bool

HasDelegate verifies if the the resource has the target namespace in the delegates attribute

func (*Domain) HasFinalizer

func (d *Domain) HasFinalizer(finalizer string) bool

func (*Domain) IsOK

func (d *Domain) IsOK() bool

IsOK verifies if the resource is in the OK state

func (*Domain) IsPrimary

func (d *Domain) IsPrimary() bool

IsPrimary validates if it's a primary domain

func (*Domain) IsValidDomain

func (d *Domain) IsValidDomain() bool

func (*Domain) IsValidSharedDomain

func (d *Domain) IsValidSharedDomain() bool

IsValidSharedDomain verifies if the shared domain it's a subdomain from the primary

type DomainList

type DomainList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []Domain `json:"items"`
}

DomainList is a List of Domain

type DomainPhase

type DomainPhase string

DomainPhase is a label for the condition of a domain at the current time.

const (
	// DomainStatusNew means it's a new resource and the phase it's not set
	DomainStatusNew DomainPhase = ""
	// DomainStatusOK means the domain doesn't have no pending operations or prohibitions,
	// and new ingresses could be created using the target domain.
	DomainStatusOK DomainPhase = "OK"
	// DomainStatusPending indicates that a request to create a new domain
	// has been received and is being processed.
	DomainStatusPending DomainPhase = "Pending"
	// DomainStatusFailed means the resource has failed on claiming the domain
	DomainStatusFailed DomainPhase = "Failed"
)

type DomainSpec

type DomainSpec struct {
	// PrimaryDomain is the name of the primary domain, to set the resource as primary,
	// 'name' and 'primary' must have the same value.
	// +required
	PrimaryDomain string `json:"primary,omitempty"`
	// Sub is the label of the Primary Domain to form a subdomain
	// +optional
	Sub string `json:"sub,omitempty"`
	// Delegates contains a list of namespaces that are allowed to use this domain.
	// New domain resources could be referenced to primary ones using the 'parent' key.
	// A wildcard ("*") allows delegate access to all namespaces in the cluster.
	// +optional
	Delegates []string `json:"delegates,omitempty"`
	// Parent refers to the namespace where the primary domain is in.
	// It only makes sense when the type of the domain is set to 'shared',
	// +optional
	Parent string `json:"parent,omitempty"`
}

DomainSpec represents information about a domain claim

type DomainStatus

type DomainStatus struct {
	// The state of the domain, an empty state means it's a new resource
	// +optional
	Phase DomainPhase `json:"phase,omitempty"`
	// A human readable message indicating details about why the domain claim is in this state.
	// +optional
	Message string `json:"message,omitempty"`
	// A brief CamelCase message indicating details about why the domain claim is in this state. e.g. 'AlreadyClaimed'
	// +optional
	Reason string `json:"reason,omitempty"`
	// The last time the resource was updated
	LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
	// DeletionTimestamp it's a temporary field to work around the issue:
	// https://github.com/kubernetes/kubernetes/issues/40715, once it's solved,
	// remove this field and use the DeletionTimestamp from metav1.ObjectMeta
	DeletionTimestamp *metav1.Time `json:"deletionTimestamp,omitempty"`
}

DomainStatus represents information about the status of a domain.

type Namespace

type Namespace struct {
	Namespace    string
	Customer     string
	Organization string
}

Namespace represents the existent metadata of the platform namespace containing the name of the namespace, organization and the name of the customer in the form: [namespace]-[customer]-[organization]

func NewNamespace

func NewNamespace(namespace string) (*Namespace, error)

NewNamespace extract the organization, customer and the name of the namespace

func (*Namespace) GetNamespace

func (n *Namespace) GetNamespace() string

GetNamespace retrieves the original namespace

func (*Namespace) GetSystemNamespace

func (n *Namespace) GetSystemNamespace() string

GetSystemNamespace returns the system broker namespace

func (*Namespace) IsSystem

func (n *Namespace) IsSystem() bool

IsSystem returns true if it's a system broker namespace.

type Plan

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

	Spec PlanSpec `json:"spec"`
}

Plan defines how resources could be managed and distributed

func ServicePlanDeepCopy

func ServicePlanDeepCopy(sp *Plan) (*Plan, error)

ServicePlanDeepCopy creates a deep-copy from the specified resource

func (*Plan) CPU

func (p *Plan) CPU() (*resource.Quantity, *resource.Quantity)

CPU return the CPU from limits and requests respectively

func (*Plan) IsDefaultType

func (p *Plan) IsDefaultType() bool

IsDefaultType validate if the plan is PlanTypeDefault

func (*Plan) IsStorageType

func (p *Plan) IsStorageType() bool

IsStorageType validate if the plan is PlanTypeStorage

func (*Plan) Memory

func (p *Plan) Memory() (*resource.Quantity, *resource.Quantity)

Memory returns the memory from limits and requests respectively

func (*Plan) Storage

func (p *Plan) Storage() *resource.Quantity

Storage returns the storage ammount from the spec

type PlanList

type PlanList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []Plan `json:"items"`
}

PlanList is a list of ServicePlans

type PlanSpec

type PlanSpec struct {
	// Type determine how resources are provisioned by the controller,
	// defaults to Compute and Kubernetes Object resources. Valid options are: "" and Storage.
	// "" means the spec will provision memory and CPU from the 'resources' attribute,
	// 'hard' could be used to limit the usage of Kubernetes resources
	Type PlanType `json:"type,omitempty"`
	// Compute Resources required by containers.
	Resources v1.ResourceRequirements `json:"resources,omitempty"`
	// Hard is the set of desired hard limits for Kubernetes objects resources.
	Hard ResourceList `json:"hard,omitempty"`
	// Storage is the ammount of storage requested
	Storage resource.Quantity `json:"storage,omitempty"`
	Roles   []PlatformRole    `json:"roles,omitempty"`
}

PlanSpec holds specification parameters of an Plan

type PlanType

type PlanType string

PlanType describes the rules how resources are going to be provisioned

const (
	// PlanTypeDefault means a plan will consider only compute (memory, CPU) and
	// Kubernetes resources (pods, services, etc)
	PlanTypeDefault PlanType = ""
	// PlanTypeStorage means a plan will consider only storage resources
	PlanTypeStorage PlanType = "Storage"
)

type PlatformRole

type PlatformRole string

PlatformRole is the name identifying various roles in a PlatformRoleList.

const (
	// RoleExecAllow cluster role name
	RoleExecAllow PlatformRole = "exec-allow"
	// RolePortForwardAllow cluster role name
	RolePortForwardAllow PlatformRole = "portforward-allow"
	// RoleAutoScaleAllow cluster role name
	RoleAutoScaleAllow PlatformRole = "autoscale-allow"
	// RoleAttachAllow cluster role name
	RoleAttachAllow PlatformRole = "attach-allow"
	// RoleAddonManagement cluster role name
	RoleAddonManagement PlatformRole = "addon-management"
)

func NewPlatformRoles

func NewPlatformRoles(roles string) []PlatformRole

NewPlatformRoles converts a string of comma separated roles to registered []PlatformRoles

func (PlatformRole) Exists

func (r PlatformRole) Exists(roles []PlatformRole) bool

Exists verifies if the slice contains the role

func (PlatformRole) GetRoleBinding

func (r PlatformRole) GetRoleBinding(subjects []rbac.Subject) *rbac.RoleBinding

GetRoleBinding retrieves a role binding for this role

func (PlatformRole) IsRegisteredRole

func (r PlatformRole) IsRegisteredRole() bool

IsRegisteredRole check if the role matches with the registered roles.

type Release

type Release struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ReleaseSpec `json:"spec"`
}

Release refers to compiled slug file versions

func ReleaseDeepCopy

func ReleaseDeepCopy(r *Release) (*Release, error)

ReleaseDeepCopy creates a deep-copy from the specified resource

func (*Release) BuildRevision

func (r *Release) BuildRevision() int

BuildRevision returns the revision as int, if the conversion fails returns 0

func (*Release) Expired

func (r *Release) Expired() bool

Expired verifies if the creation time of the resource is expired.

func (*Release) GitCloneURL

func (r *Release) GitCloneURL() (string, error)

GitCloneURL constructs the remote clone URL for the given release

func (*Release) GitReleaseURL

func (r *Release) GitReleaseURL(host string) string

GitReleaseURL constructs the URL where the release must be stored

func (*Release) IsGitHubSource

func (r *Release) IsGitHubSource() bool

IsGitHubSource check if the source of the build is from github

type ReleaseList

type ReleaseList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Release `json:"items"`
}

ReleaseList is a list of Release

type ReleaseSpec

type ReleaseSpec struct {
	// The URL of the git remote server to download the git revision tarball
	GitRemote     string     `json:"gitRemote"`
	GitRevision   string     `json:"gitRevision"`
	GitRepository string     `json:"gitRepository"`
	BuildRevision string     `json:"buildRevision"`
	AutoDeploy    bool       `json:"autoDeploy"`
	ExpireAfter   int32      `json:"expireAfter"`
	DeployName    string     `json:"deployName"`
	Build         bool       `json:"build"`
	AuthToken     string     `json:"authToken"` // expirable token
	Source        SourceType `json:"sourceType"`
}

ReleaseSpec holds specification parameters of a release

type ResourceList

type ResourceList v1.ResourceList

ResourceList is a set of (resource name, quantity) pairs.

var PlatformRegisteredResources *ResourceList

PlatformRegisteredResources contains all the resources allowed for a user to configure in resource quotas: http://kubernetes.io/docs/admin/resourcequota/#Object-Count-Quota

func (*ResourceList) RemoveUnregisteredResources

func (r *ResourceList) RemoveUnregisteredResources()

RemoveUnregisteredResources removes resources which are not registered on the platform

type ServicePlanPhase

type ServicePlanPhase string

ServicePlanPhase is the current lifecycle phase of the Service Plan.

const (
	// ServicePlanActive means the ServicePlan is available for use in the system
	ServicePlanActive ServicePlanPhase = "Active"
	// ServicePlanPending means the ServicePlan isn't associate with any global ServicePlan
	ServicePlanPending ServicePlanPhase = "Pending"
	// ServicePlanNotFound means the reference plan wasn't found
	ServicePlanNotFound ServicePlanPhase = "NotFound"
	// ServicePlanDisabled means the ServicePlan is disabled and cannot be associated with resources
	ServicePlanDisabled ServicePlanPhase = "Disabled"
)

type SourceType

type SourceType string

SourceType refers to the source of the build

const (
	// GitHubSource means the build came from a webhook
	GitHubSource SourceType = "github"
	// GitLocalSource means the build came from the git local server
	GitLocalSource SourceType = "local"
)

type TokenType

type TokenType string

TokenType refers to a jwt token claim to specify the type of the token some types have restricted access and scope in the platform

const (
	// AdminTokenType has unsrestricted access to all endpoints
	AdminTokenType TokenType = "admin"
	// SystemTokenType allows interaction only between machine with l
	// imited access scope to endpoints
	SystemTokenType  TokenType = "system"
	RegularTokenType TokenType = "regular"
)

type User

type User struct {
	Username     string    `json:"username"`
	Email        string    `json:"email"`
	Customer     string    `json:"customer"`
	Organization string    `json:"org"`
	Sub          string    `json:"sub"`
	Groups       []string  `json:"groups"`
	Type         TokenType `json:"kolihub.io/type"` // Origin refers to the type of the token (system or regular)
	jwt.StandardClaims
}

User identifies an user on the platform

func (User) IsValid

func (u User) IsValid() bool

IsValid validates if the user is valid verifying the email, customer and organization

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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