k8s

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2016 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

*

  • Copyright (c) 2016 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright (c) 2016 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright (c) 2016 Intel Corporation *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConsulServiceName

func GetConsulServiceName(port api.ServicePort, service api.Service) string

func GetServiceExternalAddress

func GetServiceExternalAddress(domain string, port api.ServicePort) string

func GetServiceInternalHost

func GetServiceInternalHost(port api.ServicePort, service api.Service) string

func GetServiceInternalHostByFirstTCPPort

func GetServiceInternalHostByFirstTCPPort(service api.Service) string

Types

type ContainerSimple

type ContainerSimple struct {
	Name string
	Envs map[string]string
}

type FabricateResult

type FabricateResult struct {
	Url string
	Env map[string]string
}

type K8Fabricator

type K8Fabricator struct {
	KubernetesClient KubernetesClientCreator
	ConsulApi        consul.ConsulService
	Domain           string
}

func NewK8Fabricator

func NewK8Fabricator(domain string) *K8Fabricator

func (*K8Fabricator) CheckKubernetesServiceHealthByServiceInstanceId

func (k *K8Fabricator) CheckKubernetesServiceHealthByServiceInstanceId(creds K8sClusterCredential, space, instance_id string) (bool, error)

func (*K8Fabricator) CreateSecret

func (k *K8Fabricator) CreateSecret(creds K8sClusterCredential, secret api.Secret) error

func (*K8Fabricator) DeleteAllByServiceId

func (k *K8Fabricator) DeleteAllByServiceId(creds K8sClusterCredential, service_id string) error

func (*K8Fabricator) DeleteAllPersistentVolumeClaims added in v0.7.1

func (k *K8Fabricator) DeleteAllPersistentVolumeClaims(creds K8sClusterCredential) error

func (*K8Fabricator) DeleteSecret

func (k *K8Fabricator) DeleteSecret(creds K8sClusterCredential, key string) error

func (*K8Fabricator) FabricateService

func (k *K8Fabricator) FabricateService(creds K8sClusterCredential, space, cf_service_id, parameters string,
	ss state.StateService, component *catalog.KubernetesComponent) (FabricateResult, error)

func (*K8Fabricator) GetAllPersistentVolumes added in v0.7.1

func (k *K8Fabricator) GetAllPersistentVolumes(creds K8sClusterCredential) ([]api.PersistentVolume, error)

func (*K8Fabricator) GetAllPodsEnvsByServiceId

func (k *K8Fabricator) GetAllPodsEnvsByServiceId(creds K8sClusterCredential, space, service_id string) ([]PodEnvs, error)

func (*K8Fabricator) GetClusterWorkers

func (k *K8Fabricator) GetClusterWorkers(creds K8sClusterCredential) ([]string, error)

func (*K8Fabricator) GetPodsStateByServiceId

func (k *K8Fabricator) GetPodsStateByServiceId(creds K8sClusterCredential, service_id string) ([]PodStatus, error)

func (*K8Fabricator) GetPodsStateForAllServices

func (k *K8Fabricator) GetPodsStateForAllServices(creds K8sClusterCredential) (map[string][]PodStatus, error)

func (*K8Fabricator) GetQuota

func (k *K8Fabricator) GetQuota(creds K8sClusterCredential, space string) (*api.ResourceQuotaList, error)

func (*K8Fabricator) GetSecret

func (k *K8Fabricator) GetSecret(creds K8sClusterCredential, key string) (*api.Secret, error)

func (*K8Fabricator) GetServiceCredentials

func (k *K8Fabricator) GetServiceCredentials(creds K8sClusterCredential, space, service_id string) ([]ServiceCredential, error)

func (*K8Fabricator) GetServiceVisibility

func (k *K8Fabricator) GetServiceVisibility(creds K8sClusterCredential, org, space, service_id string) ([]K8sServiceInfo, error)

func (*K8Fabricator) GetServices

func (k *K8Fabricator) GetServices(creds K8sClusterCredential, org string) ([]api.Service, error)

func (*K8Fabricator) GetServicesVisibility

func (k *K8Fabricator) GetServicesVisibility(creds K8sClusterCredential, org, space string) ([]K8sServiceInfo, error)

func (*K8Fabricator) ListReplicationControllers

