kube

package
v1.1.62 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChartCDX the default name of the CDX chart
	ChartCDX = "jenkins-x/cdx"

	// ChartGitea the default name of the gitea chart
	ChartGitea = "jenkins-x/gitea"

	// ChartKubeless the default chart for kubeless
	ChartKubeless = "incubator/kubeless"

	// ServiceJenkins is the name of the Jenkins Service
	ServiceJenkins = "jenkins"

	// SeriviceCDX the service name of the Helm Chart Museum service
	ServiceCDX = "cdx-cdx"

	// ServiceChartMuseum the service name of the Helm Chart Museum service
	ServiceChartMuseum = "jenkins-x-chartmuseum"

	// ServiceKubernetesDashboard the kubernetes dashboard
	ServiceKubernetesDashboard = "jenkins-x-kubernetes-dashboard"

	// SecretJenkinsGitCredentials the git credentials secret
	SecretJenkinsGitCredentials = "jenkins-git-credentials"

	// SecretJenkinsPipelineIssueCredentials the issue tracker credentials secret
	SecretJenkinsPipelineIssueCredentials = "jx-pipeline-issues-"

	// SecretJenkinsPipelineGitCredentials the issue tracker credentials secret
	SecretJenkinsPipelineGitCredentials = "jx-pipeline-git-"

	// ConfigMapJenkinsXGitKinds the name of the ConfigMap in the development namespace that maps kinds to URLs
	ConfigMapJenkinsXGitKinds = "jenkins-x-git-kinds"

	// LocalHelmRepoName is the default name of the local chart repository where CI / CD releases go to
	LocalHelmRepoName = "releases"

	DefaultEnvironmentGitRepoURL = "https://github.com/jenkins-x/default-environment-charts.git"

	// LabelKind to indicate the kind of auth, such as Git or Issue
	LabelKind = "jenkins.io/kind"

	// ValueKindGit a git auth secret/credentials
	ValueKindGit = "git"
	// ValueKindIssue an issue auth secret/credentials
	ValueKindIssue = "issue"

	// LabelServiceKind the label to indicate the auto Server's Kind
	LabelServiceKind = "jenkins.io/service-kind"

	// LabelCreatedBy indicates the service that created this resource
	LabelCreatedBy = "jenkins.io/created-by"

	// ValueCreatedByJX for resources created by the Jenkins X CLI
	ValueCreatedByJX = "jx"

	// LabelCredentialsType the kind of jenkins credential for a secret
	LabelCredentialsType = "jenkins.io/credentials-type"

	// ValueCredentialTypeUsernamePassword for user password credential secrets
	ValueCredentialTypeUsernamePassword = "usernamePassword"

	// AnnotationURL indicates a service/server's URL
	AnnotationURL = "jenkins.io/url"

	// AnnotationName indicates a service/server's textual name (can be mixed case, contain spaces unlike kubernetes resources)
	AnnotationName = "jenkins.io/name"

	// AnnotationCredentialsDescription the description text for a Credentian on a Secret
	AnnotationCredentialsDescription = "jenkins.io/credentials-description"

	// SecretDataUsername the username in a Secret/Credentials
	SecretDataUsername = "username"

	// SecretDataPassword the password in a Secret/Credentials
	SecretDataPassword = "password"
)
View Source
const (
	LabelValueDevEnvironment = "dev"

	LabelTeam        = "team"
	LabelEnvironment = "env"
)
View Source
const (
	OptionName      = "name"
	OptionNamespace = "namespace"
)
View Source
const (
	DefaultNamespace = "jx"
)
View Source
const (
	ExposeURLAnnotation = "fabric8.io/exposeUrl"
)
View Source
const (
	Exposecontroller = "exposecontroller"
)

Variables

View Source
var (
	AddonCharts = map[string]string{
		"cdx":        ChartCDX,
		"gitea":      ChartGitea,
		"kubeless":   ChartKubeless,
		"prometheus": "stable/prometheus",
		"grafana":    "stable/grafana",
	}
)

Functions

func ClusterRoleBindingYaml

func ClusterRoleBindingYaml(user string) string

func ClusterRoleYaml

func ClusterRoleYaml(user string) string

func CompletePromote

func CompletePromote(p *v1.PromoteActivityStep) error

func CreateClient

func CreateClient(kubeconfig *string) (*kubernetes.Clientset, error)

CreateClient creates a new kubernetes client

func CreateEnvironmentSurvey

