-
Notifications
You must be signed in to change notification settings - Fork 205
Create GlobalnetEgressIP CRD types and associated items #1158
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| © 2021 Red Hat, Inc. and others | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| // +k8s:deepcopy-gen=package,register | ||
|
|
||
| // +groupName=submariner.io | ||
| package v1alpha1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| © 2021 Red Hat, Inc. and others | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/apimachinery/pkg/runtime/schema" | ||
| ) | ||
|
|
||
| // SchemeGroupVersion is group version used to register these objects | ||
| var SchemeGroupVersion = schema.GroupVersion{Group: "submariner.io", Version: "v1alpha1"} | ||
|
|
||
| // Kind takes an unqualified kind and returns back a Group qualified GroupKind | ||
| func Kind(kind string) schema.GroupKind { | ||
| return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
| } | ||
|
|
||
| // Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
| func Resource(resource string) schema.GroupResource { | ||
| return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
| } | ||
|
|
||
| var ( | ||
| SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
| AddToScheme = SchemeBuilder.AddToScheme | ||
| ) | ||
|
|
||
| // Adds the list of known types to Scheme. | ||
| func addKnownTypes(scheme *runtime.Scheme) error { | ||
| scheme.AddKnownTypes(SchemeGroupVersion, | ||
| &GlobalnetEgressIP{}, | ||
| &GlobalnetEgressIPList{}, | ||
| ) | ||
| metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| © 2021 Red Hat, Inc. and others | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package v1alpha1 | ||
|
|
||
| import ( | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // +genclient | ||
| // +genclient:noStatus | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| type GlobalnetEgressIP struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| // Spec is the specification of desired behavior of GlobalnetEgressIP object | ||
| Spec EgressIPSpec `json:"spec"` | ||
|
|
||
| // Observed status of GlobalnetEgressIP. Its a read-only field. | ||
| // +optional | ||
| Status EgressIPStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| type EgressIPSpec struct { | ||
| // User can explicitly request a specific GlobalIP and this should be a valid IPaddress | ||
| // from globalnetCIDR allocated to the Cluster. If the requested globalIP falls outside | ||
| // of the globalnetCIDR or is already allocated (either fully or partially), then Status | ||
| // field will be set to Error with appropriate message. | ||
| // If this field is not specified, a single globalIP will be allocated. | ||
| // This field cannot be changed through updates. | ||
| // +optional | ||
| GlobalIP string `json:"globalIP,omitempty"` | ||
|
|
||
| // The number of globalIP's requested. Globalnet Controller will allocate the requested | ||
| // number of contiguous GlobalIPs for this GlobalnetEgressIP object. | ||
| // User can specify this field while omitting GlobalIP. In such cases, Globalnet will | ||
| // auto-allocate the requested number of contiguous GlobalIPs. | ||
| // If unspecified, NumGlobalIPs defaults to 1. | ||
| // +optional | ||
| NumGlobalIPs int `json:"numGlobalIPs,omitempty"` | ||
|
|
||
| // Selects the Namespaces to which this GlobalnetEgressIP object applies. | ||
| // If an empty namespaceSelector: {} is configured, it selects all namespaces. | ||
| // If an empty namespaceSelector: {} is configured along with empty PodSelector, it applies | ||
| // to whole Cluster. | ||
| // On the other hand, if you omit specifying namespaceSelector, it does not select any | ||
| // namespaces and selects only Pods from the namespace where the GlobalnetEgressIP is | ||
| // deployed to. | ||
|
sridhargaddam marked this conversation as resolved.
|
||
| // +optional | ||
| NamespaceSelector metav1.LabelSelector `json:"namespaceSelector,omitempty"` | ||
|
|
||
| // Selects the pods whose label match the definition. This is an optional field and | ||
| // in case it is not set, it results in all the Pods selected from the NamespaceSelector. | ||
| // In case it is set, its intersected with NamespaceSelector, and only Pods that match the | ||
|
sridhargaddam marked this conversation as resolved.
|
||
| // PodSelector and present in the NamespaceSelector will have the GlobalIPs as EgressIPs. | ||
| // Either namespaceSelector or podSelector have to be specified. If both are omitted, | ||
| // its considered as an error. | ||
|
sridhargaddam marked this conversation as resolved.
|
||
| // When a Pod or Namespace matches multiple GlobalnetEgressIP objects, there is no guarantee | ||
| // which of the globalIP address that are assigned to GlobalnetEgressIP will be used. | ||
| // +optional | ||
| PodSelector metav1.LabelSelector `json:"podSelector,omitempty"` | ||
| } | ||
|
|
||
| // GlobalnetEgressIPStatus identifies the status of GlobalnetEgressIP request. | ||
| type GlobalnetEgressIPStatus string | ||
|
|
||
| const ( | ||
| // GlobalnetEgressIPSuccess means that Globalnet was able to successfully | ||
| // allocate the GlobalIP as requested in GlobalnetEgressIP object. | ||
| GlobalnetEgressIPSuccess GlobalnetEgressIPStatus = "Success" | ||
|
|
||
| // GlobalnetEgressIPError means that Globalnet was unable to allocate the | ||
| // requested GlobalIP. | ||
| GlobalnetEgressIPError GlobalnetEgressIPStatus = "Error" | ||
| ) | ||
|
|
||
| type EgressIPStatus struct { | ||
| // Status is one of {"Success", "Error"} | ||
| Status GlobalnetEgressIPStatus `json:"status,omitempty"` | ||
|
|
||
| // +optional | ||
| Message *string `json:"message,omitempty"` | ||
|
|
||
| // The list of GlobalIPs assigned via this GlobalnetEgressIP object. | ||
| GlobalIPs []string `json:"globalIPs"` | ||
|
|
||
| // The Namespaces to which the GlobalIPs are applied. | ||
| Namespaces []string `json:"namespaces"` | ||
|
|
||
| // The Pods to which the GlobalIPs are applied. | ||
| Pods []string `json:"pods"` | ||
| } | ||
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| type GlobalnetEgressIPList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata"` | ||
| Items []GlobalnetEgressIP `json:"items"` | ||
| } | ||
140 changes: 140 additions & 0 deletions
140
pkg/apis/submariner.io/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.