router

package
v0.0.0-...-2972591 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 28 Imported by: 0

README

Kubernetes client problems

Plain kubernetes client
clientset, err := kubernetes.NewForConfig(config)
Rest client
Variant 1
clientset, err := kubernetes.NewForConfig(config)
clientset.RESTClient().Namespace(out.GetObjectMeta().Namespace).
                      		Resource(crd.ResourceName(schema.Plural)).
                      		Body(out).
                      		Do().
                      		Get()

No serializer found for

The simple RESTClient has only decoders installed.

Variant 2
config.GroupVersion = &schema.GroupVersion{
    Group:   "config.istio.io",
    Version: "v1alpha2",
}
config.APIPath = "/apis"
config.ContentType = runtime.ContentTypeJSON

types := runtime.NewScheme()
schemeBuilder := runtime.NewSchemeBuilder(
    func(scheme *runtime.Scheme) error {
        metav1.AddToGroupVersion(scheme, *config.GroupVersion)
        return nil
    })
err := schemeBuilder.AddToScheme(types)
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: serializer.NewCodecFactory(types)}

client, err := rest.RESTClientFor(config)

client.Post().
		Namespace(out.GetObjectMeta().Namespace).
		Resource(crd.ResourceName(schema.Plural)).
		Body(out).
		Do().
		Get()

the server could not find the requested resource (post serviceentries.config.istio.io)

Documentation

Index

Constants

View Source
const (
	// DefaultPort for istio-broker-proxy HTTP endpoint
	DefaultPort = 8080
	// IstioBrokerVersion is a header entry that contains the commit-shas of istio-broker-proxy
	IstioBrokerVersion = "X-Istio-Broker-Versions"
)

Variables

This section is empty.

Functions

func CreateIstioObjectsInK8S

func CreateIstioObjectsInK8S(configStore ConfigStore, bindingID string, name string, endpoint model.Endpoint, systemDomain string) (string, error)

CreateIstioObjectsInK8S create a service and istio routing rules

func SetupRouter

func SetupRouter(interceptor ServiceBrokerInterceptor, routerConfig Config) *gin.Engine

SetupRouter creates the istio-broker-proxy's endpoints

func SetupRouterWithVersion

func SetupRouterWithVersion(interceptor ServiceBrokerInterceptor, routerConfig Config, vers string) *gin.Engine

SetupRouterWithVersion creates the istio-broker-proxy's endpoints

Types

type Config

type Config struct {
	ForwardURL         string
	SkipVerifyTLS      bool
	Port               int
	HTTPClientFactory  func(tr *http.Transport) *http.Client
	HTTPRequestFactory func(method string, url string, header http.Header, body io.Reader) (*http.Request, error)
}

Config contains various config

type ConfigStore

type ConfigStore interface {
	CreateService(bindingID string, service *v1.Service) (*v1.Service, error)
	CreateIstioConfig(bindingID string, config []model.Config) error
	DeleteBinding(bindingID string) error
}

ConfigStore encapsulates functions to modify istio config

func NewExternKubeConfigStore

func NewExternKubeConfigStore(namespace string) ConfigStore

NewExternKubeConfigStore creates a new ConfigStore using the KUBECONFIG env variable

func NewFileConfigStore

func NewFileConfigStore(dir string) ConfigStore

NewFileConfigStore returns a new FileConfigStore for a given directory

func NewInClusterConfigStore

func NewInClusterConfigStore() ConfigStore

NewInClusterConfigStore creates a new ConfigStore from within the cluster

func NewMockConfigStore

func NewMockConfigStore() ConfigStore

NewMockConfigStore create a new ConfigStore with mocking capabilities

type ConsumerInterceptor

type ConsumerInterceptor struct {
	ConsumerID        string
	ConfigStore       ConfigStore
	ServiceNamePrefix string
	NetworkProfile    string
}

ConsumerInterceptor contains config for the consumer side

func (ConsumerInterceptor) HasAdaptCredentials