func CreateEnvironmentSurvey(out io.Writer, batchMode bool, authConfigSvc auth.AuthConfigService, devEnv *v1.Environment, data *v1.Environment, config *v1.Environment, forkEnvGitURL string, ns string, jxClient *versioned.Clientset, kubeClient *kubernetes.Clientset, envDir string, gitRepoOptions *gits.GitRepositoryOptions, helmValues config.HelmValuesConfig, prefix string) (gits.GitProvider, error)

CreateEnvironmentSurvey creates a Survey on the given environment using the default options from the CLI

func CurrentContext

func CurrentContext(config *api.Config) *api.Context

CurrentContext returns the current context

func CurrentNamespace

func CurrentNamespace(config *api.Config) string

CurrentNamespace returns the current namespace in the context

func CurrentServer

func CurrentServer(config *api.Config) string

CurrentServer returns the current context's server

func DeploymentPodCount

func DeploymentPodCount(client *kubernetes.Clientset, name, namespace string) (int, error)

func EnableInsecureRegistry

func EnableInsecureRegistry(iqJson string, dockerRegistry string) (string, error)

EnableInsecureRegistry appends the Docker Registry

func EnsureDevEnvironmentSetup

func EnsureDevEnvironmentSetup(jxClient *versioned.Clientset, ns string) (*v1.Environment, error)

EnsureDevEnvironmentSetup ensures that the Environment is created in the given namespace

func EnsureEnvironmentNamespaceSetup

func EnsureEnvironmentNamespaceSetup(kubeClient *kubernetes.Clientset, jxClient *versioned.Clientset, env *v1.Environment, ns string) error

func EnsureGitServiceExistsForHost

func EnsureGitServiceExistsForHost(jxClient *versioned.Clientset, devNs string, kind string, name string, gitUrl string, out io.Writer) error

EnsureGitServiceExistsForHost ensures that there is a GitService CRD for the given host and kind

func EnsureNamespaceCreated

func EnsureNamespaceCreated(kubeClient *kubernetes.Clientset, name string, labels map[string]string, annotations map[string]string) error

Ensure that the namespace exists for the given name

func FailedPromote

func FailedPromote(p *v1.PromoteActivityStep) error

func FindServiceURL

func FindServiceURL(client *kubernetes.Clientset, namespace string, name string) (string, error)

func GetAppName

func GetAppName(name string, namespaces ...string) string

GetAppName returns the app name

func GetCommitSha

func GetCommitSha(r *metav1.ObjectMeta) string

GetCommitSha returns the git commit sha

func GetCommitURL

func GetCommitURL(r *metav1.ObjectMeta) string

GetCommitURL returns the git commit URL

func GetConfigmapData

func GetConfigmapData(client *kubernetes.Clientset, name, ns string) (map[string]string, error)

func GetCurrentDomain

func GetCurrentDomain(client *kubernetes.Clientset, ns string) (string, error)

func GetDeploymentNames

func GetDeploymentNames(client *kubernetes.Clientset, ns string, filter string) ([]string, error)

func GetDeploymentPods

func GetDeploymentPods(client *kubernetes.Clientset, name, namespace string) ([]v1.Pod, error)

func GetDeployments

func GetDeployments(kubeClient *kubernetes.Clientset, ns string) (map[string]v1beta1.Deployment, error)

func GetDevNamespace

func GetDevNamespace(kubeClient *kubernetes.Clientset, ns string) (string, string, error)

GetDevNamespace returns the developer environment namespace which is the namespace that contains the Environments and the developer tools like Jenkins

func GetEnvironmentNames

func GetEnvironmentNames(jxClient *versioned.Clientset, ns string) ([]string, error)

GetEnvironmentNames returns the sorted list of environment names

func GetEnvironments

func GetEnvironments(jxClient *versioned.Clientset, ns string) (map[string]*v1.Environment, []string, error)

GetEnvironments returns a map of the enviroments along with a sorted list of names

func GetGitServiceKind

func GetGitServiceKind(jxClient *versioned.Clientset, kubeClient *kubernetes.Clientset, devNs string, gitServiceUrl string) (string, error)

GetGitServiceKind returns the kind of the given host if one can be found or ""

func GetGitServiceKindFromConfigMap

func GetGitServiceKindFromConfigMap(cm *corev1.ConfigMap, gitServiceUrl string) string

func GetName

func GetName(r *metav1.ObjectMeta) string

GetName returns the app name

func GetPodCondition

func GetPodCondition(status *v1.PodStatus, conditionType v1.PodConditionType) (int, *v1.PodCondition)

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go GetPodCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodNames

