|
| 1 | +/* |
| 2 | +Copyright 2023 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + configv1alpha1 "k8s.io/component-base/config/v1alpha1" |
| 22 | +) |
| 23 | + |
| 24 | +// +k8s:defaulter-gen=true |
| 25 | +// +kubebuilder:object:root=true |
| 26 | + |
| 27 | +// Configuration is the Schema for the configurations API |
| 28 | +type Configuration struct { |
| 29 | + metav1.TypeMeta `json:",inline"` |
| 30 | + |
| 31 | + // Namespace is the namespace in which jobset controller is deployed. |
| 32 | + // It is used as part of DNSName of the webhook Service. |
| 33 | + // If not set, the value is set from the file /var/run/secrets/kubernetes.io/serviceaccount/namespace |
| 34 | + // If the file doesn't exist, default value is kueue-system. |
| 35 | + Namespace *string `json:"namespace,omitempty"` |
| 36 | + |
| 37 | + // ControllerManager returns the configurations for controllers |
| 38 | + ControllerManager `json:",inline"` |
| 39 | + |
| 40 | + // InternalCertManagerment is configuration for internalCertManagerment |
| 41 | + InternalCertManagement *InternalCertManagement `json:"internalCertManagement,omitempty"` |
| 42 | + |
| 43 | + ClientConnection *ClientConnection `json:"clientConnection,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +type ControllerManager struct { |
| 47 | + // Webhook contains the controllers webhook configuration |
| 48 | + // +optional |
| 49 | + Webhook ControllerWebhook `json:"webhook,omitempty"` |
| 50 | + |
| 51 | + // LeaderElection is the LeaderElection config to be used when configuring |
| 52 | + // the manager.Manager leader election |
| 53 | + // +optional |
| 54 | + LeaderElection *configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"` |
| 55 | + |
| 56 | + // Metrics contains the controller metrics configuration |
| 57 | + // +optional |
| 58 | + Metrics ControllerMetrics `json:"metrics,omitempty"` |
| 59 | + |
| 60 | + // Health contains the controller health configuration |
| 61 | + // +optional |
| 62 | + Health ControllerHealth `json:"health,omitempty"` |
| 63 | +} |
| 64 | + |
| 65 | +// ControllerWebhook defines the webhook server for the controller. |
| 66 | +type ControllerWebhook struct { |
| 67 | + // Port is the port that the webhook server serves at. |
| 68 | + // It is used to set webhook.Server.Port. |
| 69 | + // +optional |
| 70 | + Port *int `json:"port,omitempty"` |
| 71 | + |
| 72 | + // Host is the hostname that the webhook server binds to. |
| 73 | + // It is used to set webhook.Server.Host. |
| 74 | + // +optional |
| 75 | + Host string `json:"host,omitempty"` |
| 76 | + |
| 77 | + // CertDir is the directory that contains the server key and certificate. |
| 78 | + // if not set, webhook server would look up the server key and certificate in |
| 79 | + // {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate |
| 80 | + // must be named tls.key and tls.crt, respectively. |
| 81 | + // +optional |
| 82 | + CertDir string `json:"certDir,omitempty"` |
| 83 | +} |
| 84 | + |
| 85 | +// ControllerMetrics defines the metrics configs. |
| 86 | +type ControllerMetrics struct { |
| 87 | + // BindAddress is the TCP address that the controller should bind to |
| 88 | + // for serving prometheus metrics. |
| 89 | + // It can be set to "0" to disable the metrics serving. |
| 90 | + // +optional |
| 91 | + BindAddress string `json:"bindAddress,omitempty"` |
| 92 | +} |
| 93 | + |
| 94 | +// ControllerHealth defines the health configs. |
| 95 | +type ControllerHealth struct { |
| 96 | + // HealthProbeBindAddress is the TCP address that the controller should bind to |
| 97 | + // for serving health probes |
| 98 | + // It can be set to "0" or "" to disable serving the health probe. |
| 99 | + // +optional |
| 100 | + HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"` |
| 101 | + |
| 102 | + // ReadinessEndpointName, defaults to "readyz" |
| 103 | + // +optional |
| 104 | + ReadinessEndpointName string `json:"readinessEndpointName,omitempty"` |
| 105 | + |
| 106 | + // LivenessEndpointName, defaults to "healthz" |
| 107 | + // +optional |
| 108 | + LivenessEndpointName string `json:"livenessEndpointName,omitempty"` |
| 109 | +} |
| 110 | + |
| 111 | +type InternalCertManagement struct { |
| 112 | + // Enable controls whether to enable internal cert management or not. |
| 113 | + // Defaults to true. If you want to use a third-party management, e.g. cert-manager, |
| 114 | + // set it to false. See the user guide for more information. |
| 115 | + Enable *bool `json:"enable,omitempty"` |
| 116 | + |
| 117 | + // WebhookServiceName is the name of the Service used as part of the DNSName. |
| 118 | + // Defaults to jobset-webhook-service. |
| 119 | + WebhookServiceName *string `json:"webhookServiceName,omitempty"` |
| 120 | + |
| 121 | + // WebhookSecretName is the name of the Secret used to store CA and server certs. |
| 122 | + // Defaults to jobset-webhook-server-cert. |
| 123 | + WebhookSecretName *string `json:"webhookSecretName,omitempty"` |
| 124 | +} |
| 125 | + |
| 126 | +type ClientConnection struct { |
| 127 | + // QPS controls the number of queries per second allowed for K8S api server |
| 128 | + // connection. |
| 129 | + QPS *float32 `json:"qps,omitempty"` |
| 130 | + |
| 131 | + // Burst allows extra queries to accumulate when a client is exceeding its rate. |
| 132 | + Burst *int32 `json:"burst,omitempty"` |
| 133 | +} |
0 commit comments