Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create WatcherAPI service #37

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions api/bases/watcher.openstack.org_watcherapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,51 @@ spec:
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
override:
description: |-
Override, provides the ability to override the generated manifest of
several child resources.
properties:
service:
additionalProperties:
description: MetalLBConfig to configure the MetalLB loadbalancer
service
properties:
ipAddressPool:
description: IPAddressPool expose VIP via MetalLB on the
IPAddressPool
minLength: 1
type: string
loadBalancerIPs:
description: LoadBalancerIPs, request given IPs from the
pool if available. Using a list to allow dual stack (IPv4/IPv6)
support
items:
type: string
type: array
sharedIP:
default: true
description: SharedIP if true, VIP/VIPs get shared with
multiple services
type: boolean
sharedIPKey:
default: ""
description: |-
SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
SharedIP is true, but no SharedIPKey specified.
type: string
required:
- ipAddressPool
type: object
description: |-
Override configuration for the Service created to serve traffic to
the cluster.
The key must be the endpoint type (public, internal)
temporarily use MetalLBConfig struct, later we'll switch to
service.RoutedOverrideSpec
type: object
type: object
passwordSelectors:
default:
service: WatcherPassword
Expand Down
45 changes: 45 additions & 0 deletions api/bases/watcher.openstack.org_watchers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,51 @@ spec:
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
override:
description: |-
Override, provides the ability to override the generated manifest of
several child resources.
properties:
service:
additionalProperties:
description: MetalLBConfig to configure the MetalLB loadbalancer
service
properties:
ipAddressPool:
description: IPAddressPool expose VIP via MetalLB on
the IPAddressPool
minLength: 1
type: string
loadBalancerIPs:
description: LoadBalancerIPs, request given IPs from
the pool if available. Using a list to allow dual
stack (IPv4/IPv6) support
items:
type: string
type: array
sharedIP:
default: true
description: SharedIP if true, VIP/VIPs get shared with
multiple services
type: boolean
sharedIPKey:
default: ""
description: |-
SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
SharedIP is true, but no SharedIPKey specified.
type: string
required:
- ipAddressPool
type: object
description: |-
Override configuration for the Service created to serve traffic to
the cluster.
The key must be the endpoint type (public, internal)
temporarily use MetalLBConfig struct, later we'll switch to
service.RoutedOverrideSpec
type: object
type: object
replicas:
default: 1
description: Replicas of Watcher service to run
Expand Down
24 changes: 24 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ type WatcherSubCrsTemplate struct {
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
}

// MetalLBConfig to configure the MetalLB loadbalancer service
type MetalLBConfig struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// IPAddressPool expose VIP via MetalLB on the IPAddressPool
IPAddressPool string `json:"ipAddressPool"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=true
// SharedIP if true, VIP/VIPs get shared with multiple services
SharedIP bool `json:"sharedIP"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=""
// SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
// Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
// SharedIP is true, but no SharedIPKey specified.
SharedIPKey string `json:"sharedIPKey"`

// +kubebuilder:validation:Optional
// LoadBalancerIPs, request given IPs from the pool if available. Using a list to allow dual stack (IPv4/IPv6) support
LoadBalancerIPs []string `json:"loadBalancerIPs"`
}

