-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from gary-lgy/webhook-scheduler-plugin
- Loading branch information
Showing
34 changed files
with
2,365 additions
and
91 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
110 changes: 110 additions & 0 deletions
110
config/crds/core.kubeadmiral.io_schedulerpluginwebhookconfigurations.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,110 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.11.1 | ||
creationTimestamp: null | ||
name: schedulerpluginwebhookconfigurations.core.kubeadmiral.io | ||
spec: | ||
group: core.kubeadmiral.io | ||
names: | ||
kind: SchedulerPluginWebhookConfiguration | ||
listKind: SchedulerPluginWebhookConfigurationList | ||
plural: schedulerpluginwebhookconfigurations | ||
singular: schedulerpluginwebhookconfiguration | ||
scope: Cluster | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: SchedulerPluginWebhookConfiguration is a webhook that can be | ||
used as a scheduler plugin. | ||
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: | ||
properties: | ||
filterPath: | ||
description: Path for the filter call, empty if not supported. This | ||
path is appended to the URLPrefix when issuing the filter call to | ||
webhook. | ||
type: string | ||
httpTimeout: | ||
default: 5s | ||
description: HTTPTimeout specifies the timeout duration for a call | ||
to the webhook. Timeout fails the scheduling of the workload. Defaults | ||
to 5 seconds. | ||
format: duration | ||
type: string | ||
payloadVersions: | ||
description: PayloadVersions is an ordered list of preferred request | ||
and response versions the webhook expects. The scheduler will try | ||
to use the first version in the list which it supports. If none | ||
of the versions specified in this list supported by the scheduler, | ||
scheduling will fail for this object. | ||
items: | ||
type: string | ||
minItems: 1 | ||
type: array | ||
scorePath: | ||
description: Path for the score call, empty if not supported. This | ||
verb is appended to the URLPrefix when issuing the score call to | ||
webhook. | ||
type: string | ||
selectPath: | ||
description: Path for the select call, empty if not supported. This | ||
verb is appended to the URLPrefix when issuing the select call to | ||
webhook. | ||
type: string | ||
tlsConfig: | ||
description: TLSConfig specifies the transport layer security config. | ||
properties: | ||
caData: | ||
description: CAData holds PEM-encoded bytes (typically read from | ||
a root certificates bundle). | ||
format: byte | ||
type: string | ||
certData: | ||
description: CertData holds PEM-encoded bytes (typically read | ||
from a client certificate file). | ||
format: byte | ||
type: string | ||
insecure: | ||
description: Server should be accessed without verifying the TLS | ||
certificate. For testing only. | ||
type: boolean | ||
keyData: | ||
description: KeyData holds PEM-encoded bytes (typically read from | ||
a client certificate key file). | ||
format: byte | ||
type: string | ||
serverName: | ||
description: ServerName is passed to the server for SNI and is | ||
used in the client to check server certificates against. If | ||
ServerName is empty, the hostname used to contact the server | ||
is used. | ||
type: string | ||
type: object | ||
urlPrefix: | ||
description: URLPrefix at which the webhook is available | ||
type: string | ||
required: | ||
- payloadVersions | ||
- urlPrefix | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
served: true | ||
storage: true |
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
92 changes: 92 additions & 0 deletions
92
pkg/apis/core/v1alpha1/types_schedulerpluginwebhookconfiguration.go
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,92 @@ | ||
/* | ||
Copyright 2018 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. | ||
This file may have been modified by The KubeAdmiral Authors | ||
("KubeAdmiral Modifications"). All KubeAdmiral Modifications | ||
are Copyright 2023 The KubeAdmiral Authors. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:resource:path=schedulerpluginwebhookconfigurations,singular=schedulerpluginwebhookconfiguration,scope=Cluster | ||
// +kubebuilder:object:root=true | ||
|
||
// SchedulerPluginWebhookConfiguration is a webhook that can be used as a scheduler plugin. | ||
type SchedulerPluginWebhookConfiguration struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec SchedulerPluginWebhookConfigurationSpec `json:"spec"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// SchedulerPluginWebhookConfigurationList contains a list of SchedulerPluginWebhookConfiguration. | ||
type SchedulerPluginWebhookConfigurationList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []SchedulerPluginWebhookConfiguration `json:"items"` | ||
} | ||
|
||
type SchedulerPluginWebhookConfigurationSpec struct { | ||
// PayloadVersions is an ordered list of preferred request and response | ||
// versions the webhook expects. | ||
// The scheduler will try to use the first version in | ||
// the list which it supports. If none of the versions specified in this list | ||
// supported by the scheduler, scheduling will fail for this object. | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MinItems=1 | ||
PayloadVersions []string `json:"payloadVersions"` | ||
// URLPrefix at which the webhook is available | ||
// +kubebuilder:validation:Required | ||
URLPrefix string `json:"urlPrefix"` | ||
// Path for the filter call, empty if not supported. This path is appended to the URLPrefix when issuing the filter call to webhook. | ||
FilterPath string `json:"filterPath,omitempty"` | ||
// Path for the score call, empty if not supported. This verb is appended to the URLPrefix when issuing the score call to webhook. | ||
ScorePath string `json:"scorePath,omitempty"` | ||
// Path for the select call, empty if not supported. This verb is appended to the URLPrefix when issuing the select call to webhook. | ||
SelectPath string `json:"selectPath,omitempty"` | ||
// TLSConfig specifies the transport layer security config. | ||
TLSConfig *WebhookTLSConfig `json:"tlsConfig,omitempty"` | ||
// HTTPTimeout specifies the timeout duration for a call to the webhook. Timeout fails the scheduling of the workload. | ||
// Defaults to 5 seconds. | ||
// +kubebuilder:default:="5s" | ||
// +kubebuilder:validation:Format:=duration | ||
HTTPTimeout metav1.Duration `json:"httpTimeout,omitempty"` | ||
} | ||
|
||
// WebhookTLSConfig contains settings to enable TLS with the webhook server. | ||
type WebhookTLSConfig struct { | ||
// Server should be accessed without verifying the TLS certificate. For testing only. | ||
Insecure bool `json:"insecure,omitempty"` | ||
// ServerName is passed to the server for SNI and is used in the client to check server | ||
// certificates against. If ServerName is empty, the hostname used to contact the | ||
// server is used. | ||
ServerName string `json:"serverName,omitempty"` | ||
|
||
// CertData holds PEM-encoded bytes (typically read from a client certificate file). | ||
CertData []byte `json:"certData,omitempty"` | ||
// KeyData holds PEM-encoded bytes (typically read from a client certificate key file). | ||
KeyData []byte `json:"keyData,omitempty"` | ||
// CAData holds PEM-encoded bytes (typically read from a root certificates bundle). | ||
CAData []byte `json:"caData,omitempty"` | ||
} |
Oops, something went wrong.