func (c ConsumerInterceptor) HasAdaptCredentials() bool

HasAdaptCredentials see interface definition

func (ConsumerInterceptor) PostBind

PostBind see interface definition

func (ConsumerInterceptor) PostCatalog

func (c ConsumerInterceptor) PostCatalog(catalog *model.Catalog) error

PostCatalog see interface definition

func (ConsumerInterceptor) PostProvision

PostProvision see interface definition

func (ConsumerInterceptor) PostUnbind

func (c ConsumerInterceptor) PostUnbind(bindID string)

PostUnbind see interface definition

func (ConsumerInterceptor) PreBind

PreBind see interface definition

func (ConsumerInterceptor) PreProvision

PreProvision see interface definition

type MockConfigStore

type MockConfigStore struct {
	CreatedServices      []*v1.Service
	CreatedIstioConfigs  []istioModel.Config
	ClusterIP            string
	CreateServiceErr     error
	CreateObjectErr      error
	CreateObjectErrCount int
	DeletedServices      []string
	DeletedIstioConfigs  []string
}

MockConfigStore is the configStore to use in unit test with some spy functionality

func (*MockConfigStore) CreateIstioConfig

func (m *MockConfigStore) CreateIstioConfig(bindingID string, configs []istioModel.Config) error

CreateIstioConfig stores the configs that would be created

func (*MockConfigStore) CreateService

func (m *MockConfigStore) CreateService(bindingID string, service *v1.Service) (*v1.Service, error)

CreateService stores the service that would be created

func (*MockConfigStore) DeleteBinding

func (m *MockConfigStore) DeleteBinding(bindingID string) error

DeleteBinding stores the objects that would have been deleted if they have been created via this store

type ProducerInterceptor

type ProducerInterceptor struct {
	LoadBalancerPort  int
	SystemDomain      string
	ProviderID        string
	IPAddress         string
	ServiceNamePrefix string
	PlanMetaData      string
	NetworkProfile    string
	ConfigStore       ConfigStore
}

ProducerInterceptor contains config for the producer side

func (ProducerInterceptor) HasAdaptCredentials

func (c ProducerInterceptor) HasAdaptCredentials() bool

HasAdaptCredentials see interface definition

func (ProducerInterceptor) PostBind

PostBind see interface definition

func (ProducerInterceptor) PostCatalog

func (c ProducerInterceptor) PostCatalog(catalog *model.Catalog) error

PostCatalog see interface definition

func (ProducerInterceptor) PostProvision

PostProvision see interface definition

func (ProducerInterceptor) PostUnbind

func (c ProducerInterceptor) PostUnbind(bindID string)

PostUnbind see interface definition

func (ProducerInterceptor) PreBind

PreBind see interface definition

func (ProducerInterceptor) PreProvision

PreProvision see interface definition

func (*ProducerInterceptor) WriteIstioConfigFiles

func (c *ProducerInterceptor) WriteIstioConfigFiles(port int) error

WriteIstioConfigFiles creates istio config for control plane route

type ServiceBrokerInterceptor

type ServiceBrokerInterceptor interface {
	PreProvision(request model.ProvisionRequest) (*model.ProvisionRequest, error)
	PostProvision(request model.ProvisionRequest, response model.ProvisionResponse) (*model.ProvisionResponse, error)
	PreBind(request model.BindRequest) (*model.BindRequest, error)
	PostBind(request model.BindRequest, response model.BindResponse, bindID string,
		adapt func(model.Credentials, []model.EndpointMapping) (*model.BindResponse, error)) (*model.BindResponse, error)
	PostUnbind(bindID string)
	PostCatalog(catalog *model.Catalog) error
	HasAdaptCredentials() bool
}

ServiceBrokerInterceptor specifies methods to modify osb calls

func NewNoOpInterceptor

func NewNoOpInterceptor() ServiceBrokerInterceptor

NewNoOpInterceptor creates an empty ServiceBrokerInterceptor

Jump to

Keyboard shortcuts

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