func GetPodNames(client *kubernetes.Clientset, ns string, filter string) ([]string, error)

func GetPodReadyCondition

func GetPodReadyCondition(status v1.PodStatus) *v1.PodCondition

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go Extracts the pod ready condition from the given status and returns that. Returns nil if the condition is not present.

func GetPodVersion

func GetPodVersion(pod *corev1.Pod, appName string) string

GetPodVersion returns the version for the given app name

func GetReadyPodNames

func GetReadyPodNames(client *kubernetes.Clientset, ns string, filter string) ([]string, error)

func GetServiceNames

func GetServiceNames(client *kubernetes.Clientset, ns string, filter string) ([]string, error)

func GetServiceURL

func GetServiceURL(svc *v1.Service) string

func GetServiceURLFromMap

func GetServiceURLFromMap(services map[string]*v1.Service, name string) string

func GetServices

func GetServices(client *kubernetes.Clientset, ns string) (map[string]*v1.Service, error)

func GetVersion

func GetVersion(r *metav1.ObjectMeta) string

GetVersion returns the version from the labels on the deployment if it can be deduced

func HasExternalAddress

func HasExternalAddress(svc *v1.Service) bool

func IsDeploymentRunning

func IsDeploymentRunning(client *kubernetes.Clientset, name, namespace string) (bool, error)

func IsPodReady

func IsPodReady(pod *v1.Pod) bool

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go IsPodReady returns true if a pod is ready; false otherwise.

func IsPodReadyConditionTrue

func IsPodReadyConditionTrue(status v1.PodStatus) bool

credit https://github.com/kubernetes/kubernetes/blob/8719b4a/pkg/api/v1/pod/util.go IsPodReady retruns true if a pod is ready; false otherwise.

func LoadConfig

func LoadConfig() (*api.Config, *clientcmd.PathOptions, error)

LoadConfig loads the kubernetes configuration

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges all the maps together with the entries in the last map overwriting any earlier values

so if you want to add some annotations to a resource you can do resource.Annotations = kube.MergeMaps(resource.Annotations, myAnnotations)

func PickEnvironment

func PickEnvironment(envNames []string, defaultEnv string) (string, error)

func PodRequestsAndLimits

func PodRequestsAndLimits(pod *v1.Pod) (reqs map[v1.ResourceName]resource.Quantity, limits map[v1.ResourceName]resource.Quantity)

func RegisterEnvironmentCRD

func RegisterEnvironmentCRD(apiClient *apiextensionsclientset.Clientset) error

RegisterEnvironmentCRD ensures that the CRD is registered for Environments

func RegisterGitServiceCRD

func RegisterGitServiceCRD(apiClient *apiextensionsclientset.Clientset) error

RegisterGitServiceCRD ensures that the CRD is registered for GitServices

func RegisterPipelineActivityCRD

func RegisterPipelineActivityCRD(apiClient *apiextensionsclientset.Clientset) error

RegisterPipelineActivityCRD ensures that the CRD is registered for PipelineActivity

func RegisterReleaseCRD

func RegisterReleaseCRD(apiClient *apiextensionsclientset.Clientset) error

RegisterReleaseCRD ensures that the CRD is registered for Release

func RoleBindingKubeSystemYaml

func RoleBindingKubeSystemYaml(user string) string

func RoleKubeSystemYaml

func RoleKubeSystemYaml(user string) string

func Server

func Server(config *api.Config, context *api.Context) string

Server returns the server of the given context

func SortEnvironments

func SortEnvironments(environments []v1.Environment)

func SortListWatchByName

func SortListWatchByName(listWatch *cache.ListWatch)

func SortRuntimeObjectsByName

func SortRuntimeObjectsByName(objects []runtime.Object)

func StartPromote

func StartPromote(p *v1.PromoteActivityStep) error

func ToValidName

func ToValidName(name string) string

ToValidName converts the given string into a valid kubernetes resource name

func ToValidNameWithDots

func ToValidNameWithDots(name string) string

ToValidNameWithDots converts the given string into a valid kubernetes resource name

func ValidNameOption

func ValidNameOption(option string, value string) error

func ValidSubDomainOption

func ValidSubDomainOption(option string, value string) error

func ValidateEnvironmentDoesNotExist

func ValidateEnvironmentDoesNotExist(jxClient *versioned.Clientset, ns string, str string) error

func ValidateName

func ValidateName(val interface{}) error

func ValidateSubDomain

func ValidateSubDomain(val interface{}) error

