mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-09 05:25:14 +09:00
With gpu.enabled the chart passes the GPU flags, serves the three GPU admission webhooks with a cert-manager certificate, and exposes the controller's metrics over HTTPS, where each scrape is authorised through the token and access reviews the controller is granted. The webhooks fail closed, so the controller runs two replicas spread over nodes, under a disruption budget, and a replica is ready only once the caches the webhooks read have synced. The pod webhook selects virt-launcher pods with claim references and leaves migration targets out, which KubeVirt deletes when they stay pending. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
/*
|
|
Copyright 2026 The Cozystack 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 webhook
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/cozystack/cozystack/internal/gpu"
|
|
)
|
|
|
|
// The chart's webhook configurations must call the paths the binary
|
|
// serves and select on the keys it reads.
|
|
func TestChartMatchesTheHandlers(t *testing.T) {
|
|
raw, err := os.ReadFile("../../../packages/system/cozystack-controller/templates/webhooks.yaml")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
chart := string(raw)
|
|
for _, want := range []string{
|
|
"path: " + PathValidateClaim + "\n",
|
|
"path: " + PathMutateVMI + "\n",
|
|
"path: " + PathGatePod + "\n",
|
|
gpu.LabelClaimReference + `: "true"`,
|
|
labelKubeVirt + ": " + valueVirtLauncher,
|
|
"key: " + labelMigrationJob + "\n",
|
|
} {
|
|
if !strings.Contains(chart, want) {
|
|
t.Errorf("webhooks.yaml lacks %q", want)
|
|
}
|
|
}
|
|
}
|