Documentation ¶
Index ¶
- Constants
- func DeleteServicesWithLabel(ctx context.Context, h *helper.Helper, obj metav1.Object, ...) error
- func EndptProtocol(proto *Protocol) string
- func GenericService(svcInfo *GenericServiceDetails) *corev1.Service
- func GetServiceWithName(ctx context.Context, h *helper.Helper, name string, namespace string) (*corev1.Service, error)
- func GetServicesListWithLabel(ctx context.Context, h *helper.Helper, namespace string, ...) (*corev1.ServiceList, error)
- func GetServicesPortDetails(service *corev1.Service, portName string) *corev1.ServicePort
- func MetalLBService(svcInfo *MetalLBServiceDetails) *corev1.Service
- type EmbeddedLabelsAnnotations
- type Endpoint
- type GenericServiceDetails
- type GenericServicePort
- type MetalLBServiceDetails
- type OverrideServiceSpec
- type OverrideSpec
- type Protocol
- type RoutedOverrideSpec
- type Service
- func (s *Service) AddAnnotation(anno map[string]string)
- func (s *Service) CreateOrPatch(ctx context.Context, h *helper.Helper) (ctrl.Result, error)
- func (s *Service) Delete(ctx context.Context, h *helper.Helper) error
- func (s *Service) GetAPIEndpoint(endpointURL *string, protocol *Protocol, path string) (string, error)
- func (s *Service) GetAnnotations() map[string]string
- func (s *Service) GetClusterIPs() []string
- func (s *Service) GetExternalIPs() []string
- func (s *Service) GetIPFamilies() []corev1.IPFamily
- func (s *Service) GetLabels() map[string]string
- func (s *Service) GetServiceHostname() string
- func (s *Service) GetServiceHostnamePort() (string, string)
- func (s *Service) GetServiceType() corev1.ServiceType
- func (s *Service) GetSpec() *corev1.ServiceSpec
- func (s *Service) ToOverrideServiceSpec() (*OverrideServiceSpec, error)
Constants ¶
const ( // EndpointAdmin - admin endpoint EndpointAdmin Endpoint = "admin" // EndpointInternal - internal endpoint EndpointInternal Endpoint = "internal" // EndpointPublic - public endpoint EndpointPublic Endpoint = "public" // AnnotationIngressCreateKey - AnnotationIngressCreateKey = "core.openstack.org/ingress_create" // AnnotationEndpointKey - AnnotationEndpointKey = "endpoint" // AnnotationHostnameKey - AnnotationHostnameKey = "dnsmasq.network.openstack.org/hostname" // ProtocolHTTP - ProtocolHTTP Protocol = "http" // ProtocolHTTPS - ProtocolHTTPS Protocol = "https" // ProtocolNone - ProtocolNone Protocol = "" )
const ( // MetalLBAddressPoolAnnotation - MetalLBAddressPoolAnnotation = "metallb.universe.tf/address-pool" MetalLBAllowSharedIPAnnotation = "metallb.universe.tf/allow-shared-ip" // MetalLBLoadBalancerIPs - MetalLBLoadBalancerIPs = "metallb.universe.tf/loadBalancerIPs" )
Variables ¶
This section is empty.
Functions ¶
func DeleteServicesWithLabel ¶
func DeleteServicesWithLabel( ctx context.Context, h *helper.Helper, obj metav1.Object, labelSelectorMap map[string]string, ) error
DeleteServicesWithLabel - Delete all services in namespace of the obj matching label selector
func EndptProtocol ¶ added in v0.2.0
EndptProtocol returns the protocol for the endpoint if proto is nil http is considered
func GenericService ¶
func GenericService(svcInfo *GenericServiceDetails) *corev1.Service
GenericService func
func GetServiceWithName ¶
func GetServiceWithName( ctx context.Context, h *helper.Helper, name string, namespace string, ) (*corev1.Service, error)
GetServiceWithName - Get service with name in namespace
func GetServicesListWithLabel ¶
func GetServicesListWithLabel( ctx context.Context, h *helper.Helper, namespace string, labelSelectorMap map[string]string, ) (*corev1.ServiceList, error)
GetServicesListWithLabel - Get all services in namespace of the obj matching label selector
func GetServicesPortDetails ¶
func GetServicesPortDetails( service *corev1.Service, portName string, ) *corev1.ServicePort
GetServicesPortDetails - Return ServicePort with name from a Service
func MetalLBService ¶
func MetalLBService(svcInfo *MetalLBServiceDetails) *corev1.Service
MetalLBService func NOTE: (mschuppert) deprecated, can be removed when external endpoint creation moved to openstack-operator
Types ¶
type EmbeddedLabelsAnnotations ¶ added in v0.2.0
type EmbeddedLabelsAnnotations struct { // Map of string keys and values that can be used to organize and categorize // (scope and select) objects. May match selectors of replication controllers // and services. // More info: http://kubernetes.io/docs/user-guide/labels // +optional Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,11,rep,name=labels"` // Annotations is an unstructured key value map stored with a resource that may be // set by external tools to store and retrieve arbitrary metadata. They are not // queryable and should be preserved when modifying objects. // More info: http://kubernetes.io/docs/user-guide/annotations // +optional Annotations map[string]string `json:"annotations,omitempty" protobuf:"bytes,12,rep,name=annotations"` }
EmbeddedLabelsAnnotations is an embedded subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta. Only labels and annotations are included.
func (*EmbeddedLabelsAnnotations) DeepCopy ¶ added in v0.2.0
func (in *EmbeddedLabelsAnnotations) DeepCopy() *EmbeddedLabelsAnnotations
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EmbeddedLabelsAnnotations.
func (*EmbeddedLabelsAnnotations) DeepCopyInto ¶ added in v0.2.0
func (in *EmbeddedLabelsAnnotations) DeepCopyInto(out *EmbeddedLabelsAnnotations)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Endpoint ¶ added in v0.2.0
type Endpoint string
Endpoint - typedef to enumerate Endpoint verbs NOTE: (mschuppert) have to duplicate this for now. Can not have circular dep back to endpoint pkg also can not move it at this point as we have circular dep in test module to keystone.
type GenericServiceDetails ¶
type GenericServiceDetails struct { Name string Namespace string Labels map[string]string Selector map[string]string // deprecated, use Ports Port GenericServicePort Ports []corev1.ServicePort ClusterIP string }
GenericServiceDetails - +kubebuilder:object:generate:=false
type GenericServicePort ¶
type GenericServicePort struct { Name string Port int32 Protocol corev1.Protocol // corev1.ProtocolTCP/ corev1.ProtocolUDP/ corev1.ProtocolSCTP - https://pkg.go.dev/k8s.io/api@v0.23.6/core/v1#Protocol }
GenericServicePort - +kubebuilder:object:generate:=false NOTE: (mschuppert) deprecated, can be removed when service operators moved to Ports
type MetalLBServiceDetails ¶
type MetalLBServiceDetails struct { Name string Namespace string Annotations map[string]string Labels map[string]string Selector map[string]string // deprecated, use Ports Port GenericServicePort Ports []corev1.ServicePort }
MetalLBServiceDetails - +kubebuilder:object:generate:=false
type OverrideServiceSpec ¶ added in v0.2.0
type OverrideServiceSpec struct { // type determines how the Service is exposed. Defaults to ClusterIP. Valid // options are ExternalName, ClusterIP, NodePort, and LoadBalancer. // "ClusterIP" allocates a cluster-internal IP address for load-balancing // to endpoints. Endpoints are determined by the selector or if that is not // specified, by manual construction of an Endpoints object or // EndpointSlice objects. If clusterIP is "None", no virtual IP is // allocated and the endpoints are published as a set of endpoints rather // than a virtual IP. // "NodePort" builds on ClusterIP and allocates a port on every node which // routes to the same endpoints as the clusterIP. // "LoadBalancer" builds on NodePort and creates an external load-balancer // (if supported in the current cloud) which routes to the same endpoints // as the clusterIP. // "ExternalName" aliases this service to the specified externalName. // Several other fields do not apply to ExternalName services. // More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types // +optional Type corev1.ServiceType `json:"type,omitempty" protobuf:"bytes,4,opt,name=type,casttype=ServiceType"` // Supports "ClientIP" and "None". Used to maintain session affinity. // Enable client IP based session affinity. // Must be ClientIP or None. // Defaults to None. // More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies // +optional SessionAffinity corev1.ServiceAffinity `json:"sessionAffinity,omitempty" protobuf:"bytes,7,opt,name=sessionAffinity,casttype=ServiceAffinity"` // If specified and supported by the platform, this will restrict traffic through the cloud-provider // load-balancer will be restricted to the specified client IPs. This field will be ignored if the // cloud-provider does not support the feature." // More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/ // +optional LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty" protobuf:"bytes,9,opt,name=loadBalancerSourceRanges"` // externalName is the external reference that discovery mechanisms will // return as an alias for this service (e.g. a DNS CNAME record). No // proxying will be involved. Must be a lowercase RFC-1123 hostname // (https://tools.ietf.org/html/rfc1123) and requires `type` to be "ExternalName". // +optional ExternalName string `json:"externalName,omitempty" protobuf:"bytes,10,opt,name=externalName"` // externalTrafficPolicy describes how nodes distribute service traffic they // receive on one of the Service's "externally-facing" addresses (NodePorts, // ExternalIPs, and LoadBalancer IPs). If set to "Local", the proxy will configure // the service in a way that assumes that external load balancers will take care // of balancing the service traffic between nodes, and so each node will deliver // traffic only to the node-local endpoints of the service, without masquerading // the client source IP. (Traffic mistakenly sent to a node with no endpoints will // be dropped.) The default value, "Cluster", uses the standard behavior of // routing to all endpoints evenly (possibly modified by topology and other // features). Note that traffic sent to an External IP or LoadBalancer IP from // within the cluster will always get "Cluster" semantics, but clients sending to // a NodePort from within the cluster may need to take traffic policy into account // when picking a node. // +optional ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty" protobuf:"bytes,11,opt,name=externalTrafficPolicy"` // sessionAffinityConfig contains the configurations of session affinity. // +optional SessionAffinityConfig *corev1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty" protobuf:"bytes,14,opt,name=sessionAffinityConfig"` // IPFamilyPolicy represents the dual-stack-ness requested or required by // this Service. If there is no value provided, then this field will be set // to SingleStack. Services can be "SingleStack" (a single IP family), // "PreferDualStack" (two IP families on dual-stack configured clusters or // a single IP family on single-stack clusters), or "RequireDualStack" // (two IP families on dual-stack configured clusters, otherwise fail). The // ipFamilies and clusterIPs fields depend on the value of this field. This // field will be wiped when updating a service to type ExternalName. // +optional IPFamilyPolicy *corev1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty" protobuf:"bytes,17,opt,name=ipFamilyPolicy,casttype=IPFamilyPolicy"` // loadBalancerClass is the class of the load balancer implementation this Service belongs to. // If specified, the value of this field must be a label-style identifier, with an optional prefix, // e.g. "internal-vip" or "example.com/internal-vip". Unprefixed names are reserved for end-users. // This field can only be set when the Service type is 'LoadBalancer'. If not set, the default load // balancer implementation is used, today this is typically done through the cloud provider integration, // but should apply for any default implementation. If set, it is assumed that a load balancer // implementation is watching for Services with a matching class. Any default load balancer // implementation (e.g. cloud providers) should ignore Services that set this field. // This field can only be set when creating or updating a Service to type 'LoadBalancer'. // Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type. // +optional LoadBalancerClass *string `json:"loadBalancerClass,omitempty" protobuf:"bytes,21,opt,name=loadBalancerClass"` // InternalTrafficPolicy describes how nodes distribute service traffic they // receive on the ClusterIP. If set to "Local", the proxy will assume that pods // only want to talk to endpoints of the service on the same node as the pod, // dropping the traffic if there are no local endpoints. The default value, // "Cluster", uses the standard behavior of routing to all endpoints evenly // (possibly modified by topology and other features). // +optional InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty" protobuf:"bytes,22,opt,name=internalTrafficPolicy"` }
OverrideServiceSpec is a subset of the fields included in https://pkg.go.dev/k8s.io/api@v0.26.6/core/v1#ServiceSpec Limited to Type, SessionAffinity, LoadBalancerSourceRanges, ExternalName, ExternalTrafficPolicy, SessionAffinityConfig, IPFamilyPolicy, LoadBalancerClass and InternalTrafficPolicy
func (*OverrideServiceSpec) DeepCopy ¶ added in v0.2.0
func (in *OverrideServiceSpec) DeepCopy() *OverrideServiceSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverrideServiceSpec.
func (*OverrideServiceSpec) DeepCopyInto ¶ added in v0.2.0
func (in *OverrideServiceSpec) DeepCopyInto(out *OverrideServiceSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type OverrideSpec ¶ added in v0.2.0
type OverrideSpec struct { *EmbeddedLabelsAnnotations `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` Spec *OverrideServiceSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` }
OverrideSpec - service override configuration for the Service created to serve traffic to the cluster. Allows for the manifest of the created Service to be overwritten with custom configuration.
func (*OverrideSpec) DeepCopy ¶ added in v0.2.0
func (in *OverrideSpec) DeepCopy() *OverrideSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverrideSpec.
func (*OverrideSpec) DeepCopyInto ¶ added in v0.2.0
func (in *OverrideSpec) DeepCopyInto(out *OverrideSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type RoutedOverrideSpec ¶ added in v0.2.0
type RoutedOverrideSpec struct { OverrideSpec `json:",inline"` EndpointURL *string `json:"endpointURL,omitempty"` }
RoutedOverrideSpec - a routed service override configuration for the Service created to serve traffic to the cluster. Allows for the manifest of the created Service to be overwritten with custom configuration.
func (*RoutedOverrideSpec) DeepCopy ¶ added in v0.2.0
func (in *RoutedOverrideSpec) DeepCopy() *RoutedOverrideSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RoutedOverrideSpec.
func (*RoutedOverrideSpec) DeepCopyInto ¶ added in v0.2.0
func (in *RoutedOverrideSpec) DeepCopyInto(out *RoutedOverrideSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service - +kubebuilder:object:generate:=false
func NewService ¶
func NewService( service *corev1.Service, timeout time.Duration, override *OverrideSpec, ) (*Service, error)
NewService returns an initialized Service.
func (*Service) AddAnnotation ¶
AddAnnotation - Adds annotation and merges it with the current set
func (*Service) CreateOrPatch ¶
CreateOrPatch - creates or patches a service, reconciles after Xs if object won't exist.
func (*Service) GetAPIEndpoint ¶ added in v0.2.0
func (s *Service) GetAPIEndpoint(endpointURL *string, protocol *Protocol, path string) (string, error)
GetAPIEndpoint - returns the API endpoint URL for the service to register in keystone.
func (*Service) GetAnnotations ¶ added in v0.2.0
GetAnnotations - returns annotations of the service
func (*Service) GetClusterIPs ¶
GetClusterIPs - returns the cluster IPs of the created service
func (*Service) GetExternalIPs ¶
GetExternalIPs - returns a list of external IPs of the created service
func (*Service) GetIPFamilies ¶
GetIPFamilies - returns the IP families of the created service
func (*Service) GetServiceHostname ¶
GetServiceHostname - returns the service hostname
func (*Service) GetServiceHostnamePort ¶
GetServiceHostnamePort - returns the service hostname with port if service port is not nil, otherwise returns GetServiceHostname()
func (*Service) GetServiceType ¶ added in v0.2.0
func (s *Service) GetServiceType() corev1.ServiceType
GetServiceType - returns type of the service spec
func (*Service) GetSpec ¶ added in v0.2.0
func (s *Service) GetSpec() *corev1.ServiceSpec
GetSpec - returns the spec of the service
func (*Service) ToOverrideServiceSpec ¶ added in v0.2.0
func (s *Service) ToOverrideServiceSpec() (*OverrideServiceSpec, error)
ToOverrideServiceSpec - convert corev1.ServiceSpec to OverrideServiceSpec