crd

package
v0.0.0-...-328700a Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2017 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package crd provides an implementation of the config store and cache using Kubernetes Custom Resources and the informer framework from Kubernetes

Index

Constants

This section is empty.

Variables

View Source
var IstioAPIGroupVersion = schema.GroupVersion{
	Group:   model.IstioAPIGroup,
	Version: model.IstioAPIVersion,
}

IstioAPIGroupVersion defines schema.GroupVersion for Istio configuration resources.

Functions

func CamelCaseToKabobCase

func CamelCaseToKabobCase(s string) string

CamelCaseToKabobCase converts "MyName" to "my-name"

func ConvertObject

func ConvertObject(schema model.ProtoSchema, object IstioObject, domain string) (*model.Config, error)

ConvertObject converts an IstioObject k8s-style object to the internal configuration model.

func CreateRESTConfig

func CreateRESTConfig(kubeconfig string) (config *rest.Config, err error)

CreateRESTConfig for cluster API server, pass empty config file for in-cluster

func KabobCaseToCamelCase

func KabobCaseToCamelCase(s string) string

KabobCaseToCamelCase converts "my-name" to "MyName"

func NewController

func NewController(client *Client, options kube.ControllerOptions) model.ConfigStoreCache

NewController creates a new Kubernetes controller for CRDs Use "" for namespace to listen for all namespace changes

func ResourceName

func ResourceName(s string) string

ResourceName converts "my-name" to "myname". This is needed by k8s API server as dashes prevent kubectl from accessing CRDs

Types

type Client

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

Client is a basic REST client for CRDs implementing config store

func NewClient

func NewClient(config string, descriptor model.ConfigDescriptor, domainSuffix string) (*Client, error)

NewClient creates a client to Kubernetes API using a kubeconfig file. Use an empty value for `kubeconfig` to use the in-cluster config. If the kubeconfig file is empty, defaults to in-cluster config as well.

func (*Client) ConfigDescriptor

func (cl *Client) ConfigDescriptor() model.ConfigDescriptor

ConfigDescriptor for the store

func (*Client) Create

func (cl *Client) Create(config model.Config) (string, error)

Create implements store interface

func (*Client) Delete

func (cl *Client) Delete(typ, name, namespace string) error

Delete implements store interface

func (*Client) DeregisterResources

func (cl *Client) DeregisterResources() error

DeregisterResources removes third party resources

func (*Client) Get

func (cl *Client) Get(typ, name, namespace string) (*model.Config, bool)

Get implements store interface

func (*Client) List

func (cl *Client) List(typ, namespace string) ([]model.Config, error)

List implements store interface

func (*Client) RegisterResources

func (cl *Client) RegisterResources() error

RegisterResources sends a request to create CRDs and waits for them to initialize

func (*Client) Update

func (cl *Client) Update(config model.Config) (string, error)

Update implements store interface

type IstioKind

type IstioKind struct {
	meta_v1.TypeMeta   `json:",inline"`
	meta_v1.ObjectMeta `json:"metadata"`
	Spec               map[string]interface{} `json:"spec"`
}

IstioKind is the generic Kubernetes API object wrapper

func ParseInputs

func ParseInputs(inputs string) ([]model.Config, []IstioKind, error)

ParseInputs reads multiple documents from `kubectl` output and checks with the schema. It also returns the list of unrecognized kinds as the second response.

NOTE: This function only decodes a subset of the complete k8s ObjectMeta as identified by the fields in model.ConfigMeta. This would typically only be a problem if a user dumps an configuration object with kubectl and then re-ingests it.

func (*IstioKind) DeepCopy

func (in *IstioKind) DeepCopy() *IstioKind

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IstioKind.

func (*IstioKind) DeepCopyInto

func (in *IstioKind) DeepCopyInto(out *IstioKind)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IstioKind) DeepCopyObject

func (in *IstioKind) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*IstioKind) GetObjectMeta

func (in *IstioKind) GetObjectMeta() meta_v1.ObjectMeta

GetObjectMeta from a wrapper

func (*IstioKind) GetSpec

func (in *IstioKind) GetSpec() map[string]interface{}

GetSpec from a wrapper

func (*IstioKind) SetObjectMeta

func (in *IstioKind) SetObjectMeta(metadata meta_v1.ObjectMeta)

SetObjectMeta for a wrapper

func (*IstioKind) SetSpec

func (in *IstioKind) SetSpec(spec map[string]interface{})

SetSpec for a wrapper

type IstioKindList

type IstioKindList struct {
	meta_v1.TypeMeta `json:",inline"`
	meta_v1.ListMeta `json:"metadata"`
	Items            []IstioKind `json:"items"`
}

IstioKindList is the generic Kubernetes API list wrapper

func (*IstioKindList) DeepCopy

func (in *IstioKindList) DeepCopy() *IstioKindList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IstioKindList.

func (*IstioKindList) DeepCopyInto

func (in *IstioKindList) DeepCopyInto(out *IstioKindList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*IstioKindList) DeepCopyObject

func (in *IstioKindList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*IstioKindList) GetItems

func (in *IstioKindList) GetItems() []IstioObject

GetItems from a wrapper

type IstioObject

type IstioObject interface {
	runtime.Object
	GetSpec() map[string]interface{}
	SetSpec(map[string]interface{})
	GetObjectMeta() meta_v1.ObjectMeta
	SetObjectMeta(meta_v1.ObjectMeta)
}

IstioObject is a k8s wrapper interface for config objects

func ConvertConfig

func ConvertConfig(schema model.ProtoSchema, config model.Config) (IstioObject, error)

ConvertConfig translates Istio config to k8s config JSON

type IstioObjectList

type IstioObjectList interface {
	runtime.Object
	GetItems() []IstioObject
}

IstioObjectList is a k8s wrapper interface for config lists

Jump to

Keyboard shortcuts

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