func WaitForAllDeploymentsToBeReady

func WaitForAllDeploymentsToBeReady(client *kubernetes.Clientset, namespace string, timeoutPerDeploy time.Duration) error

func WaitForDeploymentToBeReady

func WaitForDeploymentToBeReady(client *kubernetes.Clientset, name, namespace string, timeout time.Duration) error

waits for the pods of a deployment to become ready

func WaitForExternalIP

func WaitForExternalIP(client *kubernetes.Clientset, name, namespace string, timeout time.Duration) error

waits for the pods of a deployment to become ready

func WaitForPodToBeReady

func WaitForPodToBeReady(client *kubernetes.Clientset, selector labels.Selector, namespace string, timeout time.Duration) error

waits for the pod to become ready using label selector to match the pod

Types

type ByName

type ByName []runtime.Object

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type ByOrder

type ByOrder []v1.Environment

func (ByOrder) Len

func (a ByOrder) Len() int

func (ByOrder) Less

func (a ByOrder) Less(i, j int) bool

func (ByOrder) Swap

func (a ByOrder) Swap(i, j int)

type ClusterStatus

type ClusterStatus struct {
	Name string
	// contains filtered or unexported fields
}

func GetClusterStatus

func GetClusterStatus(client *kubernetes.Clientset, namespace string) (ClusterStatus, error)

func (*ClusterStatus) AverageCpuPercent

func (clusterStatus *ClusterStatus) AverageCpuPercent() int

func (*ClusterStatus) AverageMemPercent

func (clusterStatus *ClusterStatus) AverageMemPercent() int

func (*ClusterStatus) CheckResource

func (clusterStatus *ClusterStatus) CheckResource() string

func (*ClusterStatus) Info

func (clusterStatus *ClusterStatus) Info() string

func (*ClusterStatus) MinimumResourceLimit

func (clusterStatus *ClusterStatus) MinimumResourceLimit() int

func (*ClusterStatus) NodeCount

func (clusterStatus *ClusterStatus) NodeCount() int

type HeapterConfig

type HeapterConfig struct {
	KubeClient        *kubernetes.Clientset
	HeapsterNamespace string
	HeapsterScheme    string
	HeapsterPort      string
	HeapsterService   string
	// contains filtered or unexported fields
}

func (*HeapterConfig) GetPodMetrics

func (q *HeapterConfig) GetPodMetrics(ns string, pod string, selector string, metric string, start string, end string) ([]byte, error)

type NodeStatus

type NodeStatus struct {
	Name            string
	AllocatedMemory *resource.Quantity
	AllocatedCPU    *resource.Quantity
	CpuReqs         resource.Quantity
	CpuLimits       resource.Quantity

	MemReqs   resource.Quantity
	MemLimits resource.Quantity
	// contains filtered or unexported fields
}

func Status

func Status(client *kubernetes.Clientset, namespace string, node v1.Node) (NodeStatus, error)

type PipelineActivityKey

type PipelineActivityKey struct {
	Name            string
	Pipeline        string
	Build           string
	BuildURL        string
	BuildLogsURL    string
	ReleaseNotesURL string
	GitInfo         *gits.GitRepositoryInfo
}

func (*PipelineActivityKey) GetOrCreate

GetOrCreate gets or creates the pipeline activity

func (*PipelineActivityKey) IsValid

func (k *PipelineActivityKey) IsValid() bool

type PromoteStepActivityKey

type PromoteStepActivityKey struct {
	PipelineActivityKey

	Environment    string
	ApplicationURL string
}

func (*PromoteStepActivityKey) GetOrCreatePromote

GetOrCreatePromote gets or creates the Promote step for the key

func (*PromoteStepActivityKey) GetOrCreatePromotePullRequest

GetOrCreatePromotePullRequest gets or creates the PromotePullRequest for the key

func (*PromoteStepActivityKey) GetOrCreatePromoteUpdate

GetOrCreatePromoteUpdate gets or creates the Promote for the key

func (*PromoteStepActivityKey) OnPromotePullRequest

func (k *PromoteStepActivityKey) OnPromotePullRequest(activities typev1.PipelineActivityInterface, fn PromotePullRequestFn) error

func (*PromoteStepActivityKey) OnPromoteUpdate

type ServiceURL

type ServiceURL struct {
	Name string
	URL  string
}

func FindServiceURLs

func FindServiceURLs(client *kubernetes.Clientset, namespace string) ([]ServiceURL, error)

Jump to

Keyboard shortcuts

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