func (k *K8Fabricator) ListReplicationControllers(creds K8sClusterCredential) (*api.ReplicationControllerList, error)

func (*K8Fabricator) SetServicePublicVisibilityByServiceId

func (k *K8Fabricator) SetServicePublicVisibilityByServiceId(creds K8sClusterCredential, org, space, service_id string, shouldBePublic bool) ([]K8sServiceInfo, error)

func (*K8Fabricator) UpdateSecret

func (k *K8Fabricator) UpdateSecret(creds K8sClusterCredential, secret api.Secret) error

type K8sClusterCredential

type K8sClusterCredential struct {
	CLusterName    string `json:"cluster_name"`
	Server         string `json:"api_server"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	ConsulEndpoint string `json:"consul_http_api"`
}

type K8sCreatorConnector

type K8sCreatorConnector struct {
	ApiVersion       string
	Server           string
	Username         string
	Password         string
	Client           *http.Client
	OrgQuota         int
	KubernetesClient KubernetesClientCreator
}

func NewK8sCreatorConnector

func NewK8sCreatorConnector(server, user, pass string, maxOrgQuota int) *K8sCreatorConnector

func (*K8sCreatorConnector) CreateSecretForPrivateTapRepo

func (k *K8sCreatorConnector) CreateSecretForPrivateTapRepo(creds K8sClusterCredential) error

func (*K8sCreatorConnector) DeleteCluster

func (k *K8sCreatorConnector) DeleteCluster(org string) error

func (*K8sCreatorConnector) GetCluster

func (k *K8sCreatorConnector) GetCluster(org string) (int, K8sClusterCredential, error)

func (*K8sCreatorConnector) GetClusters

func (k *K8sCreatorConnector) GetClusters() ([]K8sClusterCredential, error)

func (*K8sCreatorConnector) GetOrCreateCluster

func (k *K8sCreatorConnector) GetOrCreateCluster(org string) (K8sClusterCredential, error)

func (*K8sCreatorConnector) IsApiWorking

func (k *K8sCreatorConnector) IsApiWorking(credential K8sClusterCredential) bool

func (*K8sCreatorConnector) PostCluster

func (k *K8sCreatorConnector) PostCluster(org string) (int, error)

type K8sCreatorRest

type K8sCreatorRest interface {
	DeleteCluster(org string) error
	GetCluster(org string) (int, K8sClusterCredential, error)
	GetOrCreateCluster(org string) (K8sClusterCredential, error)
	PostCluster(org string) (int, error)
	GetClusters() ([]K8sClusterCredential, error)
}

type K8sServiceInfo

type K8sServiceInfo struct {
	ServiceId string   `json:"serviceId"`
	Org       string   `json:"org"`
	Space     string   `json:"space"`
	Name      string   `json:"name"`
	TapPublic bool     `json:"tapPublic"`
	Uri       []string `json:"uri"`
}

type KubernetesApi

type KubernetesApi interface {
	FabricateService(creds K8sClusterCredential, space, cf_service_id, parameters string, ss state.StateService,
		component *catalog.KubernetesComponent) (FabricateResult, error)
	CheckKubernetesServiceHealthByServiceInstanceId(creds K8sClusterCredential, space, instance_id string) (bool, error)
	DeleteAllByServiceId(creds K8sClusterCredential, service_id string) error
	DeleteAllPersistentVolumeClaims(creds K8sClusterCredential) error
	GetAllPersistentVolumes(creds K8sClusterCredential) ([]api.PersistentVolume, error)
	GetAllPodsEnvsByServiceId(creds K8sClusterCredential, space, service_id string) ([]PodEnvs, error)
	GetServiceVisibility(creds K8sClusterCredential, org, space, service_id string) ([]K8sServiceInfo, error)
	GetServicesVisibility(creds K8sClusterCredential, org, space string) ([]K8sServiceInfo, error)
	GetServiceCredentials(creds K8sClusterCredential, space, service_id string) ([]ServiceCredential, error)
	GetServices(creds K8sClusterCredential, org string) ([]api.Service, error)
	GetQuota(creds K8sClusterCredential, space string) (*api.ResourceQuotaList, error)
	GetClusterWorkers(creds K8sClusterCredential) ([]string, error)
	GetPodsStateByServiceId(creds K8sClusterCredential, service_id string) ([]PodStatus, error)
	GetPodsStateForAllServices(creds K8sClusterCredential) (map[string][]PodStatus, error)
	SetServicePublicVisibilityByServiceId(creds K8sClusterCredential, org, space, service_id string, shouldBePublic bool) ([]K8sServiceInfo, error)
	ListReplicationControllers(creds K8sClusterCredential) (*api.ReplicationControllerList, error)
	GetSecret(creds K8sClusterCredential, key string) (*api.Secret, error)
	CreateSecret(creds K8sClusterCredential, secret api.Secret) error
	DeleteSecret(creds K8sClusterCredential, key string) error
	UpdateSecret(creds K8sClusterCredential, secret api.Secret) error
}

type KubernetesClient

type KubernetesClient interface {
	ReplicationControllers(namespace string) k8sClient.ReplicationControllerInterface
	Nodes() k8sClient.NodeInterface
	Events(namespace string) k8sClient.EventInterface
	Endpoints(namespace string) k8sClient.EndpointsInterface
	Pods(namespace string) k8sClient.PodInterface
	PodTemplates(namespace string) k8sClient.PodTemplateInterface
	Services(namespace string) k8sClient.ServiceInterface
	LimitRanges(namespace string) k8sClient.LimitRangeInterface
	ResourceQuotas(namespace string) k8sClient.ResourceQuotaInterface
	ServiceAccounts(namespace string) k8sClient.ServiceAccountsInterface
	Secrets(namespace string) k8sClient.SecretsInterface
	Namespaces() k8sClient.NamespaceInterface
	PersistentVolumes() k8sClient.PersistentVolumeInterface
	PersistentVolumeClaims(namespace string) k8sClient.PersistentVolumeClaimInterface
	ComponentStatuses() k8sClient.ComponentStatusInterface
	ConfigMaps(namespace string) k8sClient.ConfigMapsInterface
}

we need this redundant interface to be able to inject TestClient in Test class

type KubernetesClientCreator

type KubernetesClientCreator interface {
	GetNewClient(creds K8sClusterCredential) (KubernetesClient, error)
}

type KubernetesRestCreator

type KubernetesRestCreator struct {
}

func (*KubernetesRestCreator) GetNewClient

type KubernetesTestAdvancedParams

type KubernetesTestAdvancedParams struct {
	Verb            string
	Resource        string
	ResponceObjects []runtime.Object
}

type KubernetesTestCreator

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

func (*KubernetesTestCreator) GetNewClient

func (*KubernetesTestCreator) LoadAdvancedResponses

func (k *KubernetesTestCreator) LoadAdvancedResponses(params []KubernetesTestAdvancedParams)

This method allow to inject response object dependly of their action

func (*KubernetesTestCreator) LoadSimpleResponsesWithSameAction

func (k *KubernetesTestCreator) LoadSimpleResponsesWithSameAction(responeObjects ...runtime.Object)

Objects will be returned in provided order All objects should do same action e.g. list/update/create

type PodEnvs

type PodEnvs struct {
	RcName     string
	Containers []ContainerSimple
}

type PodStatus

type PodStatus struct {
	PodName       string
	ServiceId     string
	Status        api.PodPhase
	StatusMessage string
}

type RcConnector

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

func NewReplicationControllerManager

func NewReplicationControllerManager(client KubernetesClient) *RcConnector

func (*RcConnector) Create

func (r *RcConnector) Create(replicationController *api.ReplicationController) (*api.ReplicationController, error)

func (*RcConnector) DeleteAll

func (r *RcConnector) DeleteAll(selector labels.Selector) error

func (*RcConnector) List

func (*RcConnector) UpdateReplicasNumber

func (r *RcConnector) UpdateReplicasNumber(name string, count int) error

type ReplicationControllerManager

type ReplicationControllerManager interface {
	DeleteAll(selector labels.Selector) error
	UpdateReplicasNumber(name string, count int) error
	Create(replicationController *api.ReplicationController) (*api.ReplicationController, error)
	List(selector labels.Selector) (*api.ReplicationControllerList, error)
}

type ServiceCredential

type ServiceCredential struct {
	Name  string
	Host  string
	Ports []api.ServicePort
}

Jump to

Keyboard shortcuts

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