-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NPRecommendationController to Theia Manager
This change adds an example controller to Theia manager, which watches NetworkPolicyRecommendation and exposes querier interface for APIServer to consume. When NetworkPolicyRecommendation is deployed in flow-visibility NS, the k8s resources and be properly returned via REST endpoint /apis/intelligence.theia.antrea.io/v1alpha1/networkpolicyrecommendations/{name} Signed-off-by: Shawn Wang <wshaoquan@vmware.com>
- Loading branch information
Showing
36 changed files
with
2,118 additions
and
17 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
build/charts/theia/crds/network-policy-recommendation-crd.yaml
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,72 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: networkpolicyrecommendations.crd.theia.antrea.io | ||
labels: | ||
app: theia | ||
spec: | ||
group: crd.theia.antrea.io | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
storage: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
required: | ||
- spec | ||
properties: | ||
spec: | ||
type: object | ||
required: | ||
- jobType | ||
properties: | ||
jobType: | ||
type: string | ||
limit: | ||
type: integer | ||
policyType: | ||
type: string | ||
startTime: | ||
type: string | ||
format: datetime | ||
endTime: | ||
type: string | ||
format: datetime | ||
nsAllowList: | ||
type: array | ||
items: | ||
type: string | ||
excludeLabels: | ||
type: boolean | ||
toServices: | ||
type: boolean | ||
executorInstances: | ||
type: integer | ||
driverCoreRequest: | ||
type: string | ||
driverMemory: | ||
type: string | ||
executorCoreRequest: | ||
type: string | ||
executorMemory: | ||
type: string | ||
status: | ||
type: object | ||
properties: | ||
state: | ||
type: string | ||
additionalPrinterColumns: | ||
- description: Current state of the job | ||
jsonPath: .status.state | ||
name: State | ||
type: string | ||
subresources: | ||
status: {} | ||
scope: Namespaced | ||
names: | ||
plural: networkpolicyrecommendations | ||
singular: networkpolicyrecommendation | ||
kind: NetworkPolicyRecommendation | ||
shortNames: | ||
- npr |
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
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,20 @@ | ||
// Copyright 2022 Antrea 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:openapi-gen=true | ||
// +k8s:deepcopy-gen=package | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=crd.theia.antrea.io | ||
|
||
package v1alpha1 |
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,62 @@ | ||
// Copyright 2022 Antrea 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 v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const GroupName = "crd.theia.antrea.io" | ||
|
||
var ( | ||
SchemeGroupVersion = schema.GroupVersion{ | ||
Group: GroupName, | ||
Version: "v1alpha1"} | ||
) | ||
|
||
var ( | ||
SchemeBuilder runtime.SchemeBuilder | ||
localSchemeBuilder = &SchemeBuilder | ||
AddToScheme = localSchemeBuilder.AddToScheme | ||
) | ||
|
||
func init() { | ||
localSchemeBuilder.Register(addKnownTypes) | ||
} | ||
|
||
// Kind takes an unqualified kind and returns back a Group qualified GroupKind | ||
func Kind(kind string) schema.GroupKind { | ||
return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
} | ||
|
||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes( | ||
SchemeGroupVersion, | ||
&NetworkPolicyRecommendation{}, | ||
&NetworkPolicyRecommendationList{}, | ||
) | ||
|
||
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,63 @@ | ||
// Copyright 2022 Antrea 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:openapi-gen=true | ||
// +k8s:deepcopy-gen=package | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=crd.theia.antrea.io | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type NetworkPolicyRecommendation struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec NetworkPolicyRecommendationSpec `json:"spec,omitempty"` | ||
Status NetworkPolicyRecommendationStatus `json:"status,omitempty"` | ||
} | ||
|
||
type NetworkPolicyRecommendationSpec struct { | ||
Type string `json:"type,omitempty"` | ||
Limit int `json:"limit,omitempty"` | ||
PolicyType string `json:"policyType,omitempty"` | ||
StartTime metav1.Time `json:"startTime,omitempty"` | ||
EndTime metav1.Time `json:"endTime,omitempty"` | ||
NSAllowList []string `json:"nsAllowList,omitempty"` | ||
ExcludeLabels bool `json:"excludeLabels,omitempty"` | ||
ToServices bool `json:"toServices,omitempty"` | ||
ExecutorInstances int `json:"executorInstances,omitempty"` | ||
DriverCoreRequest string `json:"driverCoreRequest,omitempty"` | ||
DriverMemory string `json:"driverMemory,omitempty"` | ||
ExecutorCoreRequest string `json:"executorCoreRequest,omitempty"` | ||
ExecutorMemory string `json:"executorMemory,omitempty"` | ||
} | ||
|
||
type NetworkPolicyRecommendationStatus struct { | ||
State string `json:"state,omitempty"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type NetworkPolicyRecommendationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []NetworkPolicyRecommendation `json:"items"` | ||
} |
Oops, something went wrong.