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 = "11032" // ErrGettingResourceCode is generated when there is an error getting the kubernetes resource ErrGettingResourceCode = "11033" // ErrTraverserCode is a collection of errors generated during traversing the resources ErrTraverserCode = "11034" // ErrResourceCannotBeExposedCode is generated when the given resource cannot be exposed ErrResourceCannotBeExposedCode = "11035" // ErrSelectorBasedMapCode is generated when the given resource's selectors can't // be parsed to a map ErrSelectorBasedMapCode = "11036" // ErrProtocolBasedMapCode is generated when the given resource's protocol can't // be parsed to a map ErrProtocolBasedMapCode = "11037" // ErrLableBasedMapCode is generated when the given resource's protocol can't // be parsed to a map ErrLableBasedMapCode = "11038" // ErrPortParsingCode is generated when the given resource's ports can't // be parsed to a slice ErrPortParsingCode = "11039" // ErrGenerateServiceCode is generated when a service cannot be generated // for the given resource ErrGenerateServiceCode = "11040" // ErrConstructingRestHelperCode is generated when a rest helper cannot be generated // for the generated service ErrConstructingRestHelperCode = "11041" // ErrCreatingServiceCode is generated when there is an error deploying the service ErrCreatingServiceCode = "11042" // ErrPodHasNoLabelsCode is generated when there is an error ErrPodHasNoLabelsCode = "11058" // ErrServiceHasNoSelectorsCode is generated when there is an error ErrServiceHasNoSelectorsCode = "11059" // ErrInvalidDeploymentNoSelectorsLabelsCode is generated when there is an error ErrInvalidDeploymentNoSelectorsLabelsCode = "11060" // ErrInvalidDeploymentNoSelectorsCode is generated when there is an error ErrInvalidDeploymentNoSelectorsCode = "11061" // ErrInvalidReplicaNoSelectorsLabelsCode is generated when there is an error ErrInvalidReplicaNoSelectorsLabelsCode = "11062" // ErrInvalidReplicaSetNoSelectorsCode is generated when there is an error ErrInvalidReplicaSetNoSelectorsCode = "11063" // ErrNoPortsFoundForHeadlessResourceCode is generated when there is an error ErrNoPortsFoundForHeadlessResourceCode = "11064" // ErrUnknownSessionAffinityErrCode is generated when there is an error ErrUnknownSessionAffinityErrCode = "11065" // ErrMatchExpressionsConvertionErrCode is generated when there is an error ErrMatchExpressionsConvertionErrCode = "11066" // ErrFailedToExtractPodSelectorErrCode is generated when there is an error ErrFailedToExtractPodSelectorErrCode = "11067" // ErrFailedToExtractPortsCode is generated when there is an error ErrFailedToExtractPortsCode = "11068" // ErrFailedToExtractProtocolsErrCode is generated when there is an error ErrFailedToExtractProtocolsErrCode = "11069" // ErrCannotExposeObjectErrCode is generated when there is an error ErrCannotExposeObjectErrCode = "11070" )
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 occured in the traverser in case this error is not nil, then this callbac function may return without executing the code