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

Handle the broker in the operator #1085

Merged
merged 1 commit into from
Feb 23, 2021
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
2 changes: 2 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ ignore: |
/deploy/submariner/crds/submariner.io_gateways.yaml
/deploy/submariner/crds/submariner.io_endpoints.yaml
/deploy/submariner/crds/submariner.io_clusters.yaml
/deploy/crds/submariner.io_brokers.yaml
/deploy/crds/submariner.io_submariners.yaml
/deploy/crds/submariner.io_servicediscoveries.yaml
/deploy/mcsapi/crds/multicluster.x_k8s.io_serviceexports.yaml
/deploy/mcsapi/crds/multicluster.x_k8s.io_serviceimports.yaml
/config/crd/bases/submariner.io_brokers.yaml
/config/crd/bases/submariner.io_submariners.yaml
/config/crd/bases/submariner.io_servicediscoveries.yaml
/config/manager/kustomization.yaml
Expand Down
46 changes: 46 additions & 0 deletions apis/submariner/v1alpha1/submariner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,54 @@ type SubmarinerList struct {
Items []Submariner `json:"items"`
}

// BrokerSpec defines the desired state of Broker
// +k8s:openapi-gen=true
type BrokerSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Components []string `json:"components,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating last moment, I just realized you were into this too :/

DefaultCustomDomains []string `json:"defaultCustomDomains,omitempty"`
GlobalnetCIDRRange string `json:"globalnetCIDRRange,omitempty"`
DefaultGlobalnetClusterSize uint `json:"defaultGlobalnetClusterSize,omitempty"`
GlobalnetEnabled bool `json:"globalnetEnabled,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might require changes to subctl to prompt the user to provide the GlobalnetCIDR/GlobalnetClusterSize while joining a new Cluster, if there are no defaults configured when Broker is deployed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already the case, I’ll do that in a separate PR. #1103 tracks this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, or may be not, not sure, if they are going through the process of using the operator directly.... may be it's better to let them be explicit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer #1104 ;-)

}

// BrokerStatus defines the observed state of Broker
// +k8s:openapi-gen=true
type BrokerStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true

// Broker is the Schema for the brokers API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=brokers,scope=Namespaced
// +genclient
// +operator-sdk:csv:customresourcedefinitions:displayName="Broker"
type Broker struct { //nolint:maligned // we want to keep the traditional order
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BrokerSpec `json:"spec,omitempty"`
Status BrokerStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// BrokerList contains a list of Broker
type BrokerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Broker `json:"items"`
}

func init() {
SchemeBuilder.Register(&Submariner{}, &SubmarinerList{})
SchemeBuilder.Register(&Broker{}, &BrokerList{})
}

func (s *Submariner) UnmarshalJSON(data []byte) error {
Expand Down
99 changes: 99 additions & 0 deletions apis/submariner/v1alpha1/zz_generated.deepcopy.go

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

67 changes: 67 additions & 0 deletions config/crd/bases/submariner.io_brokers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: brokers.submariner.io
spec:
group: submariner.io
names:
kind: Broker
listKind: BrokerList
plural: brokers
singular: broker
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: Broker is the Schema for the brokers API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: BrokerSpec defines the desired state of Broker
properties:
components:
items:
type: string
type: array
defaultCustomDomains:
items:
type: string
type: array
defaultGlobalnetClusterSize:
type: integer
globalnetCIDRRange:
type: string
globalnetEnabled:
type: boolean
type: object
status:
description: BrokerStatus defines the observed state of Broker
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
resources:
# - bases/submariner.io_servicediscoveries.yaml
- bases/submariner.io_submariners.yaml
- bases/submariner.io_brokers.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_submariners.yaml
#- patches/webhook_in_servicediscoveries.yaml
#- patches/webhook_in_brokers.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- patches/cainjection_in_submariners.yaml
#- patches/cainjection_in_servicediscoveries.yaml
#- patches/cainjection_in_brokers.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_brokers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: brokers.submariner.io
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_brokers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: brokers.submariner.io
spec:
conversion:
strategy: Webhook
webhookClientConfig:
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
caBundle: Cg==
service:
namespace: system
name: webhook-service
path: /convert
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
resources:
- lighthouse_v2alpha1_serviceexport.yaml
- lighthouse_v2alpha1_serviceimport.yaml
- submariner_v1alpha1_broker.yaml
- submariner_v1alpha1_submariner.yaml
- submariner_v1alpha1_servicediscovery.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
10 changes: 10 additions & 0 deletions config/samples/submariner_v1alpha1_broker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: submariner.io/v1alpha1
kind: Broker
metadata:
name: broker-sample
spec:
# defaultCustomDomains:
# globalnetCIDRRange:
defaultGlobalnetClusterSize: 8192
globalnetEnabled: false
serviceDiscovery: true
Loading