-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15f450f
commit 753f39c
Showing
5 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,21 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
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 svcneg | ||
|
||
const ( | ||
GroupName = "networking.gke.io" | ||
) |
This file contains 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,21 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
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 | ||
|
||
// Package v1beta1 is the v1beta1 version of the API. | ||
// +groupName=networking.gke.io | ||
package v1beta1 |
This file contains 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 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
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 v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/ingress-gce/pkg/apis/servicenetworkendpointgroup" | ||
) | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: servicenetworkendpointgroup.GroupName, Version: "v1beta1"} | ||
|
||
// 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, | ||
&ServiceNetworkEndpointGroup{}, | ||
&ServiceNetworkEndpointGroupList{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
This file contains 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,118 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
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 v1beta1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
core "k8s.io/kubernetes/pkg/apis/core" | ||
) | ||
|
||
// ServiceNetworkEndpointGroup represents a group of Network Endpoint Groups associated with a service. | ||
|
||
// +genclient | ||
// +genclient:noStatus | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// | ||
// +k8s:openapi-gen=true | ||
type ServiceNetworkEndpointGroup struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ServiceNetworkEndpointGroupSpec `json:"spec,omitempty"` | ||
Status ServiceNetworkEndpointGroupStatus `json:"status,omitempty"` | ||
} | ||
|
||
// ServiceNetworkEndpointGroupSpec is the spec for a ServiceNetworkEndpointGroup resource | ||
// +k8s:openapi-gen=true | ||
type ServiceNetworkEndpointGroupSpec struct{} | ||
|
||
// ServiceNetworkEndpointGroupStatus is the status for a ServiceNetworkEndpointGroup resource | ||
type ServiceNetworkEndpointGroupStatus struct { | ||
NetworkEndpointGroups []NegObjectReference `json:"networkEndpointGroups,omitempty"` | ||
|
||
// Last time the NEG syncer syncs associated NEGs. | ||
// +optional | ||
Conditions []Condition `json:"conditions,omitempty"` | ||
|
||
// Last time the NEG syncer syncs associated NEGs. | ||
// +optional | ||
LastSyncTime metav1.Time `json:"lastTransitionTime,omitempty"` | ||
} | ||
|
||
// NegObjectReference is the object reference to the NEG resource in GCE | ||
type NegObjectReference struct { | ||
// The unique identifier for the NEG resource in GCE API. | ||
Id uint64 `json:"id,omitempty,string"` | ||
|
||
// SelfLink is the GCE Server-defined fully-qualified URL for the GCE NEG resource | ||
SelfLink string `json:"selfLink,omitempty"` | ||
|
||
// NetworkEndpointType: Type of network endpoints in this network | ||
// endpoint group. | ||
NetworkEndpointType NetworkEndpointType `json:"networkEndpointType,omitempty"` | ||
} | ||
|
||
type NetworkEndpointType string | ||
|
||
const ( | ||
VmIpPortEndpointType = NetworkEndpointType("GCE_VM_IP_PORT") | ||
VmIpEndpointType = NetworkEndpointType("GCE_VM_IP") | ||
NonGCPPrivateEndpointType = NetworkEndpointType("NON_GCP_PRIVATE_IP_PORT") | ||
) | ||
|
||
// TODO: Replace Condition with standard Condition | ||
// NegCondition contains details for the current condition of this NEG. | ||
type Condition struct { | ||
// Type is the type of the condition. | ||
// +required | ||
Type string `json:"type" protobuf:"bytes,1,opt,name=type"` | ||
// Status of the condition, one of True, False, Unknown. | ||
// +required | ||
Status core.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` | ||
// ObservedGeneration will not be set for ServiceNetworkEndpointGroup as the spec is empty. | ||
// +optional | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` | ||
// Last time the condition transitioned from one status to another. | ||
// +required | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"` | ||
// The reason for the condition's last transition | ||
// +required | ||
Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"` | ||
// A human readable message indicating details about the transition. | ||
// This field may be empty. | ||
// +required | ||
Message string `json:"message" protobuf:"bytes,6,opt,name=message"` | ||
} | ||
|
||
// These are valid conditions of NEG. | ||
const ( | ||
// Initialized means all NEGs have been created and initialized. | ||
Initialized = "Initialized" | ||
// Synced means all NEGs are being synced. | ||
// The LastSyncTime represents the time when the last sync took place. | ||
Synced = "Synced" | ||
) | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ServiceNetworkEndpointGroupList is a list of ServiceNetworkEndpointGroup resources | ||
type ServiceNetworkEndpointGroupList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
|
||
Items []ServiceNetworkEndpointGroup `json:"items"` | ||
} |