Documentation ¶
Index ¶
- Variables
- func ErrCannotExposeObjectErr(kind schema.GroupKind) error
- func ErrConstructingRestHelper(err error) error
- func ErrCreatingService(err error) error
- func ErrExposeResource(err error) error
- func ErrFailedToExtractPodSelectorErr(object runtime.Object) error
- func ErrFailedToExtractPorts(object runtime.Object) error
- func ErrFailedToExtractProtocolsErr(object runtime.Object) error
- func ErrGenerateService(err error) error
- func ErrGettingResource(err error) error
- func ErrLabelBasedMap(err error) error
- func ErrMatchExpressionsConvertionErr(me []metav1.LabelSelectorRequirement) error
- func ErrPortParsing(err error) error
- func ErrProtocolBasedMap(err error) error
- func ErrResourceCannotBeExposed(err error, resourceKind string) error
- func ErrSelectorBasedMap(err error) error
- func ErrTraverser(err error) error
- func ErrUnknownSessionAffinityErr(sa SessionAffinity) error
- func Expose(clientSet *kubernetes.Clientset, restConfig rest.Config, config Config, ...) ([]*v1.Service, error)
- func Remove(svc, ns string, client *kubernetes.Clientset) error
- type Config
- type Object
- type Resource
- type ServiceType
- type SessionAffinity
- type Traverser
- type VisitCB
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExposeResourceCode is generated while exposing the kubernetes resource ErrExposeResourceCode = "meshkit-11205" // ErrGettingResourceCode is generated when there is an error getting the kubernetes resource ErrGettingResourceCode = "meshkit-11206" // ErrTraverserCode is a collection of errors generated during traversing the resources ErrTraverserCode = "meshkit-11207" // ErrResourceCannotBeExposedCode is generated when the given resource cannot be exposed ErrResourceCannotBeExposedCode = "meshkit-11208" // ErrSelectorBasedMapCode is generated when the given resource's selectors can't // be parsed to a map ErrSelectorBasedMapCode = "meshkit-11209" // ErrProtocolBasedMapCode is generated when the given resource's protocol can't // be parsed to a map ErrProtocolBasedMapCode = "meshkit-11210" // ErrLableBasedMapCode is generated when the given resource's protocol can't // be parsed to a map ErrLableBasedMapCode = "meshkit-11211" // ErrPortParsingCode is generated when the given resource's ports can't // be parsed to a slice ErrPortParsingCode = "meshkit-11212" // ErrGenerateServiceCode is generated when a service cannot be generated // for the given resource ErrGenerateServiceCode = "meshkit-11213" // ErrConstructingRestHelperCode is generated when a rest helper cannot be generated // for the generated service ErrConstructingRestHelperCode = "meshkit-11214" // ErrCreatingServiceCode is generated when there is an error deploying the service ErrCreatingServiceCode = "meshkit-11215" // ErrPodHasNoLabelsCode is generated when there is an error ErrPodHasNoLabelsCode = "meshkit-11216" // ErrServiceHasNoSelectorsCode is generated when there is an error ErrServiceHasNoSelectorsCode = "meshkit-11217" // ErrInvalidDeploymentNoSelectorsLabelsCode is generated when there is an error ErrInvalidDeploymentNoSelectorsLabelsCode = "meshkit-11218" // ErrInvalidDeploymentNoSelectorsCode is generated when there is an error ErrInvalidDeploymentNoSelectorsCode = "meshkit-11219" // ErrInvalidReplicaNoSelectorsLabelsCode is generated when there is an error ErrInvalidReplicaNoSelectorsLabelsCode = "meshkit-11220" // ErrInvalidReplicaSetNoSelectorsCode is generated when there is an error ErrInvalidReplicaSetNoSelectorsCode = "meshkit-11221" // ErrNoPortsFoundForHeadlessResourceCode is generated when there is an error ErrNoPortsFoundForHeadlessResourceCode = "meshkit-11222" // ErrUnknownSessionAffinityErrCode is generated when there is an error ErrUnknownSessionAffinityErrCode = "meshkit-11223" // ErrMatchExpressionsConvertionErrCode is generated when there is an error ErrMatchExpressionsConvertionErrCode = "meshkit-11224" // ErrFailedToExtractPodSelectorErrCode is generated when there is an error ErrFailedToExtractPodSelectorErrCode = "meshkit-11225" // ErrFailedToExtractPortsCode is generated when there is an error ErrFailedToExtractPortsCode = "meshkit-11226" // ErrFailedToExtractProtocolsErrCode is generated when there is an error ErrFailedToExtractProtocolsErrCode = "meshkit-11227" // ErrCannotExposeObjectErrCode is generated when there is an error ErrCannotExposeObjectErrCode = "meshkit-11228" )
var ( // ErrPodHasNoLabels is the error for pods with no labels ErrPodHasNoLabels = errors.New(ErrPodHasNoLabelsCode, errors.Alert, []string{"the pod has no labels and cannot be exposed"}, []string{}, []string{}, []string{}) // ErrServiceHasNoSelectors is the error for service with no selectors ErrServiceHasNoSelectors = errors.New(ErrServiceHasNoSelectorsCode, errors.Alert, []string{"the service has no pod selector set"}, []string{}, []string{}, []string{}) // ErrInvalidDeploymentNoSelectorsLabels is the error for deployment (v1beta1) with no selectors and labels ErrInvalidDeploymentNoSelectorsLabels = errors.New(ErrInvalidDeploymentNoSelectorsLabelsCode, errors.Alert, []string{"the deployment has no labels or selectors and cannot be exposed"}, []string{}, []string{}, []string{}) // ErrInvalidDeploymentNoSelectors is the error for deployment (v1) with no selectors ErrInvalidDeploymentNoSelectors = errors.New(ErrInvalidDeploymentNoSelectorsCode, errors.Alert, []string{"invalid deployment: no selectors, therefore cannot be exposed"}, []string{}, []string{}, []string{}) // ErrInvalidReplicaNoSelectorsLabels is the error for replicaset (v1beta1) with no selectors and labels ErrInvalidReplicaNoSelectorsLabels = errors.New(ErrInvalidReplicaNoSelectorsLabelsCode, errors.Alert, []string{"the replica set has no labels or selectors and cannot be exposed"}, []string{}, []string{}, []string{}) // ErrInvalidReplicaSetNoSelectors is the error for replicaset (v1) with no selectors ErrInvalidReplicaSetNoSelectors = errors.New(ErrInvalidReplicaSetNoSelectorsCode, errors.Alert, []string{"invalid replicaset: no selectors, therefore cannot be exposed"}, []string{}, []string{}, []string{}) // ErrNoPortsFoundForHeadlessResource is the error when no ports are found for non headless resource ErrNoPortsFoundForHeadlessResource = errors.New(ErrNoPortsFoundForHeadlessResourceCode, errors.Alert, []string{"no ports found for the non headless resource"}, []string{}, []string{}, []string{}) )
Functions ¶
func ErrCannotExposeObjectErr ¶
ErrCannotExposeObjectErr is the error if the given object cannot be exposed
func ErrConstructingRestHelper ¶
ErrConstructingRestHelper is the error when a rest helper cannot be generated for the generated service
func ErrCreatingService ¶
ErrCreatingService is the error when there is an error deploying the service
func ErrExposeResource ¶
ErrExposeResource is the error when there is an error exposing the kubernetes resource
func ErrFailedToExtractPodSelectorErr ¶
ErrFailedToExtractPodSelectorErr is the error for failed to extract pod selector
func ErrFailedToExtractPorts ¶
ErrFailedToExtractPorts is the error for failed to extract ports
func ErrFailedToExtractProtocolsErr ¶
ErrFailedToExtractProtocolsErr is the error for extracting ports
func ErrGenerateService ¶
ErrGenerateService is the error when a service cannot be generated for the given resource
func ErrGettingResource ¶
ErrGettingResource is the error when there is an error getting the kubernetes resource
func ErrLabelBasedMap ¶
ErrLabelBasedMap is the error when the given resource's labels can't be parsed to a map
func ErrMatchExpressionsConvertionErr ¶
func ErrMatchExpressionsConvertionErr(me []metav1.LabelSelectorRequirement) error
ErrMatchExpressionsConvertionErr is the error for failed match expression conversion
func ErrPortParsing ¶
ErrPortParsing is the error when the given resource's ports can't be parsed to a slice
func ErrProtocolBasedMap ¶
ErrProtocolBasedMap is the error when the given resource's protocols can't be parsed to a map
func ErrResourceCannotBeExposed ¶
ErrResourceCannotBeExposed is the error if the given resource cannot be exposed
func ErrSelectorBasedMap ¶
ErrSelectorBasedMap is the error when the given resource's selectors can't be parsed to a map
func ErrTraverser ¶
ErrTraverser is the error is collection of error generated while traversing the resources
func ErrUnknownSessionAffinityErr ¶
func ErrUnknownSessionAffinityErr(sa SessionAffinity) error
ErrUnknownSessionAffinityErr is the error for unknown session affinity
Types ¶
type Config ¶
type Config struct { // Type is the type of the service // could be either ClusterIP, NodePort // or LoadBalancer. If an empty is string // is provided then "ClusterIP" type service // is created Type ServiceType // LoadBalancerIP is the IP address that would // be used if the service type is "loadBalancer" // based. This IP address should be a valid // IP address which can be provisioned by // the service provider LoadBalancerIP string // ClusterIP is the IP address that would be // used if the service type is "ClusterIP" or // an empty string. This IP address should be // a valid clusterIP. ClusterIP string // Namespace where the service should be created // ideally this should be the same as the service // that needs to be exposed // // It defaults to the namespace of the target resource Namespace string // SessionAffinity of the service // could be "None" or "ClientIP" SessionAffinity SessionAffinity // Name of the service Name string // Annotations will be used to annotate the generated service // // It will not effect the target resource Annotations map[string]string // Log is the logger that would be used for logging Log logger.Handler }
Config is a the struct for Expose configuration
type Resource ¶
Resource defines the structure for the resource definition used by the traverser to locate the kubernetes resources
type ServiceType ¶
type ServiceType string
ServiceType us the type for Kubernetes resources' Type
const ( ClusterIP ServiceType = "ClusterIP" NodePort ServiceType = "NodePort" LoadBalancer ServiceType = "LoadBalancer" )
Supported service type
type SessionAffinity ¶
type SessionAffinity string
SessionAffinity is the type for Kubernetes resources' SessionAffinity
const ( // None is the "None" type SessionAffinity None SessionAffinity = "None" // ClientIP is the "ClientIP" type SessionAffinity ClientIP SessionAffinity = "ClientIP" )
type Traverser ¶
type Traverser struct { Resources []Resource Client *kubernetes.Clientset Logger logger.Handler }
Traverser can be used to traverse resources in the cluster
type VisitCB ¶
VisitCB is the type for callback function that is invoked when the traverser reaches one of the given kubernetes resource
The first argument for the VisitCB is the kubernetes resource itself while the other is the error that may have occurred in the traverser in case this error is not nil, then this callbac function may return without executing the code