type WatcherImages struct {
// +kubebuilder:validation:Required
// APIContainerImageURL
Expand Down
22 changes: 22 additions & 0 deletions api/v1beta1/watcherapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -33,6 +34,11 @@ type WatcherAPISpec struct {
Secret string `json:"secret"`

WatcherSubCrsCommon `json:",inline"`

// +kubebuilder:validation:Optional
// Override, provides the ability to override the generated manifest of
// several child resources.
Override APIOverrideSpec `json:"override,omitempty"`
}

// WatcherAPIStatus defines the observed state of WatcherAPI
Expand All @@ -53,10 +59,26 @@ type WatcherAPIStatus struct {
Hash map[string]string `json:"hash,omitempty"`
}

// APIOverrideSpec to override the generated manifest of several child
// resources.
type APIOverrideSpec struct {
// Override configuration for the Service created to serve traffic to
// the cluster.
// The key must be the endpoint type (public, internal)
// temporarily use MetalLBConfig struct, later we'll switch to
// service.RoutedOverrideSpec
Service map[service.Endpoint]MetalLBConfig `json:"service,omitempty"`
}

// WatcherAPITemplate defines the input parameters specified by the user to
// create a WatcherAPI via higher level CRDs.
type WatcherAPITemplate struct {
WatcherSubCrsTemplate `json:",inline"`

// +kubebuilder:validation:Optional
// Override, provides the ability to override the generated manifest of
// several child resources.
Override APIOverrideSpec `json:"override,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
45 changes: 45 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions config/crd/bases/watcher.openstack.org_watcherapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,51 @@ spec:
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
override:
description: |-
Override, provides the ability to override the generated manifest of
several child resources.
properties:
service:
additionalProperties:
description: MetalLBConfig to configure the MetalLB loadbalancer
service
properties:
ipAddressPool:
description: IPAddressPool expose VIP via MetalLB on the
IPAddressPool
minLength: 1
type: string
loadBalancerIPs:
description: LoadBalancerIPs, request given IPs from the
pool if available. Using a list to allow dual stack (IPv4/IPv6)
support
items:
type: string
type: array
sharedIP:
default: true
description: SharedIP if true, VIP/VIPs get shared with
multiple services
type: boolean
sharedIPKey:
default: ""
description: |-
SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
SharedIP is true, but no SharedIPKey specified.
type: string
required:
- ipAddressPool
type: object
description: |-
Override configuration for the Service created to serve traffic to
the cluster.
The key must be the endpoint type (public, internal)
temporarily use MetalLBConfig struct, later we'll switch to
service.RoutedOverrideSpec
type: object
type: object
passwordSelectors:
default:
service: WatcherPassword
Expand Down
45 changes: 45 additions & 0 deletions config/crd/bases/watcher.openstack.org_watchers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,51 @@ spec:
NodeSelector to target subset of worker nodes running this component. Setting here overrides
any global NodeSelector settings within the Watcher CR.
type: object
override:
description: |-
Override, provides the ability to override the generated manifest of
several child resources.
properties:
service:
additionalProperties:
description: MetalLBConfig to configure the MetalLB loadbalancer
service
properties:
ipAddressPool:
description: IPAddressPool expose VIP via MetalLB on
the IPAddressPool
minLength: 1
type: string
loadBalancerIPs:
description: LoadBalancerIPs, request given IPs from
the pool if available. Using a list to allow dual
stack (IPv4/IPv6) support
items:
type: string
type: array
sharedIP:
default: true
description: SharedIP if true, VIP/VIPs get shared with
multiple services
type: boolean
sharedIPKey:
default: ""
description: |-
SharedIPKey specifies the sharing key which gets set as the annotation on the LoadBalancer service.
Services which share the same VIP must have the same SharedIPKey. Defaults to the IPAddressPool if
SharedIP is true, but no SharedIPKey specified.
type: string
required:
- ipAddressPool
type: object
description: |-
Override configuration for the Service created to serve traffic to
the cluster.
The key must be the endpoint type (public, internal)
temporarily use MetalLBConfig struct, later we'll switch to
service.RoutedOverrideSpec
type: object
type: object
replicas:
default: 1
description: Replicas of Watcher service to run
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- security.openshift.io
resourceNames:
Expand Down
1 change: 1 addition & 0 deletions controllers/watcher_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ func (r *WatcherReconciler) ensureAPI(
Resources: instance.Spec.APIServiceTemplate.Resources,
ServiceAccount: "watcher-" + instance.Name,
},
Override: instance.Spec.APIServiceTemplate.Override,
}

// If NodeSelector is not specified in Watcher APIServiceTemplate, the current
Expand Down
Loading
Loading