mirror of
https://github.com/cozystack/cozystack.git
synced 2026-03-11 01:18:57 +00:00
Compare commits
77 Commits
workloadmo
...
v0.38.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa428457db | ||
|
|
975011e04e | ||
|
|
0d88aa394a | ||
|
|
ec1a150d2c | ||
|
|
cbc6cd2567 | ||
|
|
fb7e39eaab | ||
|
|
9cc348733f | ||
|
|
00e0f45de3 | ||
|
|
b5c264de7d | ||
|
|
4ff60e4539 | ||
|
|
294458e7c4 | ||
|
|
42cb0e6974 | ||
|
|
73bf0e5f7e | ||
|
|
f512061a1c | ||
|
|
12db4fc520 | ||
|
|
91ddbb06ef | ||
|
|
7d2250be4d | ||
|
|
a070573af9 | ||
|
|
492aef93f5 | ||
|
|
23e6cf735a | ||
|
|
c5b1177149 | ||
|
|
84133ef2d3 | ||
|
|
1c9ae2bec5 | ||
|
|
bdff61eaed | ||
|
|
3d4ad39bce | ||
|
|
f2f575b450 | ||
|
|
aba4d2c977 | ||
|
|
e4021bbf57 | ||
|
|
ef8612e882 | ||
|
|
32b58dec5f | ||
|
|
1bafb7fb4f | ||
|
|
bc61d13ad3 | ||
|
|
972548cab4 | ||
|
|
bb8d07d384 | ||
|
|
6fdc9b0bad | ||
|
|
9c040cd42f | ||
|
|
5414d37376 | ||
|
|
a9818a7ce7 | ||
|
|
1651d94291 | ||
|
|
2b4afde373 | ||
|
|
a5c9bfabee | ||
|
|
143832c0b4 | ||
|
|
298206efc7 | ||
|
|
c81b222cf6 | ||
|
|
9d6af84449 | ||
|
|
7ddd9cf4a8 | ||
|
|
a861814c24 | ||
|
|
d65d293fbc | ||
|
|
523510469c | ||
|
|
cf5b2f2bbb | ||
|
|
4e5343e36c | ||
|
|
d8237b4321 | ||
|
|
83c3b0ca12 | ||
|
|
e1590aad1b | ||
|
|
304338d697 | ||
|
|
b65d639ecb | ||
|
|
339e71331f | ||
|
|
08be385665 | ||
|
|
2f0657f8ba | ||
|
|
a64ba184ce | ||
|
|
00328c8a31 | ||
|
|
7009c8da37 | ||
|
|
63db8ca009 | ||
|
|
369384f5ec | ||
|
|
4278692763 | ||
|
|
edc942b6c1 | ||
|
|
4c71e7fe57 | ||
|
|
627022972d | ||
|
|
1e8a9ee980 | ||
|
|
b45f4a6545 | ||
|
|
5b96190be8 | ||
|
|
8849570f74 | ||
|
|
b6958320b2 | ||
|
|
0a210bf5d3 | ||
|
|
90d50fef48 | ||
|
|
ea74d7d59a | ||
|
|
74262977f6 |
3
.github/workflows/pull-requests.yaml
vendored
3
.github/workflows/pull-requests.yaml
vendored
@@ -33,6 +33,9 @@ jobs:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Run unit tests
|
||||
run: make unit-tests
|
||||
|
||||
- name: Set up Docker config
|
||||
run: |
|
||||
if [ -d ~/.docker ]; then
|
||||
|
||||
7
Makefile
7
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: manifests repos assets
|
||||
.PHONY: manifests repos assets unit-tests helm-unit-tests
|
||||
|
||||
build-deps:
|
||||
@command -V find docker skopeo jq gh helm > /dev/null
|
||||
@@ -46,6 +46,11 @@ test:
|
||||
make -C packages/core/testing apply
|
||||
make -C packages/core/testing test
|
||||
|
||||
unit-tests: helm-unit-tests
|
||||
|
||||
helm-unit-tests:
|
||||
hack/helm-unit-tests.sh
|
||||
|
||||
prepare-env:
|
||||
make -C packages/core/testing apply
|
||||
make -C packages/core/testing prepare-cluster
|
||||
|
||||
@@ -80,58 +80,41 @@ EOF
|
||||
# Wait for the machine deployment to scale to 2 replicas (timeout after 1 minute)
|
||||
kubectl wait machinedeployment kubernetes-${test_name}-md0 -n tenant-test --timeout=1m --for=jsonpath='{.status.replicas}'=2
|
||||
# Get the admin kubeconfig and save it to a file
|
||||
kubectl get secret kubernetes-${test_name}-admin-kubeconfig -ojsonpath='{.data.super-admin\.conf}' -n tenant-test | base64 -d > tenantkubeconfig
|
||||
kubectl get secret kubernetes-${test_name}-admin-kubeconfig -ojsonpath='{.data.super-admin\.conf}' -n tenant-test | base64 -d > tenantkubeconfig-${test_name}
|
||||
|
||||
# Update the kubeconfig to use localhost for the API server
|
||||
yq -i ".clusters[0].cluster.server = \"https://localhost:${port}\"" tenantkubeconfig
|
||||
yq -i ".clusters[0].cluster.server = \"https://localhost:${port}\"" tenantkubeconfig-${test_name}
|
||||
|
||||
|
||||
# Set up port forwarding to the Kubernetes API server for a 200 second timeout
|
||||
bash -c 'timeout 300s kubectl port-forward service/kubernetes-'"${test_name}"' -n tenant-test '"${port}"':6443 > /dev/null 2>&1 &'
|
||||
# Verify the Kubernetes version matches what we expect (retry for up to 20 seconds)
|
||||
timeout 20 sh -ec 'until kubectl --kubeconfig tenantkubeconfig version 2>/dev/null | grep -Fq "Server Version: ${k8s_version}"; do sleep 5; done'
|
||||
timeout 20 sh -ec 'until kubectl --kubeconfig tenantkubeconfig-'"${test_name}"' version 2>/dev/null | grep -Fq "Server Version: ${k8s_version}"; do sleep 5; done'
|
||||
|
||||
# Wait for the nodes to be ready (timeout after 2 minutes)
|
||||
timeout 3m bash -c '
|
||||
until [ "$(kubectl --kubeconfig tenantkubeconfig get nodes -o jsonpath="{.items[*].metadata.name}" | wc -w)" -eq 2 ]; do
|
||||
until [ "$(kubectl --kubeconfig tenantkubeconfig-'"${test_name}"' get nodes -o jsonpath="{.items[*].metadata.name}" | wc -w)" -eq 2 ]; do
|
||||
sleep 2
|
||||
done
|
||||
'
|
||||
# Verify the nodes are ready
|
||||
kubectl --kubeconfig tenantkubeconfig wait node --all --timeout=2m --for=condition=Ready
|
||||
kubectl --kubeconfig tenantkubeconfig get nodes -o wide
|
||||
kubectl --kubeconfig tenantkubeconfig-${test_name} wait node --all --timeout=2m --for=condition=Ready
|
||||
kubectl --kubeconfig tenantkubeconfig-${test_name} get nodes -o wide
|
||||
|
||||
# Verify the kubelet version matches what we expect
|
||||
versions=$(kubectl --kubeconfig tenantkubeconfig get nodes -o jsonpath='{.items[*].status.nodeInfo.kubeletVersion}')
|
||||
versions=$(kubectl --kubeconfig "tenantkubeconfig-${test_name}" \
|
||||
get nodes -o jsonpath='{.items[*].status.nodeInfo.kubeletVersion}')
|
||||
|
||||
node_ok=true
|
||||
|
||||
case "$k8s_version" in
|
||||
v1.32*)
|
||||
echo "⚠️ TODO: Temporary stub — allowing nodes with v1.33 while k8s_version is v1.32"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
for v in $versions; do
|
||||
case "$k8s_version" in
|
||||
v1.32|v1.32.*)
|
||||
case "$v" in
|
||||
v1.32 | v1.32.* | v1.32-* | v1.33 | v1.33.* | v1.33-*)
|
||||
;;
|
||||
*)
|
||||
node_ok=false
|
||||
break
|
||||
;;
|
||||
esac
|
||||
case "$v" in
|
||||
"${k8s_version}" | "${k8s_version}".* | "${k8s_version}"-*)
|
||||
# acceptable
|
||||
;;
|
||||
*)
|
||||
case "$v" in
|
||||
"${k8s_version}" | "${k8s_version}".* | "${k8s_version}"-*)
|
||||
;;
|
||||
*)
|
||||
node_ok=false
|
||||
break
|
||||
;;
|
||||
esac
|
||||
node_ok=false
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -118,7 +118,7 @@ EOF
|
||||
}
|
||||
|
||||
@test "Check Cozystack API service" {
|
||||
kubectl wait --for=condition=Available apiservices/v1alpha1.apps.cozystack.io --timeout=2m
|
||||
kubectl wait --for=condition=Available apiservices/v1alpha1.apps.cozystack.io apiservices/v1alpha1.core.cozystack.io --timeout=2m
|
||||
}
|
||||
|
||||
@test "Configure Tenant and wait for applications" {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
@test "Test OpenAPI v3 endpoint" {
|
||||
kubectl get -v7 --raw '/openapi/v3/apis/apps.cozystack.io/v1alpha1' > /dev/null
|
||||
kubectl get -v7 --raw '/openapi/v3/apis/core.cozystack.io/v1alpha1' > /dev/null
|
||||
}
|
||||
|
||||
@test "Test OpenAPI v2 endpoint (protobuf)" {
|
||||
@@ -18,3 +19,26 @@
|
||||
curl -sS --fail 'http://localhost:21234/openapi/v2?timeout=32s' -H 'Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf' > /dev/null
|
||||
)
|
||||
}
|
||||
|
||||
@test "Test kinds" {
|
||||
val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/tenants | jq -r '.kind')
|
||||
if [ "$val" != "TenantList" ]; then
|
||||
echo "Expected kind to be TenantList, got $val"
|
||||
exit 1
|
||||
fi
|
||||
val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/tenants | jq -r '.items[0].kind')
|
||||
if [ "$val" != "Tenant" ]; then
|
||||
echo "Expected kind to be Tenant, got $val"
|
||||
exit 1
|
||||
fi
|
||||
val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/ingresses | jq -r '.kind')
|
||||
if [ "$val" != "IngressList" ]; then
|
||||
echo "Expected kind to be IngressList, got $val"
|
||||
exit 1
|
||||
fi
|
||||
val=$(kubectl get --raw /apis/apps.cozystack.io/v1alpha1/ingresses | jq -r '.items[0].kind')
|
||||
if [ "$val" != "Ingress" ]; then
|
||||
echo "Expected kind to be Ingress, got $val"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
59
hack/helm-unit-tests.sh
Executable file
59
hack/helm-unit-tests.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Script to run unit tests for all Helm charts.
|
||||
# It iterates through directories in packages/apps, packages/extra,
|
||||
# packages/system, and packages/library and runs the 'test' Makefile
|
||||
# target if it exists.
|
||||
|
||||
FAILED_DIRS_FILE="$(mktemp)"
|
||||
trap 'rm -f "$FAILED_DIRS_FILE"' EXIT
|
||||
|
||||
tests_found=0
|
||||
|
||||
check_and_run_test() {
|
||||
dir="$1"
|
||||
makefile="$dir/Makefile"
|
||||
|
||||
if [ ! -f "$makefile" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if make -C "$dir" -n test >/dev/null 2>&1; then
|
||||
echo "Running tests in $dir"
|
||||
tests_found=$((tests_found + 1))
|
||||
if ! make -C "$dir" test; then
|
||||
printf '%s\n' "$dir" >> "$FAILED_DIRS_FILE"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
for package_dir in packages/apps packages/extra packages/system packages/library; do
|
||||
if [ ! -d "$package_dir" ]; then
|
||||
echo "Warning: Directory $package_dir does not exist, skipping..." >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
for dir in "$package_dir"/*; do
|
||||
[ -d "$dir" ] || continue
|
||||
check_and_run_test "$dir" || true
|
||||
done
|
||||
done
|
||||
|
||||
if [ "$tests_found" -eq 0 ]; then
|
||||
echo "No directories with 'test' Makefile targets found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -s "$FAILED_DIRS_FILE" ]; then
|
||||
echo "ERROR: Tests failed in the following directories:" >&2
|
||||
while IFS= read -r dir; do
|
||||
echo " - $dir" >&2
|
||||
done < "$FAILED_DIRS_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All Helm unit tests passed."
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
)
|
||||
|
||||
// ensureCustomFormsOverride creates or updates a CustomFormsOverride resource for the given CRD
|
||||
@@ -45,15 +46,24 @@ func (m *Manager) ensureCustomFormsOverride(ctx context.Context, crd *cozyv1alph
|
||||
}
|
||||
}
|
||||
|
||||
// Build schema with multilineString for string fields without enum
|
||||
l := log.FromContext(ctx)
|
||||
schema, err := buildMultilineStringSchema(crd.Spec.Application.OpenAPISchema)
|
||||
if err != nil {
|
||||
// If schema parsing fails, log the error and use an empty schema
|
||||
l.Error(err, "failed to build multiline string schema, using empty schema", "crd", crd.Name)
|
||||
schema = map[string]any{}
|
||||
}
|
||||
|
||||
spec := map[string]any{
|
||||
"customizationId": customizationID,
|
||||
"hidden": hidden,
|
||||
"sort": sort,
|
||||
"schema": map[string]any{}, // {}
|
||||
"schema": schema,
|
||||
"strategy": "merge",
|
||||
}
|
||||
|
||||
_, err := controllerutil.CreateOrUpdate(ctx, m.Client, obj, func() error {
|
||||
_, err = controllerutil.CreateOrUpdate(ctx, m.Client, obj, func() error {
|
||||
if err := controllerutil.SetOwnerReference(crd, obj, m.Scheme); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,3 +83,94 @@ func (m *Manager) ensureCustomFormsOverride(ctx context.Context, crd *cozyv1alph
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// buildMultilineStringSchema parses OpenAPI schema and creates schema with multilineString
|
||||
// for all string fields inside spec that don't have enum
|
||||
func buildMultilineStringSchema(openAPISchema string) (map[string]any, error) {
|
||||
if openAPISchema == "" {
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
|
||||
var root map[string]any
|
||||
if err := json.Unmarshal([]byte(openAPISchema), &root); err != nil {
|
||||
return nil, fmt.Errorf("cannot parse openAPISchema: %w", err)
|
||||
}
|
||||
|
||||
props, _ := root["properties"].(map[string]any)
|
||||
if props == nil {
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
|
||||
schema := map[string]any{
|
||||
"properties": map[string]any{},
|
||||
}
|
||||
|
||||
// Process spec properties recursively
|
||||
processSpecProperties(props, schema["properties"].(map[string]any))
|
||||
|
||||
return schema, nil
|
||||
}
|
||||
|
||||
// processSpecProperties recursively processes spec properties and adds multilineString type
|
||||
// for string fields without enum
|
||||
func processSpecProperties(props map[string]any, schemaProps map[string]any) {
|
||||
for pname, raw := range props {
|
||||
sub, ok := raw.(map[string]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
typ, _ := sub["type"].(string)
|
||||
|
||||
switch typ {
|
||||
case "string":
|
||||
// Check if this string field has enum
|
||||
if !hasEnum(sub) {
|
||||
// Add multilineString type for this field
|
||||
if schemaProps[pname] == nil {
|
||||
schemaProps[pname] = map[string]any{}
|
||||
}
|
||||
fieldSchema := schemaProps[pname].(map[string]any)
|
||||
fieldSchema["type"] = "multilineString"
|
||||
}
|
||||
case "object":
|
||||
// Recursively process nested objects
|
||||
if childProps, ok := sub["properties"].(map[string]any); ok {
|
||||
fieldSchema, ok := schemaProps[pname].(map[string]any)
|
||||
if !ok {
|
||||
fieldSchema = map[string]any{}
|
||||
schemaProps[pname] = fieldSchema
|
||||
}
|
||||
nestedSchemaProps, ok := fieldSchema["properties"].(map[string]any)
|
||||
if !ok {
|
||||
nestedSchemaProps = map[string]any{}
|
||||
fieldSchema["properties"] = nestedSchemaProps
|
||||
}
|
||||
processSpecProperties(childProps, nestedSchemaProps)
|
||||
}
|
||||
case "array":
|
||||
// Check if array items are objects with properties
|
||||
if items, ok := sub["items"].(map[string]any); ok {
|
||||
if itemProps, ok := items["properties"].(map[string]any); ok {
|
||||
// Create array item schema
|
||||
fieldSchema, ok := schemaProps[pname].(map[string]any)
|
||||
if !ok {
|
||||
fieldSchema = map[string]any{}
|
||||
schemaProps[pname] = fieldSchema
|
||||
}
|
||||
itemSchema, ok := fieldSchema["items"].(map[string]any)
|
||||
if !ok {
|
||||
itemSchema = map[string]any{}
|
||||
fieldSchema["items"] = itemSchema
|
||||
}
|
||||
itemSchemaProps, ok := itemSchema["properties"].(map[string]any)
|
||||
if !ok {
|
||||
itemSchemaProps = map[string]any{}
|
||||
itemSchema["properties"] = itemSchemaProps
|
||||
}
|
||||
processSpecProperties(itemProps, itemSchemaProps)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
155
internal/controller/dashboard/customformsoverride_test.go
Normal file
155
internal/controller/dashboard/customformsoverride_test.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildMultilineStringSchema(t *testing.T) {
|
||||
// Test OpenAPI schema with various field types
|
||||
openAPISchema := `{
|
||||
"properties": {
|
||||
"simpleString": {
|
||||
"type": "string",
|
||||
"description": "A simple string field"
|
||||
},
|
||||
"stringWithEnum": {
|
||||
"type": "string",
|
||||
"enum": ["option1", "option2"],
|
||||
"description": "String with enum should be skipped"
|
||||
},
|
||||
"numberField": {
|
||||
"type": "number",
|
||||
"description": "Number field should be skipped"
|
||||
},
|
||||
"nestedObject": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nestedString": {
|
||||
"type": "string",
|
||||
"description": "Nested string should get multilineString"
|
||||
},
|
||||
"nestedStringWithEnum": {
|
||||
"type": "string",
|
||||
"enum": ["a", "b"],
|
||||
"description": "Nested string with enum should be skipped"
|
||||
}
|
||||
}
|
||||
},
|
||||
"arrayOfObjects": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"itemString": {
|
||||
"type": "string",
|
||||
"description": "String in array item"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
schema, err := buildMultilineStringSchema(openAPISchema)
|
||||
if err != nil {
|
||||
t.Fatalf("buildMultilineStringSchema failed: %v", err)
|
||||
}
|
||||
|
||||
// Marshal to JSON for easier inspection
|
||||
schemaJSON, err := json.MarshalIndent(schema, "", " ")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to marshal schema: %v", err)
|
||||
}
|
||||
|
||||
t.Logf("Generated schema:\n%s", schemaJSON)
|
||||
|
||||
// Verify that simpleString has multilineString type
|
||||
props, ok := schema["properties"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("schema.properties is not a map")
|
||||
}
|
||||
|
||||
// Check simpleString
|
||||
simpleString, ok := props["simpleString"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("simpleString not found in properties")
|
||||
}
|
||||
if simpleString["type"] != "multilineString" {
|
||||
t.Errorf("simpleString should have type multilineString, got %v", simpleString["type"])
|
||||
}
|
||||
|
||||
// Check stringWithEnum should not be present (or should not have multilineString)
|
||||
if stringWithEnum, ok := props["stringWithEnum"].(map[string]any); ok {
|
||||
if stringWithEnum["type"] == "multilineString" {
|
||||
t.Error("stringWithEnum should not have multilineString type")
|
||||
}
|
||||
}
|
||||
|
||||
// Check numberField should not be present
|
||||
if numberField, ok := props["numberField"].(map[string]any); ok {
|
||||
if numberField["type"] != nil {
|
||||
t.Error("numberField should not have any type override")
|
||||
}
|
||||
}
|
||||
|
||||
// Check nested object
|
||||
nestedObject, ok := props["nestedObject"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("nestedObject not found in properties")
|
||||
}
|
||||
nestedProps, ok := nestedObject["properties"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("nestedObject.properties is not a map")
|
||||
}
|
||||
|
||||
// Check nestedString
|
||||
nestedString, ok := nestedProps["nestedString"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("nestedString not found in nestedObject.properties")
|
||||
}
|
||||
if nestedString["type"] != "multilineString" {
|
||||
t.Errorf("nestedString should have type multilineString, got %v", nestedString["type"])
|
||||
}
|
||||
|
||||
// Check array of objects
|
||||
arrayOfObjects, ok := props["arrayOfObjects"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("arrayOfObjects not found in properties")
|
||||
}
|
||||
items, ok := arrayOfObjects["items"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("arrayOfObjects.items is not a map")
|
||||
}
|
||||
itemProps, ok := items["properties"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("arrayOfObjects.items.properties is not a map")
|
||||
}
|
||||
itemString, ok := itemProps["itemString"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatal("itemString not found in arrayOfObjects.items.properties")
|
||||
}
|
||||
if itemString["type"] != "multilineString" {
|
||||
t.Errorf("itemString should have type multilineString, got %v", itemString["type"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildMultilineStringSchemaEmpty(t *testing.T) {
|
||||
schema, err := buildMultilineStringSchema("")
|
||||
if err != nil {
|
||||
t.Fatalf("buildMultilineStringSchema failed on empty string: %v", err)
|
||||
}
|
||||
if len(schema) != 0 {
|
||||
t.Errorf("Expected empty schema for empty input, got %v", schema)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildMultilineStringSchemaInvalidJSON(t *testing.T) {
|
||||
schema, err := buildMultilineStringSchema("{invalid json")
|
||||
if err == nil {
|
||||
t.Error("Expected error for invalid JSON")
|
||||
}
|
||||
if schema != nil {
|
||||
t.Errorf("Expected nil schema for invalid JSON, got %v", schema)
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,9 @@ func (m *Manager) ensureFactory(ctx context.Context, crd *cozyv1alpha1.Cozystack
|
||||
if flags.Secrets {
|
||||
tabs = append(tabs, secretsTab(kind))
|
||||
}
|
||||
if prefix, ok := vncTabPrefix(kind); ok {
|
||||
tabs = append(tabs, vncTab(prefix))
|
||||
}
|
||||
tabs = append(tabs, yamlTab(plural))
|
||||
|
||||
// Use unified factory creation
|
||||
@@ -150,6 +153,27 @@ func detailsTab(kind, endpoint, schemaJSON string, keysOrder [][]string) map[str
|
||||
}),
|
||||
paramsList,
|
||||
}
|
||||
if kind == "VirtualPrivateCloud" {
|
||||
rightColStack = append(rightColStack,
|
||||
antdFlexVertical("vpc-subnets-block", 4, []any{
|
||||
antdText("vpc-subnets-label", true, "Subnets", nil),
|
||||
map[string]any{
|
||||
"type": "EnrichedTable",
|
||||
"data": map[string]any{
|
||||
"id": "vpc-subnets-table",
|
||||
"baseprefix": "/openapi-ui",
|
||||
"clusterNamePartOfUrl": "{2}",
|
||||
"customizationId": "virtualprivatecloud-subnets",
|
||||
"fetchUrl": "/api/clusters/{2}/k8s/api/v1/namespaces/{3}/configmaps",
|
||||
"fieldSelector": map[string]any{
|
||||
"metadata.name": "virtualprivatecloud-{6}-subnets",
|
||||
},
|
||||
"pathToItems": []any{"items"},
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
return map[string]any{
|
||||
"key": "details",
|
||||
@@ -221,7 +245,7 @@ func workloadsTab(kind string) map[string]any {
|
||||
"baseprefix": "/openapi-ui",
|
||||
"customizationId": "factory-details-v1alpha1.cozystack.io.workloadmonitors",
|
||||
"pathToItems": []any{"items"},
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"apps.cozystack.io/application.group": "apps.cozystack.io",
|
||||
"apps.cozystack.io/application.kind": kind,
|
||||
"apps.cozystack.io/application.name": "{reqs[0]['metadata','name']}",
|
||||
@@ -246,7 +270,7 @@ func servicesTab(kind string) map[string]any {
|
||||
"baseprefix": "/openapi-ui",
|
||||
"customizationId": "factory-details-v1.services",
|
||||
"pathToItems": []any{"items"},
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"apps.cozystack.io/application.group": "apps.cozystack.io",
|
||||
"apps.cozystack.io/application.kind": kind,
|
||||
"apps.cozystack.io/application.name": "{reqs[0]['metadata','name']}",
|
||||
@@ -272,7 +296,7 @@ func ingressesTab(kind string) map[string]any {
|
||||
"baseprefix": "/openapi-ui",
|
||||
"customizationId": "factory-details-networking.k8s.io.v1.ingresses",
|
||||
"pathToItems": []any{"items"},
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"apps.cozystack.io/application.group": "apps.cozystack.io",
|
||||
"apps.cozystack.io/application.kind": kind,
|
||||
"apps.cozystack.io/application.name": "{reqs[0]['metadata','name']}",
|
||||
@@ -293,12 +317,12 @@ func secretsTab(kind string) map[string]any {
|
||||
"type": "EnrichedTable",
|
||||
"data": map[string]any{
|
||||
"id": "secrets-table",
|
||||
"fetchUrl": "/api/clusters/{2}/k8s/apis/core.cozystack.io/v1alpha1/namespaces/{3}/tenantsecretstables",
|
||||
"fetchUrl": "/api/clusters/{2}/k8s/apis/core.cozystack.io/v1alpha1/namespaces/{3}/tenantsecrets",
|
||||
"clusterNamePartOfUrl": "{2}",
|
||||
"baseprefix": "/openapi-ui",
|
||||
"customizationId": "factory-details-v1alpha1.core.cozystack.io.tenantsecretstables",
|
||||
"customizationId": "factory-details-v1alpha1.core.cozystack.io.tenantsecrets",
|
||||
"pathToItems": []any{"items"},
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"apps.cozystack.io/application.group": "apps.cozystack.io",
|
||||
"apps.cozystack.io/application.kind": kind,
|
||||
"apps.cozystack.io/application.name": "{reqs[0]['metadata','name']}",
|
||||
@@ -331,6 +355,36 @@ func yamlTab(plural string) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
func vncTabPrefix(kind string) (string, bool) {
|
||||
switch kind {
|
||||
case "VirtualMachine":
|
||||
return "virtual-machine", true
|
||||
case "VMInstance":
|
||||
return "vm-instance", true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
func vncTab(prefix string) map[string]any {
|
||||
return map[string]any{
|
||||
"key": "vnc",
|
||||
"label": "VNC",
|
||||
"children": []any{
|
||||
map[string]any{
|
||||
"type": "VMVNC",
|
||||
"data": map[string]any{
|
||||
"id": "vm-vnc",
|
||||
"cluster": "{2}",
|
||||
"namespace": "{reqsJsonPath[0]['.metadata.namespace']['-']}",
|
||||
"substractHeight": float64(400),
|
||||
"vmName": fmt.Sprintf("%s-{reqsJsonPath[0]['.metadata.name']['-']}", prefix),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- OpenAPI → Right column ----------------
|
||||
|
||||
func buildOpenAPIParamsBlocks(schemaJSON string, keysOrder [][]string) []any {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||
managerpkg "sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
)
|
||||
|
||||
@@ -53,10 +54,19 @@ func NewManager(c client.Client, scheme *runtime.Scheme) *Manager {
|
||||
}
|
||||
|
||||
func (m *Manager) SetupWithManager(mgr ctrl.Manager) error {
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
if err := ctrl.NewControllerManagedBy(mgr).
|
||||
Named("dashboard-reconciler").
|
||||
For(&cozyv1alpha1.CozystackResourceDefinition{}).
|
||||
Complete(m)
|
||||
Complete(m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return mgr.Add(managerpkg.RunnableFunc(func(ctx context.Context) error {
|
||||
if !mgr.GetCache().WaitForCacheSync(ctx) {
|
||||
return fmt.Errorf("dashboard static resources cache sync failed")
|
||||
}
|
||||
return m.ensureStaticResources(ctx)
|
||||
}))
|
||||
}
|
||||
|
||||
func (m *Manager) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
|
||||
@@ -122,7 +122,7 @@ func createCustomColumnsOverride(id string, additionalPrinterColumns []any) *das
|
||||
}
|
||||
}
|
||||
|
||||
if name == "factory-details-v1alpha1.core.cozystack.io.tenantsecretstables" {
|
||||
if name == "factory-details-v1alpha1.core.cozystack.io.tenantsecrets" {
|
||||
data["additionalPrinterColumnsTrimLengths"] = []any{
|
||||
map[string]any{
|
||||
"key": "Name",
|
||||
@@ -1046,6 +1046,15 @@ func createConverterBytesColumn(name, jsonPath string) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
// createFlatMapColumn creates a flatMap column that expands a map into separate rows
|
||||
func createFlatMapColumn(name, jsonPath string) map[string]any {
|
||||
return map[string]any{
|
||||
"name": name,
|
||||
"type": "flatMap",
|
||||
"jsonPath": jsonPath,
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- Factory UI helper functions ----------------
|
||||
|
||||
// labelsEditor creates a Labels editor component
|
||||
|
||||
@@ -173,14 +173,22 @@ func CreateAllCustomColumnsOverrides() []*dashboardv1alpha1.CustomColumnsOverrid
|
||||
createStringColumn("OBSERVED", ".status.observedReplicas"),
|
||||
}),
|
||||
|
||||
// Factory details v1alpha1 core cozystack io tenantsecretstables
|
||||
createCustomColumnsOverride("factory-details-v1alpha1.core.cozystack.io.tenantsecretstables", []any{
|
||||
// Factory details v1alpha1 core cozystack io tenantsecrets
|
||||
createCustomColumnsOverride("factory-details-v1alpha1.core.cozystack.io.tenantsecrets", []any{
|
||||
createCustomColumnWithJsonPath("Name", ".metadata.name", "Secret", "", "/openapi-ui/{2}/{reqsJsonPath[0]['.metadata.namespace']['-']}/factory/kube-secret-details/{reqsJsonPath[0]['.metadata.name']['-']}"),
|
||||
createStringColumn("Key", ".data.key"),
|
||||
createSecretBase64Column("Value", ".data.value"),
|
||||
createFlatMapColumn("Data", ".data"),
|
||||
createStringColumn("Key", "_flatMapData_Key"),
|
||||
createSecretBase64Column("Value", "._flatMapData_Value"),
|
||||
createTimestampColumn("Created", ".metadata.creationTimestamp"),
|
||||
}),
|
||||
|
||||
// Virtual private cloud subnets
|
||||
createCustomColumnsOverride("virtualprivatecloud-subnets", []any{
|
||||
createFlatMapColumn("Data", ".data"),
|
||||
createStringColumn("Subnet Parameters", "_flatMapData_Key"),
|
||||
createStringColumn("Values", "_flatMapData_Value"),
|
||||
}),
|
||||
|
||||
// Factory ingress details rules
|
||||
createCustomColumnsOverride("factory-kube-ingress-details-rules", []any{
|
||||
createStringColumn("Host", ".host"),
|
||||
@@ -1055,7 +1063,7 @@ func CreateAllFactories() []*dashboardv1alpha1.Factory {
|
||||
"clusterNamePartOfUrl": "{2}",
|
||||
"customizationId": "factory-kube-service-details-endpointslice",
|
||||
"fetchUrl": "/api/clusters/{2}/k8s/apis/discovery.k8s.io/v1/namespaces/{3}/endpointslices",
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"kubernetes.io/service-name": "{reqsJsonPath[0]['.metadata.name']['-']}",
|
||||
},
|
||||
"pathToItems": ".items[*].endpoints",
|
||||
@@ -1396,7 +1404,7 @@ func CreateAllFactories() []*dashboardv1alpha1.Factory {
|
||||
"clusterNamePartOfUrl": "{2}",
|
||||
"customizationId": "factory-details-v1alpha1.cozystack.io.workloads",
|
||||
"fetchUrl": "/api/clusters/{2}/k8s/apis/cozystack.io/v1alpha1/namespaces/{3}/workloads",
|
||||
"labelsSelector": map[string]any{
|
||||
"labelSelector": map[string]any{
|
||||
"workloads.cozystack.io/monitor": "{reqs[0]['metadata','name']}",
|
||||
},
|
||||
"pathToItems": []any{"items"},
|
||||
|
||||
@@ -1 +1 @@
|
||||
ghcr.io/cozystack/cozystack/nginx-cache:0.0.0@sha256:50ac1581e3100bd6c477a71161cb455a341ffaf9e5e2f6086802e4e25271e8af
|
||||
ghcr.io/cozystack/cozystack/nginx-cache:0.0.0@sha256:b7633717cd7449c0042ae92d8ca9b36e4d69566561f5c7d44e21058e7d05c6d5
|
||||
|
||||
@@ -1 +1 @@
|
||||
ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.0.0@sha256:c8b08084a86251cdd18e237de89b695bca0e4f7eb1f1f6ddc2b903b4d74ea5ff
|
||||
ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.0.0@sha256:d5c836ba33cf5dbed7e6f866784f668f80ffe69179e7c75847b680111984eefb
|
||||
|
||||
@@ -182,6 +182,33 @@ metadata:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
files:
|
||||
- path: /usr/bin/update-k8s.sh
|
||||
owner: root:root
|
||||
permissions: "0755"
|
||||
content: |
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Expected to be passed in via preKubeadmCommands
|
||||
: "${KUBELET_VERSION:?KUBELET_VERSION must be set, e.g. v1.31.0}"
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
case "${ARCH}" in
|
||||
x86_64) ARCH=amd64 ;;
|
||||
aarch64) ARCH=arm64 ;;
|
||||
esac
|
||||
|
||||
# Use your internal mirror here for real-world use.
|
||||
BASE_URL="https://dl.k8s.io/release/${KUBELET_VERSION}/bin/linux/${ARCH}"
|
||||
|
||||
echo "Installing kubelet and kubeadm ${KUBELET_VERSION} for ${ARCH}..."
|
||||
curl -fsSL "${BASE_URL}/kubelet" -o /root/kubelet
|
||||
curl -fsSL "${BASE_URL}/kubeadm" -o /root/kubeadm
|
||||
chmod 0755 /root/kubelet
|
||||
chmod 0755 /root/kubeadm
|
||||
if /root/kubelet --version ; then mv /root/kubelet /usr/bin/kubelet ; fi
|
||||
if /root/kubeadm version ; then mv /root/kubeadm /usr/bin/kubeadm ; fi
|
||||
diskSetup:
|
||||
filesystems:
|
||||
- device: /dev/vdb
|
||||
@@ -205,6 +232,7 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
preKubeadmCommands:
|
||||
- KUBELET_VERSION={{ include "kubernetes.versionMap" $}} /usr/bin/update-k8s.sh || true
|
||||
- sed -i 's|root:x:|root::|' /etc/passwd
|
||||
- systemctl stop containerd.service
|
||||
- mkdir -p /ephemeral/kubelet /ephemeral/containerd
|
||||
|
||||
89
packages/apps/kubernetes/templates/delete.yaml
Normal file
89
packages/apps/kubernetes/templates/delete.yaml
Normal file
@@ -0,0 +1,89 @@
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-weight": "10"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation,hook-failed
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: {{ .Release.Name }}-cleanup
|
||||
restartPolicy: Never
|
||||
tolerations:
|
||||
- key: CriticalAddonsOnly
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
operator: Exists
|
||||
effect: "NoSchedule"
|
||||
containers:
|
||||
- name: kubectl
|
||||
image: docker.io/clastix/kubectl:v1.32
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- kubectl -n {{ .Release.Namespace }} delete datavolumes
|
||||
-l "cluster.x-k8s.io/cluster-name={{ .Release.Name }}"
|
||||
--ignore-not-found=true
|
||||
|
||||
kubectl -n {{ .Release.Namespace }} delete services
|
||||
-l "cluster.x-k8s.io/cluster-name={{ .Release.Name }}"
|
||||
--field-selector spec.type=LoadBalancer
|
||||
--ignore-not-found=true
|
||||
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
annotations:
|
||||
helm.sh/hook: post-delete
|
||||
helm.sh/hook-delete-policy: before-hook-creation,hook-failed,hook-succeeded
|
||||
helm.sh/hook-weight: "0"
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation,hook-failed
|
||||
"helm.sh/hook-weight": "5"
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
rules:
|
||||
- apiGroups:
|
||||
- "cdi.kubevirt.io"
|
||||
resources:
|
||||
- datavolumes
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- delete
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- delete
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
annotations:
|
||||
"helm.sh/hook": post-delete
|
||||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation,hook-failed
|
||||
"helm.sh/hook-weight": "5"
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ .Release.Name }}-cleanup
|
||||
namespace: {{ .Release.Namespace }}
|
||||
|
||||
@@ -24,26 +24,26 @@ spec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
kubectl
|
||||
--namespace={{ .Release.Namespace }}
|
||||
patch
|
||||
helmrelease
|
||||
{{ .Release.Name }}-cilium
|
||||
{{ .Release.Name }}-gateway-api-crds
|
||||
{{ .Release.Name }}-csi
|
||||
{{ .Release.Name }}-cert-manager
|
||||
{{ .Release.Name }}-cert-manager-crds
|
||||
{{ .Release.Name }}-vertical-pod-autoscaler
|
||||
{{ .Release.Name }}-vertical-pod-autoscaler-crds
|
||||
{{ .Release.Name }}-ingress-nginx
|
||||
{{ .Release.Name }}-fluxcd-operator
|
||||
{{ .Release.Name }}-fluxcd
|
||||
{{ .Release.Name }}-gpu-operator
|
||||
{{ .Release.Name }}-velero
|
||||
{{ .Release.Name }}-coredns
|
||||
-p '{"spec": {"suspend": true}}'
|
||||
--type=merge --field-manager=flux-client-side-apply || true
|
||||
- >-
|
||||
kubectl
|
||||
--namespace={{ .Release.Namespace }}
|
||||
patch
|
||||
helmrelease
|
||||
{{ .Release.Name }}-cilium
|
||||
{{ .Release.Name }}-gateway-api-crds
|
||||
{{ .Release.Name }}-csi
|
||||
{{ .Release.Name }}-cert-manager
|
||||
{{ .Release.Name }}-cert-manager-crds
|
||||
{{ .Release.Name }}-vertical-pod-autoscaler
|
||||
{{ .Release.Name }}-vertical-pod-autoscaler-crds
|
||||
{{ .Release.Name }}-ingress-nginx
|
||||
{{ .Release.Name }}-fluxcd-operator
|
||||
{{ .Release.Name }}-fluxcd
|
||||
{{ .Release.Name }}-gpu-operator
|
||||
{{ .Release.Name }}-velero
|
||||
{{ .Release.Name }}-coredns
|
||||
-p '{"spec": {"suspend": true}}'
|
||||
--type=merge --field-manager=flux-client-side-apply || true
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
@@ -51,7 +51,7 @@ metadata:
|
||||
name: {{ .Release.Name }}-flux-teardown
|
||||
annotations:
|
||||
helm.sh/hook: pre-delete
|
||||
helm.sh/hook-delete-policy: before-hook-creation,hook-failed
|
||||
helm.sh/hook-delete-policy: before-hook-creation,hook-failed,hook-succeeded
|
||||
helm.sh/hook-weight: "0"
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
@@ -75,6 +75,7 @@ rules:
|
||||
- {{ .Release.Name }}-csi
|
||||
- {{ .Release.Name }}-cert-manager
|
||||
- {{ .Release.Name }}-cert-manager-crds
|
||||
- {{ .Release.Name }}-gateway-api-crds
|
||||
- {{ .Release.Name }}-vertical-pod-autoscaler
|
||||
- {{ .Release.Name }}-vertical-pod-autoscaler-crds
|
||||
- {{ .Release.Name }}-ingress-nginx
|
||||
|
||||
@@ -37,6 +37,10 @@ spec:
|
||||
# automaticFailover: true
|
||||
{{- end }}
|
||||
|
||||
podMetadata:
|
||||
labels:
|
||||
"policy.cozystack.io/allow-to-apiserver": "true"
|
||||
|
||||
metrics:
|
||||
enabled: true
|
||||
exporter:
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
|
||||
{{- $clusterDomain := (index $cozyConfig.data "cluster-domain") | default "cozy.local" }}
|
||||
{{- $existingSecret := lookup "v1" "Secret" .Release.Namespace (printf "%s-credentials" .Release.Name) }}
|
||||
{{- $passwords := dict }}
|
||||
|
||||
{{- with (dig "data" (dict) $existingSecret) }}
|
||||
{{- range $k, $v := . }}
|
||||
{{- $_ := set $passwords $k (b64dec $v) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $user, $u := .Values.users }}
|
||||
{{- if $u.password }}
|
||||
{{- $_ := set $passwords $user $u.password }}
|
||||
|
||||
@@ -20,11 +20,7 @@ metadata:
|
||||
name: allow-external-communication
|
||||
namespace: {{ include "tenant.name" . }}
|
||||
spec:
|
||||
endpointSelector:
|
||||
matchExpressions:
|
||||
- key: policy.cozystack.io/allow-external-communication
|
||||
operator: NotIn
|
||||
values: ["false"]
|
||||
endpointSelector: {}
|
||||
ingress:
|
||||
- fromEntities:
|
||||
- world
|
||||
|
||||
@@ -35,7 +35,6 @@ rules:
|
||||
resources:
|
||||
- tenantmodules
|
||||
- tenantsecrets
|
||||
- tenantsecretstables
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
@@ -123,7 +122,7 @@ metadata:
|
||||
name: {{ include "tenant.name" . }}-view
|
||||
namespace: {{ include "tenant.name" . }}
|
||||
subjects:
|
||||
{{ include "cozy-lib.rbac.subjectsForTenant" (list "view" (include "tenant.name" .)) | nindent 2 }}
|
||||
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "view" (include "tenant.name" .)) | nindent 2 }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "tenant.name" . }}-view
|
||||
@@ -193,7 +192,6 @@ rules:
|
||||
resources:
|
||||
- tenantmodules
|
||||
- tenantsecrets
|
||||
- tenantsecretstables
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
kind: RoleBinding
|
||||
@@ -202,7 +200,7 @@ metadata:
|
||||
name: {{ include "tenant.name" . }}-use
|
||||
namespace: {{ include "tenant.name" . }}
|
||||
subjects:
|
||||
{{ include "cozy-lib.rbac.subjectsForTenant" (list "use" (include "tenant.name" .)) | nindent 2 }}
|
||||
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "use" (include "tenant.name" .)) | nindent 2 }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "tenant.name" . }}-use
|
||||
@@ -293,7 +291,6 @@ rules:
|
||||
resources:
|
||||
- tenantmodules
|
||||
- tenantsecrets
|
||||
- tenantsecretstables
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
kind: RoleBinding
|
||||
@@ -302,7 +299,7 @@ metadata:
|
||||
name: {{ include "tenant.name" . }}-admin
|
||||
namespace: {{ include "tenant.name" . }}
|
||||
subjects:
|
||||
{{ include "cozy-lib.rbac.subjectsForTenant" (list "admin" (include "tenant.name" .)) | nindent 2 }}
|
||||
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "admin" (include "tenant.name" .)) | nindent 2 }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "tenant.name" . }}-admin
|
||||
@@ -368,7 +365,6 @@ rules:
|
||||
resources:
|
||||
- tenantmodules
|
||||
- tenantsecrets
|
||||
- tenantsecretstables
|
||||
verbs: ["get", "list", "watch"]
|
||||
---
|
||||
kind: RoleBinding
|
||||
@@ -377,7 +373,7 @@ metadata:
|
||||
name: {{ include "tenant.name" . }}-super-admin
|
||||
namespace: {{ include "tenant.name" . }}
|
||||
subjects:
|
||||
{{ include "cozy-lib.rbac.subjectsForTenant" (list "super-admin" (include "tenant.name" .) ) | nindent 2 }}
|
||||
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "super-admin" (include "tenant.name" .) ) | nindent 2 }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: {{ include "tenant.name" . }}-super-admin
|
||||
|
||||
@@ -28,27 +28,3 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: {{ include "virtual-machine.fullname" . }}
|
||||
spec:
|
||||
endpointSelector:
|
||||
matchLabels:
|
||||
{{- include "virtual-machine.selectorLabels" . | nindent 6 }}
|
||||
ingress:
|
||||
- fromEntities:
|
||||
- cluster
|
||||
- fromEntities:
|
||||
- world
|
||||
{{- if eq .Values.externalMethod "PortList" }}
|
||||
toPorts:
|
||||
- ports:
|
||||
{{- range .Values.externalPorts }}
|
||||
- port: {{ quote . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
egress:
|
||||
- toEntities:
|
||||
- world
|
||||
|
||||
@@ -62,7 +62,6 @@ spec:
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
policy.cozystack.io/allow-external-communication: "false"
|
||||
kubevirt.io/allow-pod-bridge-network-live-migration: "true"
|
||||
labels:
|
||||
{{- include "virtual-machine.labels" . | nindent 8 }}
|
||||
|
||||
@@ -28,27 +28,3 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: cilium.io/v2
|
||||
kind: CiliumNetworkPolicy
|
||||
metadata:
|
||||
name: {{ include "virtual-machine.fullname" . }}
|
||||
spec:
|
||||
endpointSelector:
|
||||
matchLabels:
|
||||
{{- include "virtual-machine.selectorLabels" . | nindent 6 }}
|
||||
ingress:
|
||||
- fromEntities:
|
||||
- cluster
|
||||
- fromEntities:
|
||||
- world
|
||||
{{- if eq .Values.externalMethod "PortList" }}
|
||||
toPorts:
|
||||
- ports:
|
||||
{{- range .Values.externalPorts }}
|
||||
- port: {{ quote . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
egress:
|
||||
- toEntities:
|
||||
- world
|
||||
|
||||
@@ -26,7 +26,6 @@ spec:
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
policy.cozystack.io/allow-external-communication: "false"
|
||||
kubevirt.io/allow-pod-bridge-network-live-migration: "true"
|
||||
labels:
|
||||
{{- include "virtual-machine.labels" . | nindent 8 }}
|
||||
|
||||
@@ -5,12 +5,12 @@ As the service evolves, it will provide more ways to isolate your workloads.
|
||||
|
||||
## Service details
|
||||
|
||||
The service utilizes kube-ovn VPC and Subnet resources, which use ovn logical routers and logical switches under the hood.
|
||||
Currently every workload will have a connection to a default management network which will also have a default gateway, and the majority of traffic will be going through it.
|
||||
VPC subnets are for now an additional dedicated networking spaces.
|
||||
To function, the service requires kube-ovn and multus CNI to be present, so by default it will only work on `paas-full` bundle.
|
||||
Kube-ovn provides VPC and Subnet resources and performs isolation and networking maintenance such as DHCP. Under the hood it uses ovn virtual routers and virtual switches.
|
||||
Multus enables a multi-nic capability, so a pod or a VM could have two or more network interfaces.
|
||||
|
||||
A VM or a pod may be connected to multiple secondary Subnets at once.
|
||||
Each secondary connection will be represented as an additional network interface.
|
||||
Currently every workload will have a connection to a default management network which will also have a default gateway, and the majority of traffic will go through it.
|
||||
VPC subnets are for now an additional dedicated networking spaces.
|
||||
|
||||
## Deployment notes
|
||||
|
||||
@@ -19,7 +19,9 @@ Subnet name and ip address range must be unique within a VPC.
|
||||
Subnet ip address space must not overlap with the default management network ip address range, subsets of 172.16.0.0/12 are recommended.
|
||||
Currently there are no fail-safe checks, however they are planned for the future.
|
||||
|
||||
Different VPCs may have subnets with ovelapping ip address ranges.
|
||||
Different VPCs may have subnets with overlapping ip address ranges.
|
||||
|
||||
A VM or a pod may be connected to multiple secondary Subnets at once. Each secondary connection will be represented as an additional network interface.
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
1
packages/apps/vpc/charts/cozy-lib
Symbolic link
1
packages/apps/vpc/charts/cozy-lib
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../library/cozy-lib
|
||||
@@ -60,13 +60,33 @@ kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ $.Release.Name }}-subnets
|
||||
labels:
|
||||
apps.cozystack.io/application.group: apps.cozystack.io
|
||||
apps.cozystack.io/application.kind: VirtualPrivateCloud
|
||||
apps.cozystack.io/application.name: {{ trimPrefix "virtualprivatecloud-" .Release.Name }}
|
||||
cozystack.io/vpcId: {{ $vpcId }}
|
||||
cozystack.io/tenantName: {{ $.Release.Namespace }}
|
||||
data:
|
||||
subnets: |
|
||||
{{- range $subnetName, $subnetConfig := .Values.subnets }}
|
||||
- subnetName: {{ $subnetName }}
|
||||
subnetId: {{ print "subnet-" (print $.Release.Namespace "/" $vpcId "/" $subnetName | sha256sum | trunc 8) }}
|
||||
subnetCIDR: {{ $subnetConfig.cidr }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $subnetName, $subnetConfig := .Values.subnets }}
|
||||
{{ $subnetName }}.ID: {{ print "subnet-" (print $.Release.Namespace "/" $vpcId "/" $subnetName | sha256sum | trunc 8) }}
|
||||
{{ $subnetName }}.CIDR: {{ $subnetConfig.cidr }}
|
||||
{{- end }}
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: "{{ .Release.Name }}-subnets"
|
||||
subjects: {{- include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "view" .Release.Namespace ) | nindent 2 }}
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: "{{ .Release.Name }}-subnets"
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: "{{ .Release.Name }}-subnets"
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["configmaps"]
|
||||
verbs: ["get","list","watch"]
|
||||
resourceNames: ["{{ .Release.Name }}-subnets"]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
cozystack:
|
||||
image: ghcr.io/cozystack/cozystack/installer:v0.37.0@sha256:256c5a0f0ae2fc3ad6865b9fda74c42945b38a5384240fa29554617185b60556
|
||||
image: ghcr.io/cozystack/cozystack/installer:v0.38.0@sha256:1a902ebd15fe375079098c088dd5b40475926c8d9576faf6348433f0fd86a963
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
e2e:
|
||||
image: ghcr.io/cozystack/cozystack/e2e-sandbox:v0.37.0@sha256:10afd0a6c39248ec41d0e59ff1bc6c29bd0075b7cc9a512b01cf603ef39c33ea
|
||||
image: ghcr.io/cozystack/cozystack/e2e-sandbox:v0.38.0@sha256:cb17739b46eca263b2a31c714a3cb211da6f9de259b1641c2fc72c91bdfc93bb
|
||||
|
||||
@@ -1 +1 @@
|
||||
ghcr.io/cozystack/cozystack/matchbox:v0.37.0@sha256:5cca5f56b755285aefa11b1052fe55e1aa83b25bae34aef80cdb77ff63091044
|
||||
ghcr.io/cozystack/cozystack/matchbox:v0.38.0@sha256:9ff2bdcf802445f6c1cabdf0e6fc32ee10043b1067945232a91088abad63f583
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{- $cozyConfig := lookup "v1" "ConfigMap" "cozy-system" "cozystack" }}
|
||||
{{- $exposeIngress := index $cozyConfig.data "expose-ingress" | default "tenant-root" }}
|
||||
{{- $exposeExternalIPs := (index $cozyConfig.data "expose-external-ips") | default "" }}
|
||||
{{- $exposeExternalIPs := (index $cozyConfig.data "expose-external-ips") | default "" | nospace }}
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
|
||||
@@ -1 +1 @@
|
||||
ghcr.io/cozystack/cozystack/objectstorage-sidecar:v0.37.0@sha256:f166f09cdc9cdbb758209883819ab8261a3793bc1d7a6b6685efd5a2b2930847
|
||||
ghcr.io/cozystack/cozystack/objectstorage-sidecar:v0.38.0@sha256:4548d85e7e69150aaf52fbb17fb9487e9714bdd8407aff49762cf39b9d0ab29c
|
||||
|
||||
@@ -4,3 +4,5 @@ include ../../../scripts/package.mk
|
||||
generate:
|
||||
cozyvalues-gen -v values.yaml -s values.schema.json -r README.md
|
||||
|
||||
test:
|
||||
$(MAKE) -C ../../tests/cozy-lib-tests/ test
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
{{- $resources := index . 1 }}
|
||||
{{- $global := index . 2 }}
|
||||
{{- $presetMap := include "cozy-lib.resources.unsanitizedPreset" $preset | fromYaml }}
|
||||
{{- $mergedMap := deepCopy $resources | mergeOverwrite $presetMap }}
|
||||
{{- $mergedMap := deepCopy (default (dict) $resources) | mergeOverwrite $presetMap }}
|
||||
{{- include "cozy-lib.resources.sanitize" (list $mergedMap $global) }}
|
||||
{{- end }}
|
||||
|
||||
@@ -174,15 +174,46 @@
|
||||
{{- end }}
|
||||
|
||||
{{- define "cozy-lib.resources.flatten" -}}
|
||||
{{- $out := dict -}}
|
||||
{{- $res := include "cozy-lib.resources.sanitize" . | fromYaml -}}
|
||||
{{- range $section, $values := $res }}
|
||||
{{- range $k, $v := $values }}
|
||||
{{- $key := printf "%s.%s" $section $k }}
|
||||
{{- if ne $key "limits.storage" }}
|
||||
{{- $_ := set $out $key $v }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $out := dict -}}
|
||||
{{- $res := include "cozy-lib.resources.sanitize" . | fromYaml -}}
|
||||
{{- range $section, $values := $res }}
|
||||
{{- range $k, $v := $values }}
|
||||
{{- with include "cozy-lib.resources.flattenResource" (list $section $k) }}
|
||||
{{- $_ := set $out . $v }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $out | toYaml }}
|
||||
{{- end }}
|
||||
{{- $out | toYaml }}
|
||||
|
||||
{{/*
|
||||
This is a helper function that takes an argument like `list "limits" "services.loadbalancers"`
|
||||
or `list "limits" "storage"` or `list "requests" "cpu"` and returns "services.loadbalancers",
|
||||
"", and "requests.cpu", respectively, thus transforming them to an acceptable format for k8s
|
||||
ResourceQuotas objects.
|
||||
*/}}
|
||||
{{- define "cozy-lib.resources.flattenResource" }}
|
||||
{{- $rawQuotaKeys := list
|
||||
"pods"
|
||||
"services"
|
||||
"services.loadbalancers"
|
||||
"services.nodeports"
|
||||
"services.clusterip"
|
||||
"configmaps"
|
||||
"secrets"
|
||||
"persistentvolumeclaims"
|
||||
"replicationcontrollers"
|
||||
"resourcequotas"
|
||||
-}}
|
||||
{{- $section := index . 0 }}
|
||||
{{- $type := index . 1 }}
|
||||
{{- $out := "" }}
|
||||
{{- if and (eq $section "limits") (eq $type "storage") }}
|
||||
{{- $out = "" }}
|
||||
{{- else if and (eq $section "limits") (has $type $rawQuotaKeys) }}
|
||||
{{- $out = $type }}
|
||||
{{- else if not (has $type $rawQuotaKeys) }}
|
||||
{{- $out = printf "%s.%s" $section $type }}
|
||||
{{- end }}
|
||||
{{- $out -}}
|
||||
{{- end }}
|
||||
|
||||
@@ -1 +1 @@
|
||||
ghcr.io/cozystack/cozystack/s3manager:v0.5.0@sha256:7348bec610f08bd902c88c9a9f28fdd644727e2728a1e4103f88f0c99febd5e7
|
||||
ghcr.io/cozystack/cozystack/s3manager:v0.5.0@sha256:f21b1c37872221323cee0490f9c58e04fa360c2b8c68700ab0455bc39f3ad160
|
||||
|
||||
1
packages/system/cozystack-api/.gitignore
vendored
Normal file
1
packages/system/cozystack-api/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
apiserver.local.config/
|
||||
@@ -4,6 +4,18 @@ NAMESPACE=cozy-system
|
||||
include ../../../scripts/common-envs.mk
|
||||
include ../../../scripts/package.mk
|
||||
|
||||
run-local:
|
||||
openssl req -nodes -new -x509 -keyout /tmp/ca.key -out /tmp/ca.crt -subj "/CN=kube-ca"
|
||||
openssl req -out /tmp/client.csr -new -newkey rsa:2048 -nodes -keyout /tmp/client.key -subj "/C=US/ST=SomeState/L=L/OU=Dev/CN=development/O=system:masters"
|
||||
openssl x509 -req -days 365 -in /tmp/client.csr -CA /tmp/ca.crt -CAkey /tmp/ca.key -set_serial 01 -sha256 -out /tmp/client.crt
|
||||
openssl req -out /tmp/apiserver.csr -new -newkey rsa:2048 -nodes -keyout /tmp/apiserver.key -subj "/CN=cozystack-api" -config cozystack-api-openssl.cnf
|
||||
openssl x509 -req -days 365 -in /tmp/apiserver.csr -CA /tmp/ca.crt -CAkey /tmp/ca.key -set_serial 01 -sha256 -out /tmp/apiserver.crt -extensions v3_req -extfile cozystack-api-openssl.cnf
|
||||
CGO_ENABLED=0 go build -o /tmp/cozystack-api ../../../cmd/cozystack-api/main.go
|
||||
/tmp/cozystack-api --client-ca-file /tmp/ca.crt --tls-cert-file /tmp/apiserver.crt --tls-private-key-file /tmp/apiserver.key --secure-port 6443 --kubeconfig $(KUBECONFIG) --authorization-kubeconfig $(KUBECONFIG) --authentication-kubeconfig $(KUBECONFIG)
|
||||
|
||||
debug:
|
||||
dlv debug ../../../cmd/cozystack-api/main.go -- --client-ca-file /tmp/ca.crt --tls-cert-file /tmp/apiserver.crt --tls-private-key-file /tmp/apiserver.key --secure-port 6443 --kubeconfig $(KUBECONFIG) --authorization-kubeconfig $(KUBECONFIG) --authentication-kubeconfig $(KUBECONFIG)
|
||||
|
||||
image: image-cozystack-api
|
||||
|
||||
image-cozystack-api:
|
||||
|
||||
13
packages/system/cozystack-api/cozystack-api-openssl.cnf
Normal file
13
packages/system/cozystack-api/cozystack-api-openssl.cnf
Normal file
@@ -0,0 +1,13 @@
|
||||
[ req ]
|
||||
distinguished_name = req_distinguished_name
|
||||
req_extensions = v3_req
|
||||
prompt = no
|
||||
|
||||
[ req_distinguished_name ]
|
||||
CN = cozystack-api
|
||||
|
||||
[ v3_req ]
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[ alt_names ]
|
||||
IP.1 = 127.0.0.1
|
||||
@@ -1,5 +1,5 @@
|
||||
cozystackAPI:
|
||||
image: ghcr.io/cozystack/cozystack/cozystack-api:v0.37.0@sha256:19d89e8afb90ce38ab7e42ecedfc28402f7c0b56f30957db957c5415132ff6ca
|
||||
image: ghcr.io/cozystack/cozystack/cozystack-api:v0.38.0@sha256:5eb5d6369c7c7ba0fa6b34b7c5022faa15c860b72e441b5fbde3eceda94efc88
|
||||
localK8sAPIEndpoint:
|
||||
enabled: true
|
||||
replicas: 2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
cozystackController:
|
||||
image: ghcr.io/cozystack/cozystack/cozystack-controller:v0.37.0@sha256:845b8e68cbc277c2303080bcd55597e4334610d396dad258ad56fd906530acc3
|
||||
image: ghcr.io/cozystack/cozystack/cozystack-controller:v0.38.0@sha256:4628a3711b6a6fc2e446255ee172cd268b28b07c65e98c302ea8897574dcbf22
|
||||
debug: false
|
||||
disableTelemetry: false
|
||||
cozystackVersion: "v0.37.0"
|
||||
cozystackVersion: "v0.38.0"
|
||||
cozystackAPIKind: "DaemonSet"
|
||||
|
||||
@@ -3,7 +3,7 @@ ARG NODE_VERSION=20.18.1
|
||||
FROM node:${NODE_VERSION}-alpine AS builder
|
||||
WORKDIR /src
|
||||
|
||||
ARG COMMIT_REF=92906a7f21050cfb8e352f98d36b209c57844f63
|
||||
ARG COMMIT_REF=ba56271739505284aee569f914fc90e6a9c670da
|
||||
RUN wget -O- https://github.com/PRO-Robotech/openapi-ui-k8s-bff/archive/${COMMIT_REF}.tar.gz | tar xzf - --strip-components=1
|
||||
|
||||
ENV PATH=/src/node_modules/.bin:$PATH
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG NODE_VERSION=20.18.1
|
||||
FROM node:${NODE_VERSION}-alpine AS openapi-k8s-toolkit-builder
|
||||
RUN apk add git
|
||||
WORKDIR /src
|
||||
ARG COMMIT=7086a2d8a07dcf6a94bb4276433db5d84acfcf3b
|
||||
ARG COMMIT=cb2f122caafaa2fd5455750213d9e633017ec555
|
||||
RUN wget -O- https://github.com/cozystack/openapi-k8s-toolkit/archive/${COMMIT}.tar.gz | tar -xzvf- --strip-components=1
|
||||
|
||||
COPY openapi-k8s-toolkit/patches /patches
|
||||
@@ -19,14 +19,14 @@ RUN npm run build
|
||||
# openapi-ui
|
||||
# imported from https://github.com/cozystack/openapi-ui
|
||||
FROM node:${NODE_VERSION}-alpine AS builder
|
||||
RUN apk add git
|
||||
#RUN apk add git
|
||||
WORKDIR /src
|
||||
|
||||
ARG COMMIT_REF=fe237518348e94cead6d4f3283b2fce27f26aa12
|
||||
ARG COMMIT_REF=3cfbbf2156b6a5e4a1f283a032019530c0c2d37d
|
||||
RUN wget -O- https://github.com/PRO-Robotech/openapi-ui/archive/${COMMIT_REF}.tar.gz | tar xzf - --strip-components=1
|
||||
|
||||
COPY openapi-ui/patches /patches
|
||||
RUN git apply /patches/*.diff
|
||||
#COPY openapi-ui/patches /patches
|
||||
#RUN git apply /patches/*.diff
|
||||
|
||||
ENV PATH=/src/node_modules/.bin:$PATH
|
||||
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
diff --git a/src/components/molecules/BlackholeForm/molecules/FormObjectFromSwagger/FormObjectFromSwagger.tsx b/src/components/molecules/BlackholeForm/molecules/FormObjectFromSwagger/FormObjectFromSwagger.tsx
|
||||
index a7135d4..2fea0bb 100644
|
||||
--- a/src/components/molecules/BlackholeForm/molecules/FormObjectFromSwagger/FormObjectFromSwagger.tsx
|
||||
+++ b/src/components/molecules/BlackholeForm/molecules/FormObjectFromSwagger/FormObjectFromSwagger.tsx
|
||||
@@ -68,13 +68,60 @@ export const FormObjectFromSwagger: FC<TFormObjectFromSwaggerProps> = ({
|
||||
properties?: OpenAPIV2.SchemaObject['properties']
|
||||
required?: string
|
||||
}
|
||||
+
|
||||
+ // Check if the field name exists in additionalProperties.properties
|
||||
+ // If so, use the type from that property definition
|
||||
+ const nestedProp = addProps?.properties?.[additionalPropValue] as OpenAPIV2.SchemaObject | undefined
|
||||
+ let fieldType: string = addProps.type
|
||||
+ let fieldItems: { type: string } | undefined = addProps.items
|
||||
+ let fieldNestedProperties = addProps.properties || {}
|
||||
+ let fieldRequired: string | undefined = addProps.required
|
||||
+
|
||||
+ if (nestedProp) {
|
||||
+ // Use the nested property definition if it exists
|
||||
+ // Handle type - it can be string or string[] in OpenAPI v2
|
||||
+ if (nestedProp.type) {
|
||||
+ if (Array.isArray(nestedProp.type)) {
|
||||
+ fieldType = nestedProp.type[0] || addProps.type
|
||||
+ } else if (typeof nestedProp.type === 'string') {
|
||||
+ fieldType = nestedProp.type
|
||||
+ } else {
|
||||
+ fieldType = addProps.type
|
||||
+ }
|
||||
+ } else {
|
||||
+ fieldType = addProps.type
|
||||
+ }
|
||||
+
|
||||
+ // Handle items - it can be ItemsObject or ReferenceObject
|
||||
+ if (nestedProp.items) {
|
||||
+ // Check if it's a valid ItemsObject with type property
|
||||
+ if ('type' in nestedProp.items && typeof nestedProp.items.type === 'string') {
|
||||
+ fieldItems = { type: nestedProp.items.type }
|
||||
+ } else {
|
||||
+ fieldItems = addProps.items
|
||||
+ }
|
||||
+ } else {
|
||||
+ fieldItems = addProps.items
|
||||
+ }
|
||||
+
|
||||
+ fieldNestedProperties = nestedProp.properties || {}
|
||||
+ // Handle required field - it can be string[] in OpenAPI schema
|
||||
+ if (Array.isArray(nestedProp.required)) {
|
||||
+ fieldRequired = nestedProp.required.join(',')
|
||||
+ } else if (typeof nestedProp.required === 'string') {
|
||||
+ fieldRequired = nestedProp.required
|
||||
+ } else {
|
||||
+ fieldRequired = addProps.required
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
inputProps?.addField({
|
||||
path: Array.isArray(name) ? [...name, String(collapseTitle)] : [name, String(collapseTitle)],
|
||||
name: additionalPropValue,
|
||||
- type: addProps.type,
|
||||
- items: addProps.items,
|
||||
- nestedProperties: addProps.properties || {},
|
||||
- required: addProps.required,
|
||||
+ type: fieldType,
|
||||
+ items: fieldItems,
|
||||
+ nestedProperties: fieldNestedProperties,
|
||||
+ required: fieldRequired,
|
||||
})
|
||||
setAddditionalPropValue(undefined)
|
||||
}
|
||||
diff --git a/src/components/molecules/BlackholeForm/molecules/FormStringInput/FormStringInput.tsx b/src/components/molecules/BlackholeForm/molecules/FormStringInput/FormStringInput.tsx
|
||||
index 487d480..3ca46c1 100644
|
||||
--- a/src/components/molecules/BlackholeForm/molecules/FormStringInput/FormStringInput.tsx
|
||||
+++ b/src/components/molecules/BlackholeForm/molecules/FormStringInput/FormStringInput.tsx
|
||||
@@ -42,7 +42,11 @@ export const FormStringInput: FC<TFormStringInputProps> = ({
|
||||
const formValue = Form.useWatch(formFieldName)
|
||||
|
||||
// Derive multiline based on current local value
|
||||
- const isMultiline = useMemo(() => isMultilineString(formValue), [formValue])
|
||||
+ const isMultiline = useMemo(() => {
|
||||
+ // Normalize value for multiline check
|
||||
+ const value = typeof formValue === 'string' ? formValue : (formValue === null || formValue === undefined ? '' : String(formValue))
|
||||
+ return isMultilineString(value)
|
||||
+ }, [formValue])
|
||||
|
||||
const title = (
|
||||
<>
|
||||
@@ -77,6 +81,23 @@ export const FormStringInput: FC<TFormStringInputProps> = ({
|
||||
rules={[{ required: forceNonRequired === false && required?.includes(getStringByName(name)) }]}
|
||||
validateTrigger="onBlur"
|
||||
hasFeedback={designNewLayout ? { icons: feedbackIcons } : true}
|
||||
+ normalize={(value) => {
|
||||
+ // Normalize value to string - prevent "[object Object]" display
|
||||
+ if (value === undefined || value === null) {
|
||||
+ return ''
|
||||
+ }
|
||||
+ if (typeof value === 'string') {
|
||||
+ return value
|
||||
+ }
|
||||
+ if (typeof value === 'number' || typeof value === 'boolean') {
|
||||
+ return String(value)
|
||||
+ }
|
||||
+ // If it's an object or array, it shouldn't be in a string field - return empty string
|
||||
+ if (typeof value === 'object') {
|
||||
+ return ''
|
||||
+ }
|
||||
+ return String(value)
|
||||
+ }}
|
||||
>
|
||||
<Input.TextArea
|
||||
placeholder={getStringByName(name)}
|
||||
diff --git a/src/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/casts.ts b/src/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/casts.ts
|
||||
index 6f9eb39..835224c 100644
|
||||
--- a/src/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/casts.ts
|
||||
+++ b/src/components/molecules/BlackholeForm/organisms/BlackholeForm/helpers/casts.ts
|
||||
@@ -124,8 +124,26 @@ export const materializeAdditionalFromValues = (
|
||||
*
|
||||
* This is used when a new field appears in the data but doesn't yet exist in the schema.
|
||||
*/
|
||||
- const makeChildFromAP = (ap: any): OpenAPIV2.SchemaObject => {
|
||||
- const t = ap?.type ?? 'object'
|
||||
+ const makeChildFromAP = (ap: any, value?: unknown): OpenAPIV2.SchemaObject => {
|
||||
+ // Determine type based on actual value if not explicitly defined in additionalProperties
|
||||
+ let t = ap?.type
|
||||
+ if (!t && value !== undefined && value !== null) {
|
||||
+ if (Array.isArray(value)) {
|
||||
+ t = 'array'
|
||||
+ } else if (typeof value === 'object') {
|
||||
+ t = 'object'
|
||||
+ } else if (typeof value === 'string') {
|
||||
+ t = 'string'
|
||||
+ } else if (typeof value === 'number') {
|
||||
+ t = 'number'
|
||||
+ } else if (typeof value === 'boolean') {
|
||||
+ t = 'boolean'
|
||||
+ } else {
|
||||
+ t = 'object'
|
||||
+ }
|
||||
+ }
|
||||
+ t = t ?? 'object'
|
||||
+
|
||||
const child: OpenAPIV2.SchemaObject = { type: t } as any
|
||||
|
||||
// Copy common schema details (if present)
|
||||
@@ -134,6 +152,20 @@ export const materializeAdditionalFromValues = (
|
||||
if (ap?.required)
|
||||
(child as any).required = _.cloneDeep(ap.required)
|
||||
|
||||
+ // If value is an array and items type is not defined, infer it from the first item
|
||||
+ if (t === 'array' && Array.isArray(value) && value.length > 0 && !ap?.items) {
|
||||
+ const firstItem = value[0]
|
||||
+ if (typeof firstItem === 'string') {
|
||||
+ ;(child as any).items = { type: 'string' }
|
||||
+ } else if (typeof firstItem === 'number') {
|
||||
+ ;(child as any).items = { type: 'number' }
|
||||
+ } else if (typeof firstItem === 'boolean') {
|
||||
+ ;(child as any).items = { type: 'boolean' }
|
||||
+ } else if (typeof firstItem === 'object') {
|
||||
+ ;(child as any).items = { type: 'object' }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// Mark as originating from `additionalProperties`
|
||||
;(child as any).isAdditionalProperties = true
|
||||
return child
|
||||
@@ -177,7 +209,16 @@ export const materializeAdditionalFromValues = (
|
||||
|
||||
// If the key doesn't exist in schema, create it from `additionalProperties`
|
||||
if (!schemaNode.properties![k]) {
|
||||
- schemaNode.properties![k] = makeChildFromAP(ap)
|
||||
+ // Check if there's a nested property definition in additionalProperties
|
||||
+ const nestedProp = ap?.properties?.[k]
|
||||
+ if (nestedProp) {
|
||||
+ // Use the nested property definition from additionalProperties
|
||||
+ schemaNode.properties![k] = _.cloneDeep(nestedProp) as any
|
||||
+ ;(schemaNode.properties![k] as any).isAdditionalProperties = true
|
||||
+ } else {
|
||||
+ // Create from additionalProperties with value-based type inference
|
||||
+ schemaNode.properties![k] = makeChildFromAP(ap, vo[k])
|
||||
+ }
|
||||
// If it's an existing additional property, merge any nested structure
|
||||
} else if ((schemaNode.properties![k] as any).isAdditionalProperties && ap?.properties) {
|
||||
;(schemaNode.properties![k] as any).properties ??= _.cloneDeep(ap.properties)
|
||||
diff --git a/src/components/molecules/BlackholeForm/organisms/BlackholeForm/utils.tsx b/src/components/molecules/BlackholeForm/organisms/BlackholeForm/utils.tsx
|
||||
index 2d887c7..d69d711 100644
|
||||
--- a/src/components/molecules/BlackholeForm/organisms/BlackholeForm/utils.tsx
|
||||
+++ b/src/components/molecules/BlackholeForm/organisms/BlackholeForm/utils.tsx
|
||||
@@ -394,9 +394,11 @@ export const getArrayFormItemFromSwagger = ({
|
||||
{(fields, { add, remove }, { errors }) => (
|
||||
<>
|
||||
{fields.map(field => {
|
||||
- const fieldType = (
|
||||
+ const rawFieldType = (
|
||||
schema.items as (OpenAPIV2.ItemsObject & { properties?: OpenAPIV2.SchemaObject }) | undefined
|
||||
)?.type
|
||||
+ // Handle type as string or string[] (OpenAPI v2 allows both)
|
||||
+ const fieldType = Array.isArray(rawFieldType) ? rawFieldType[0] : rawFieldType
|
||||
const description = (schema.items as (OpenAPIV2.ItemsObject & { description?: string }) | undefined)
|
||||
?.description
|
||||
const entry = schema.items as
|
||||
@@ -577,7 +579,29 @@ export const getArrayFormItemFromSwagger = ({
|
||||
type="text"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
- add()
|
||||
+ // Determine initial value based on item type
|
||||
+ const fieldType = (
|
||||
+ schema.items as (OpenAPIV2.ItemsObject & { properties?: OpenAPIV2.SchemaObject }) | undefined
|
||||
+ )?.type
|
||||
+
|
||||
+ let initialValue: unknown
|
||||
+ // Handle type as string or string[] (OpenAPI v2 allows both)
|
||||
+ const typeStr = Array.isArray(fieldType) ? fieldType[0] : fieldType
|
||||
+ if (typeStr === 'string') {
|
||||
+ initialValue = ''
|
||||
+ } else if (typeStr === 'number' || typeStr === 'integer') {
|
||||
+ initialValue = 0
|
||||
+ } else if (typeStr === 'boolean') {
|
||||
+ initialValue = false
|
||||
+ } else if (typeStr === 'array') {
|
||||
+ initialValue = []
|
||||
+ } else if (typeStr === 'object') {
|
||||
+ initialValue = {}
|
||||
+ } else {
|
||||
+ initialValue = ''
|
||||
+ }
|
||||
+
|
||||
+ add(initialValue)
|
||||
}}
|
||||
>
|
||||
<PlusIcon />
|
||||
@@ -1,91 +0,0 @@
|
||||
diff --git a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
|
||||
index ac56e5f..c6e2350 100644
|
||||
--- a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
|
||||
+++ b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { FC, useState } from 'react'
|
||||
import { Button, Alert, Spin, Typography } from 'antd'
|
||||
-import { filterSelectOptions, Spacer, useBuiltinResources, useApiResources } from '@prorobotech/openapi-k8s-toolkit'
|
||||
+import { filterSelectOptions, Spacer, useApiResources } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
@@ -11,6 +11,11 @@ import {
|
||||
CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME,
|
||||
} from 'constants/customizationApiGroupAndVersion'
|
||||
import { Styled } from './styled'
|
||||
+import {
|
||||
+ BASE_PROJECTS_API_GROUP,
|
||||
+ BASE_PROJECTS_VERSION,
|
||||
+ BASE_PROJECTS_RESOURCE_NAME,
|
||||
+} from 'constants/customizationApiGroupAndVersion'
|
||||
|
||||
export const ListInsideClusterAndNs: FC = () => {
|
||||
const clusterList = useSelector((state: RootState) => state.clusterList.clusterList)
|
||||
@@ -33,9 +38,11 @@ export const ListInsideClusterAndNs: FC = () => {
|
||||
typeof CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME === 'string' &&
|
||||
CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME.length > 0
|
||||
|
||||
- const namespacesData = useBuiltinResources({
|
||||
+ const namespacesData = useApiResources({
|
||||
clusterName: selectedCluster || '',
|
||||
- typeName: 'namespaces',
|
||||
+ apiGroup: BASE_PROJECTS_API_GROUP,
|
||||
+ apiVersion: BASE_PROJECTS_VERSION,
|
||||
+ typeName: BASE_PROJECTS_RESOURCE_NAME,
|
||||
limit: null,
|
||||
isEnabled: selectedCluster !== undefined && !isCustomNamespaceResource,
|
||||
})
|
||||
diff --git a/src/hooks/useNavSelectorInside.ts b/src/hooks/useNavSelectorInside.ts
|
||||
index 5736e2b..1ec0f71 100644
|
||||
--- a/src/hooks/useNavSelectorInside.ts
|
||||
+++ b/src/hooks/useNavSelectorInside.ts
|
||||
@@ -1,6 +1,11 @@
|
||||
-import { TClusterList, TSingleResource, useBuiltinResources } from '@prorobotech/openapi-k8s-toolkit'
|
||||
+import { TClusterList, TSingleResource, useApiResources } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
+import {
|
||||
+ BASE_PROJECTS_API_GROUP,
|
||||
+ BASE_PROJECTS_VERSION,
|
||||
+ BASE_PROJECTS_RESOURCE_NAME,
|
||||
+} from 'constants/customizationApiGroupAndVersion'
|
||||
|
||||
const mappedClusterToOptionInSidebar = ({ name }: TClusterList[number]): { value: string; label: string } => ({
|
||||
value: name,
|
||||
@@ -15,9 +20,11 @@ const mappedNamespaceToOptionInSidebar = ({ metadata }: TSingleResource): { valu
|
||||
export const useNavSelectorInside = (clusterName?: string) => {
|
||||
const clusterList = useSelector((state: RootState) => state.clusterList.clusterList)
|
||||
|
||||
- const { data: namespaces } = useBuiltinResources({
|
||||
+ const { data: namespaces } = useApiResources({
|
||||
clusterName: clusterName || '',
|
||||
- typeName: 'namespaces',
|
||||
+ apiGroup: BASE_PROJECTS_API_GROUP,
|
||||
+ apiVersion: BASE_PROJECTS_VERSION,
|
||||
+ typeName: BASE_PROJECTS_RESOURCE_NAME,
|
||||
limit: null,
|
||||
isEnabled: Boolean(clusterName),
|
||||
})
|
||||
diff --git a/src/utils/getBacklink.ts b/src/utils/getBacklink.ts
|
||||
index a862354..f24e2bc 100644
|
||||
--- a/src/utils/getBacklink.ts
|
||||
+++ b/src/utils/getBacklink.ts
|
||||
@@ -28,7 +28,7 @@ export const getFormsBackLink = ({
|
||||
}
|
||||
|
||||
if (namespacesMode) {
|
||||
- return `${baseprefix}/${clusterName}/builtin-table/namespaces`
|
||||
+ return `${baseprefix}/${clusterName}/api-table/core.cozystack.io/v1alpha1/tenantnamespaces`
|
||||
}
|
||||
|
||||
if (possibleProject) {
|
||||
@@ -64,7 +64,7 @@ export const getTablesBackLink = ({
|
||||
}
|
||||
|
||||
if (namespacesMode) {
|
||||
- return `${baseprefix}/${clusterName}/builtin-table/namespaces`
|
||||
+ return `${baseprefix}/${clusterName}/api-table/core.cozystack.io/v1alpha1/tenantnamespaces`
|
||||
}
|
||||
|
||||
if (possibleProject) {
|
||||
@@ -1,15 +0,0 @@
|
||||
diff --git a/src/components/organisms/Header/organisms/User/User.tsx b/src/components/organisms/Header/organisms/User/User.tsx
|
||||
index efe7ac3..80b715c 100644
|
||||
--- a/src/components/organisms/Header/organisms/User/User.tsx
|
||||
+++ b/src/components/organisms/Header/organisms/User/User.tsx
|
||||
@@ -23,10 +23,6 @@ export const User: FC = () => {
|
||||
// key: '1',
|
||||
// label: <ThemeSelector />,
|
||||
// },
|
||||
- {
|
||||
- key: '2',
|
||||
- label: <div onClick={() => navigate(`${baseprefix}/inside/clusters`)}>Inside</div>,
|
||||
- },
|
||||
{
|
||||
key: '3',
|
||||
label: (
|
||||
@@ -1,6 +1,6 @@
|
||||
{{- $brandingConfig:= lookup "v1" "ConfigMap" "cozy-system" "cozystack-branding" }}
|
||||
|
||||
{{- $tenantText := "latest" }}
|
||||
{{- $tenantText := "v0.38.0" }}
|
||||
{{- $footerText := "Cozystack" }}
|
||||
{{- $titleText := "Cozystack Dashboard" }}
|
||||
{{- $logoText := "" }}
|
||||
|
||||
@@ -34,6 +34,14 @@ data:
|
||||
}
|
||||
|
||||
location /k8s {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $host;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_send_timeout 86400s;
|
||||
|
||||
rewrite /k8s/(.*) /$1 break;
|
||||
proxy_pass https://kubernetes.default.svc:443;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ spec:
|
||||
- name: BASE_NAMESPACE_FULL_PATH
|
||||
value: "/apis/core.cozystack.io/v1alpha1/tenantnamespaces"
|
||||
- name: LOGGER
|
||||
value: "TRUE"
|
||||
value: "true"
|
||||
- name: LOGGER_WITH_HEADERS
|
||||
value: "TRUE"
|
||||
value: "false"
|
||||
- name: PORT
|
||||
value: "64231"
|
||||
image: {{ .Values.openapiUIK8sBff.image | quote }}
|
||||
@@ -94,6 +94,8 @@ spec:
|
||||
- env:
|
||||
- name: BASEPREFIX
|
||||
value: /openapi-ui
|
||||
- name: HIDE_INSIDE
|
||||
value: "true"
|
||||
- name: CUSTOMIZATION_API_GROUP
|
||||
value: dashboard.cozystack.io
|
||||
- name: CUSTOMIZATION_API_VERSION
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
openapiUI:
|
||||
image: ghcr.io/cozystack/cozystack/openapi-ui:latest@sha256:b942d98ff0ea36e3c6e864b6459b404d37ed68bc2b0ebc5d3007a1be4faf60c5
|
||||
image: ghcr.io/cozystack/cozystack/openapi-ui:v0.38.0@sha256:78570edb9f4e329ffed0f8da3942acee1536323169d56324e57360df66044c28
|
||||
openapiUIK8sBff:
|
||||
image: ghcr.io/cozystack/cozystack/openapi-ui-k8s-bff:latest@sha256:5ddc6546baf3acdb8e0572536665fe73053a7f985b05e51366454efa11c201d2
|
||||
image: ghcr.io/cozystack/cozystack/openapi-ui-k8s-bff:v0.38.0@sha256:b7f18b86913d94338f1ceb93fca6409d19f565e35d6d6e683ca93441920fec71
|
||||
tokenProxy:
|
||||
image: ghcr.io/cozystack/cozystack/token-proxy:latest@sha256:fad27112617bb17816702571e1f39d0ac3fe5283468d25eb12f79906cdab566b
|
||||
image: ghcr.io/cozystack/cozystack/token-proxy:v0.38.0@sha256:fad27112617bb17816702571e1f39d0ac3fe5283468d25eb12f79906cdab566b
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
strimzi-kafka-operator:
|
||||
watchAnyNamespace: true
|
||||
generateNetworkPolicy: false
|
||||
kubernetesServiceDnsDomain: cozy.local
|
||||
kubernetesServiceDnsDomain: cozy.local
|
||||
resources:
|
||||
limits:
|
||||
memory: 512Mi
|
||||
|
||||
@@ -3,7 +3,7 @@ kamaji:
|
||||
deploy: false
|
||||
image:
|
||||
pullPolicy: IfNotPresent
|
||||
tag: v0.37.0@sha256:9f4fd5045ede2909fbaf2572e4138fcbd8921071ecf8f08446257fddd0e6f655
|
||||
tag: v0.38.0@sha256:125e4e6a8b86418e891416d29353053ab8b65182b7e443f221b557c11a385280
|
||||
repository: ghcr.io/cozystack/cozystack/kamaji
|
||||
resources:
|
||||
limits:
|
||||
@@ -13,4 +13,4 @@ kamaji:
|
||||
cpu: 100m
|
||||
memory: 100Mi
|
||||
extraArgs:
|
||||
- --migrate-image=ghcr.io/cozystack/cozystack/kamaji:v0.37.0@sha256:9f4fd5045ede2909fbaf2572e4138fcbd8921071ecf8f08446257fddd0e6f655
|
||||
- --migrate-image=ghcr.io/cozystack/cozystack/kamaji:v0.38.0@sha256:125e4e6a8b86418e891416d29353053ab8b65182b7e443f221b557c11a385280
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
portSecurity: true
|
||||
routes: ""
|
||||
image: ghcr.io/cozystack/cozystack/kubeovn-plunger:v0.37.0@sha256:9950614571ea77a55925eba0839b6b12c8e5a7a30b8858031a8c6050f261af1a
|
||||
image: ghcr.io/cozystack/cozystack/kubeovn-plunger:v0.38.0@sha256:a140bdcc300bcfb63a5d64884d02d802d7669ba96dc65292a06f3b200ff627f8
|
||||
ovnCentralName: ovn-central
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
portSecurity: true
|
||||
routes: ""
|
||||
image: ghcr.io/cozystack/cozystack/kubeovn-webhook:v0.37.0@sha256:7e63205708e607ce2cedfe2a2cafd323ca51e3ebc71244a21ff6f9016c6c87bc
|
||||
image: ghcr.io/cozystack/cozystack/kubeovn-webhook:v0.38.0@sha256:7bfd458299a507f2cf82cddb65941ded6991fd4ba92fd46010cbc8c363126085
|
||||
|
||||
@@ -44,7 +44,7 @@ kube-ovn:
|
||||
memory: "50Mi"
|
||||
limits:
|
||||
cpu: "1000m"
|
||||
memory: "1Gi"
|
||||
memory: "2Gi"
|
||||
kube-ovn-pinger:
|
||||
requests:
|
||||
cpu: "10m"
|
||||
@@ -65,4 +65,4 @@ global:
|
||||
images:
|
||||
kubeovn:
|
||||
repository: kubeovn
|
||||
tag: v1.14.5@sha256:af10da442a0c6dc7df47a0ef752e2eb5c247bb0b43069fdfcb2aa51511185ea2
|
||||
tag: v1.14.11@sha256:1b0f472cf30d5806e3afd10439ce8f9cfe8a004322dbd1911f7d69171fe936e5
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
storageClass: replicated
|
||||
csiDriver:
|
||||
image: ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.0.0@sha256:c8b08084a86251cdd18e237de89b695bca0e4f7eb1f1f6ddc2b903b4d74ea5ff
|
||||
image: ghcr.io/cozystack/cozystack/kubevirt-csi-driver:0.0.0@sha256:d5c836ba33cf5dbed7e6f866784f668f80ffe69179e7c75847b680111984eefb
|
||||
|
||||
@@ -22,7 +22,13 @@ spec:
|
||||
- GPU
|
||||
- VMExport
|
||||
evictionStrategy: LiveMigrate
|
||||
vmRolloutStrategy: LiveUpdate
|
||||
workloadUpdateStrategy:
|
||||
workloadUpdateMethods:
|
||||
- LiveMigrate
|
||||
- Evict
|
||||
batchEvictionInterval: 1m
|
||||
batchEvictionSize: 10
|
||||
customizeComponents: {}
|
||||
imagePullPolicy: IfNotPresent
|
||||
monitorNamespace: tenant-root
|
||||
workloadUpdateStrategy: {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
lineageControllerWebhook:
|
||||
image: ghcr.io/cozystack/cozystack/lineage-controller-webhook:v0.37.0@sha256:845b8e68cbc277c2303080bcd55597e4334610d396dad258ad56fd906530acc3
|
||||
image: ghcr.io/cozystack/cozystack/lineage-controller-webhook:v0.38.0@sha256:fc2b04f59757904ec1557a39529b84b595114b040ef95d677fd7f21ac3958e0a
|
||||
debug: false
|
||||
localK8sAPIEndpoint:
|
||||
enabled: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
dependencies:
|
||||
- name: mariadb-operator-crds
|
||||
repository: file://../mariadb-operator-crds
|
||||
version: 0.38.1
|
||||
digest: sha256:0f2ff90b83955a060f581b7db4a0c746338ae3a50d9766877c346c7f61d74cde
|
||||
generated: "2025-04-15T16:54:07.813989419Z"
|
||||
version: 25.10.2
|
||||
digest: sha256:01b102dbdb92970e38346df382ed3e5cd93d02a3b642029e94320256c9bfad42
|
||||
generated: "2025-10-28T11:29:04.951947063Z"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
apiVersion: v2
|
||||
appVersion: 0.38.1
|
||||
appVersion: 25.10.2
|
||||
dependencies:
|
||||
- condition: crds.enabled
|
||||
name: mariadb-operator-crds
|
||||
repository: file://../mariadb-operator-crds
|
||||
version: 0.38.1
|
||||
version: 25.10.2
|
||||
description: Run and operate MariaDB in a cloud native way
|
||||
home: https://github.com/mariadb-operator/mariadb-operator
|
||||
icon: https://mariadb-operator.github.io/mariadb-operator/assets/mariadb_profile.svg
|
||||
@@ -21,4 +21,4 @@ maintainers:
|
||||
name: mmontes11
|
||||
name: mariadb-operator
|
||||
type: application
|
||||
version: 0.38.1
|
||||
version: 25.10.2
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[//]: # (README.md generated by gotmpl. DO NOT EDIT.)
|
||||
|
||||
  
|
||||
  
|
||||
|
||||
Run and operate MariaDB in a cloud native way
|
||||
|
||||
@@ -16,7 +16,7 @@ helm install mariadb-operator-crds mariadb-operator/mariadb-operator-crds
|
||||
helm install mariadb-operator mariadb-operator/mariadb-operator
|
||||
```
|
||||
|
||||
Refer to the [helm documentation](https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/HELM.md) for further detail.
|
||||
Refer to the [helm documentation](https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/helm.md) for further detail.
|
||||
|
||||
## Values
|
||||
|
||||
@@ -60,14 +60,15 @@ Refer to the [helm documentation](https://github.com/mariadb-operator/mariadb-op
|
||||
| certController.tolerations | list | `[]` | Tolerations to add to cert-controller container |
|
||||
| certController.topologySpreadConstraints | list | `[]` | topologySpreadConstraints to add to cert-controller container |
|
||||
| clusterName | string | `"cluster.local"` | Cluster DNS name |
|
||||
| config | object | `{"exporterImage":"prom/mysqld-exporter:v0.15.1","exporterMaxscaleImage":"docker-registry2.mariadb.com/mariadb/maxscale-prometheus-exporter-ubi:v0.0.1","galeraLibPath":"/usr/lib/galera/libgalera_smm.so","mariadbDefaultVersion":"11.4","mariadbImage":"docker-registry1.mariadb.com/library/mariadb:11.4.5","maxscaleImage":"docker-registry2.mariadb.com/mariadb/maxscale:23.08.5"}` | Operator configuration |
|
||||
| config | object | `{"exporterImage":"prom/mysqld-exporter:v0.15.1","exporterMaxscaleImage":"docker-registry2.mariadb.com/mariadb/maxscale-prometheus-exporter-ubi:v0.0.1","galeraLibPath":"/usr/lib/galera/libgalera_smm.so","mariadbDefaultVersion":"11.8","mariadbImage":"docker-registry1.mariadb.com/library/mariadb:11.8.2","mariadbImageName":"docker-registry1.mariadb.com/library/mariadb","maxscaleImage":"docker-registry2.mariadb.com/mariadb/maxscale:23.08.5"}` | Operator configuration |
|
||||
| config.exporterImage | string | `"prom/mysqld-exporter:v0.15.1"` | Default MariaDB exporter image |
|
||||
| config.exporterMaxscaleImage | string | `"docker-registry2.mariadb.com/mariadb/maxscale-prometheus-exporter-ubi:v0.0.1"` | Default MaxScale exporter image |
|
||||
| config.galeraLibPath | string | `"/usr/lib/galera/libgalera_smm.so"` | Galera library path to be used with MariaDB Galera |
|
||||
| config.mariadbDefaultVersion | string | `"11.4"` | Default MariaDB version to be used when unable to infer it via image tag |
|
||||
| config.mariadbImage | string | `"docker-registry1.mariadb.com/library/mariadb:11.4.5"` | Default MariaDB image |
|
||||
| config.mariadbDefaultVersion | string | `"11.8"` | Default MariaDB version to be used when unable to infer it via image tag |
|
||||
| config.mariadbImage | string | `"docker-registry1.mariadb.com/library/mariadb:11.8.2"` | Default MariaDB image |
|
||||
| config.mariadbImageName | string | `"docker-registry1.mariadb.com/library/mariadb"` | Default MariaDB image name |
|
||||
| config.maxscaleImage | string | `"docker-registry2.mariadb.com/mariadb/maxscale:23.08.5"` | Default MaxScale image |
|
||||
| crds | object | `{"enabled":false}` | - CRDs |
|
||||
| crds | object | `{"enabled":false}` | CRDs |
|
||||
| crds.enabled | bool | `false` | Whether the helm chart should create and update the CRDs. It is false by default, which implies that the CRDs must be managed independently with the mariadb-operator-crds helm chart. **WARNING** This should only be set to true during the initial deployment. If this chart manages the CRDs and is later uninstalled, all MariaDB instances will be DELETED. |
|
||||
| currentNamespaceOnly | bool | `false` | Whether the operator should watch CRDs only in its own namespace or not. |
|
||||
| extrArgs | list | `[]` | Extra arguments to be passed to the controller entrypoint |
|
||||
|
||||
@@ -17,6 +17,6 @@ helm install mariadb-operator-crds mariadb-operator/mariadb-operator-crds
|
||||
helm install mariadb-operator mariadb-operator/mariadb-operator
|
||||
```
|
||||
|
||||
Refer to the [helm documentation](https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/HELM.md) for further detail.
|
||||
Refer to the [helm documentation](https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/helm.md) for further detail.
|
||||
|
||||
{{ template "chart.valuesSection" . }}
|
||||
|
||||
@@ -16,4 +16,4 @@ maintainers:
|
||||
name: mmontes11
|
||||
name: mariadb-operator-crds
|
||||
type: application
|
||||
version: 0.38.1
|
||||
version: 25.10.2
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
mariadb-operator has been successfully deployed! 🦭
|
||||
|
||||
Not sure what to do next? 😅 Check out:
|
||||
https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/QUICKSTART.md
|
||||
https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/quickstart.md
|
||||
|
||||
@@ -51,10 +51,10 @@ rules:
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
- discovery.k8s.io
|
||||
resources:
|
||||
- endpoints
|
||||
- endpoints/restricted
|
||||
- endpointslices
|
||||
- endpointslices/restricted
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
|
||||
@@ -4,6 +4,7 @@ data:
|
||||
MARIADB_GALERA_LIB_PATH: "{{ .Values.config.galeraLibPath }}"
|
||||
MARIADB_DEFAULT_VERSION: "{{ .Values.config.mariadbDefaultVersion }}"
|
||||
RELATED_IMAGE_MARIADB: "{{ .Values.config.mariadbImage }}"
|
||||
RELATED_IMAGE_MARIADB_NAME: "{{ .Values.config.mariadbImageName }}"
|
||||
RELATED_IMAGE_MAXSCALE: "{{ .Values.config.maxscaleImage }}"
|
||||
RELATED_IMAGE_EXPORTER: "{{ .Values.config.exporterImage }}"
|
||||
RELATED_IMAGE_EXPORTER_MAXSCALE: "{{ .Values.config.exporterMaxscaleImage }}"
|
||||
|
||||
@@ -36,17 +36,6 @@ rules:
|
||||
verbs:
|
||||
- create
|
||||
- patch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- endpoints
|
||||
- endpoints/restricted
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
@@ -65,6 +54,7 @@ rules:
|
||||
- persistentvolumeclaims
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- deletecollection
|
||||
- list
|
||||
- patch
|
||||
@@ -121,6 +111,7 @@ rules:
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
@@ -133,6 +124,17 @@ rules:
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- discovery.k8s.io
|
||||
resources:
|
||||
- endpointslices
|
||||
- endpointslices/restricted
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- k8s.mariadb.com
|
||||
resources:
|
||||
@@ -141,7 +143,9 @@ rules:
|
||||
- databases
|
||||
- grants
|
||||
- mariadbs
|
||||
- externalmariadbs
|
||||
- maxscales
|
||||
- physicalbackups
|
||||
- restores
|
||||
- sqljobs
|
||||
- users
|
||||
@@ -161,7 +165,9 @@ rules:
|
||||
- databases/finalizers
|
||||
- grants/finalizers
|
||||
- mariadbs/finalizers
|
||||
- externalmariadbs/finalizers
|
||||
- maxscales/finalizers
|
||||
- physicalbackups/finalizers
|
||||
- restores/finalizers
|
||||
- sqljobs/finalizers
|
||||
- users/finalizers
|
||||
@@ -175,7 +181,9 @@ rules:
|
||||
- databases/status
|
||||
- grants/status
|
||||
- mariadbs/status
|
||||
- externalmariadbs/status
|
||||
- maxscales/status
|
||||
- physicalbackups/status
|
||||
- restores/status
|
||||
- sqljobs/status
|
||||
- users/status
|
||||
@@ -220,6 +228,17 @@ rules:
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- snapshot.storage.k8s.io
|
||||
resources:
|
||||
- volumesnapshots
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
|
||||
@@ -53,17 +53,6 @@ rules:
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- endpoints
|
||||
- endpoints/restricted
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
@@ -82,6 +71,7 @@ rules:
|
||||
- persistentvolumeclaims
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- deletecollection
|
||||
- list
|
||||
- patch
|
||||
@@ -150,6 +140,7 @@ rules:
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
@@ -162,6 +153,17 @@ rules:
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- discovery.k8s.io
|
||||
resources:
|
||||
- endpointslices
|
||||
- endpointslices/restricted
|
||||
verbs:
|
||||
- create
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- k8s.mariadb.com
|
||||
resources:
|
||||
@@ -170,7 +172,9 @@ rules:
|
||||
- databases
|
||||
- grants
|
||||
- mariadbs
|
||||
- externalmariadbs
|
||||
- maxscales
|
||||
- physicalbackups
|
||||
- restores
|
||||
- sqljobs
|
||||
- users
|
||||
@@ -190,7 +194,9 @@ rules:
|
||||
- databases/finalizers
|
||||
- grants/finalizers
|
||||
- mariadbs/finalizers
|
||||
- externalmariadbs/finalizers
|
||||
- maxscales/finalizers
|
||||
- physicalbackups/finalizers
|
||||
- restores/finalizers
|
||||
- sqljobs/finalizers
|
||||
- users/finalizers
|
||||
@@ -204,7 +210,9 @@ rules:
|
||||
- databases/status
|
||||
- grants/status
|
||||
- mariadbs/status
|
||||
- externalmariadbs/status
|
||||
- maxscales/status
|
||||
- physicalbackups/status
|
||||
- restores/status
|
||||
- sqljobs/status
|
||||
- users/status
|
||||
@@ -250,6 +258,17 @@ rules:
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
- apiGroups:
|
||||
- snapshot.storage.k8s.io
|
||||
resources:
|
||||
- volumesnapshots
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- watch
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
|
||||
@@ -1,41 +1,5 @@
|
||||
{{ if and (not .Values.currentNamespaceOnly) .Values.webhook.enabled }}
|
||||
{{ $fullName := include "mariadb-operator.fullname" . }}
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: MutatingWebhookConfiguration
|
||||
metadata:
|
||||
name: {{ $fullName }}-webhook
|
||||
labels:
|
||||
{{- include "mariadb-operator-webhook.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- if .Values.webhook.cert.certManager.enabled }}
|
||||
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "mariadb-operator.fullname" . }}-webhook-cert
|
||||
{{- else }}
|
||||
k8s.mariadb.com/webhook: ""
|
||||
{{- end }}
|
||||
{{- with .Values.webhook.annotations }}
|
||||
{{ toYaml . | indent 4 }}
|
||||
{{- end }}
|
||||
webhooks:
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
service:
|
||||
name: {{ $fullName }}-webhook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /mutate-k8s-mariadb-com-v1alpha1-mariadb
|
||||
failurePolicy: Fail
|
||||
name: mmariadb-v1alpha1.kb.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- k8s.mariadb.com
|
||||
apiVersions:
|
||||
- v1alpha1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- mariadbs
|
||||
sideEffects: None
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingWebhookConfiguration
|
||||
@@ -73,6 +37,26 @@ webhooks:
|
||||
resources:
|
||||
- backups
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
service:
|
||||
name: {{ $fullName }}-webhook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-k8s-mariadb-com-v1alpha1-physicalbackup
|
||||
failurePolicy: Fail
|
||||
name: vphysicalbackup-v1alpha1.kb.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- k8s.mariadb.com
|
||||
apiVersions:
|
||||
- v1alpha1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- physicalbackups
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
@@ -233,4 +217,4 @@ webhooks:
|
||||
resources:
|
||||
- users
|
||||
sideEffects: None
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
# --- CRDs
|
||||
# -- CRDs
|
||||
crds:
|
||||
# -- Whether the helm chart should create and update the CRDs. It is false by default, which implies that the CRDs must be
|
||||
# managed independently with the mariadb-operator-crds helm chart.
|
||||
@@ -310,9 +310,11 @@ config:
|
||||
# -- Galera library path to be used with MariaDB Galera
|
||||
galeraLibPath: /usr/lib/galera/libgalera_smm.so
|
||||
# -- Default MariaDB version to be used when unable to infer it via image tag
|
||||
mariadbDefaultVersion: "11.4"
|
||||
mariadbDefaultVersion: "11.8"
|
||||
# -- Default MariaDB image
|
||||
mariadbImage: docker-registry1.mariadb.com/library/mariadb:11.4.5
|
||||
mariadbImage: docker-registry1.mariadb.com/library/mariadb:11.8.2
|
||||
# -- Default MariaDB image name
|
||||
mariadbImageName: docker-registry1.mariadb.com/library/mariadb
|
||||
# -- Default MaxScale image
|
||||
maxscaleImage: docker-registry2.mariadb.com/mariadb/maxscale:23.08.5
|
||||
# -- Default MariaDB exporter image
|
||||
|
||||
@@ -154,7 +154,7 @@ spec:
|
||||
serviceAccountName: multus
|
||||
containers:
|
||||
- name: kube-multus
|
||||
image: ghcr.io/k8snetworkplumbingwg/multus-cni:v4.2.2-thick
|
||||
image: ghcr.io/k8snetworkplumbingwg/multus-cni:v4.2.3-thick
|
||||
command: [ "/usr/src/multus-cni/bin/multus-daemon" ]
|
||||
resources:
|
||||
requests:
|
||||
@@ -162,7 +162,7 @@ spec:
|
||||
memory: "100Mi"
|
||||
limits:
|
||||
cpu: "100m"
|
||||
memory: "100Mi"
|
||||
memory: "300Mi"
|
||||
securityContext:
|
||||
privileged: true
|
||||
terminationMessagePolicy: FallbackToLogsOnError
|
||||
@@ -201,11 +201,13 @@ spec:
|
||||
fieldPath: spec.nodeName
|
||||
initContainers:
|
||||
- name: install-multus-binary
|
||||
image: ghcr.io/k8snetworkplumbingwg/multus-cni:v4.2.2-thick
|
||||
image: ghcr.io/k8snetworkplumbingwg/multus-cni:v4.2.3-thick
|
||||
command:
|
||||
- "sh"
|
||||
- "-c"
|
||||
- "cp /usr/src/multus-cni/bin/multus-shim /host/opt/cni/bin/multus-shim && cp /usr/src/multus-cni/bin/passthru /host/opt/cni/bin/passthru"
|
||||
- "/usr/src/multus-cni/bin/install_multus"
|
||||
- "-d"
|
||||
- "/host/opt/cni/bin"
|
||||
- "-t"
|
||||
- "thick"
|
||||
resources:
|
||||
requests:
|
||||
cpu: "10m"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
objectstorage:
|
||||
controller:
|
||||
image: "ghcr.io/cozystack/cozystack/objectstorage-controller:v0.37.0@sha256:5f2eed05d19ba971806374834cb16ca49282aac76130194c00b213c79ce3e10d"
|
||||
image: "ghcr.io/cozystack/cozystack/objectstorage-controller:v0.38.0@sha256:7d37495cce46d30d4613ecfacaa7b7f140e7ea8f3dbcc3e8c976e271de6cc71b"
|
||||
|
||||
@@ -3,8 +3,8 @@ name: piraeus
|
||||
description: |
|
||||
The Piraeus Operator manages software defined storage clusters using LINSTOR in Kubernetes.
|
||||
type: application
|
||||
version: 2.9.1
|
||||
appVersion: "v2.9.1"
|
||||
version: 2.10.1
|
||||
appVersion: "v2.10.1"
|
||||
maintainers:
|
||||
- name: Piraeus Datastore
|
||||
url: https://piraeus.io
|
||||
|
||||
@@ -3,33 +3,8 @@
|
||||
Deploys the [Piraeus Operator](https://github.com/piraeusdatastore/piraeus-operator) which deploys and manages a simple
|
||||
and resilient storage solution for Kubernetes.
|
||||
|
||||
The main deployment method for Piraeus Operator switched to [`kustomize`](../../docs/tutorial)
|
||||
The main deployment method for Piraeus Operator switched to [`kustomize`](https://piraeus.io/docs/stable/tutorial/get-started/)
|
||||
in release `v2.0.0`. This chart is intended for users who want to continue using Helm.
|
||||
|
||||
This chart **only** configures the Operator, but does not create the `LinstorCluster` resource creating the actual
|
||||
storage system. Refer to the existing [tutorials](../../docs/tutorial)
|
||||
and [how-to guides](../../docs/how-to).
|
||||
|
||||
## Deploying Piraeus Operator
|
||||
|
||||
To deploy Piraeus Operator with Helm, clone this repository and deploy the chart:
|
||||
|
||||
```
|
||||
$ git clone --branch v2 https://github.com/piraeusdatastore/piraeus-operator
|
||||
$ cd piraeus-operator
|
||||
$ helm install piraeus-operator charts/piraeus-operator --create-namespace -n piraeus-datastore
|
||||
```
|
||||
|
||||
Follow the instructions printed by Helm to create your storage cluster:
|
||||
|
||||
```
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: piraeus.io/v1
|
||||
kind: LinstorCluster
|
||||
metadata:
|
||||
name: linstorcluster
|
||||
spec: {}
|
||||
EOF
|
||||
```
|
||||
|
||||
Check out our [documentation](../../docs) for more information.
|
||||
storage system. Refer to the [how-to guide](https://piraeus.io/docs/stable/how-to/helm/).
|
||||
|
||||
@@ -14,7 +14,7 @@ Piraeus Operator installed.
|
||||
` }}
|
||||
{{- end }}
|
||||
|
||||
{{- if not (.Capabilities.APIVersions.Has "piraeus.io/v1/LinstorCluster") }}
|
||||
{{- if and (not (.Capabilities.APIVersions.Has "piraeus.io/v1/LinstorCluster")) (not .Values.installCRDs) }}
|
||||
It looks like the necessary CRDs for Piraeus Operator are still missing.
|
||||
|
||||
To apply them via helm now use:
|
||||
@@ -23,18 +23,12 @@ To apply them via helm now use:
|
||||
|
||||
Alternatively, you can manage them manually:
|
||||
|
||||
kubectl apply --server-side -k "https://github.com/piraeusdatastore/piraeus-operator//config/crd?ref=v2"
|
||||
kubectl apply --server-side -k "https://github.com/piraeusdatastore/piraeus-operator//config/crd?ref={{ .Chart.AppVersion }}"
|
||||
|
||||
{{- end }}
|
||||
|
||||
To get started with Piraeus, simply run:
|
||||
To get started with Piraeus Datastore deploy the "linstor-cluster" chart:
|
||||
|
||||
$ kubectl apply -f - <<EOF
|
||||
apiVersion: piraeus.io/v1
|
||||
kind: LinstorCluster
|
||||
metadata:
|
||||
name: linstorcluster
|
||||
spec: {}
|
||||
EOF
|
||||
$ helm upgrade --install --namespace {{ .Release.Namespace }} linstor-cluster oci://ghcr.io/piraeusdatastore/helm-charts/linstor-cluster
|
||||
|
||||
For next steps, check out our documentation at https://github.com/piraeusdatastore/piraeus-operator/tree/v2/docs
|
||||
For next steps, check out our documentation at https://piraeus.io/docs/{{ .Chart.AppVersion }}
|
||||
|
||||
@@ -23,20 +23,26 @@ data:
|
||||
tag: v1.32.3
|
||||
image: piraeus-server
|
||||
linstor-csi:
|
||||
tag: v1.9.0
|
||||
tag: v1.10.2
|
||||
image: piraeus-csi
|
||||
nfs-server:
|
||||
tag: v1.10.2
|
||||
image: piraeus-csi-nfs-server
|
||||
drbd-reactor:
|
||||
tag: v1.9.0
|
||||
tag: v1.10.0
|
||||
image: drbd-reactor
|
||||
ha-controller:
|
||||
tag: v1.3.0
|
||||
tag: v1.3.1
|
||||
image: piraeus-ha-controller
|
||||
drbd-shutdown-guard:
|
||||
tag: v1.0.0
|
||||
tag: v1.1.1
|
||||
image: drbd-shutdown-guard
|
||||
ktls-utils:
|
||||
tag: v1.2.1
|
||||
image: ktls-utils
|
||||
linstor-affinity-controller:
|
||||
tag: v1.3.0
|
||||
image: linstor-affinity-controller
|
||||
drbd-module-loader:
|
||||
tag: v9.2.15
|
||||
# The special "match" attribute is used to select an image based on the node's reported OS.
|
||||
@@ -93,13 +99,13 @@ data:
|
||||
tag: v2.17.0
|
||||
image: livenessprobe
|
||||
csi-provisioner:
|
||||
tag: v5.3.0
|
||||
tag: v6.0.0
|
||||
image: csi-provisioner
|
||||
csi-snapshotter:
|
||||
tag: v8.3.0
|
||||
tag: v8.4.0
|
||||
image: csi-snapshotter
|
||||
csi-resizer:
|
||||
tag: v1.14.0
|
||||
tag: v2.0.0
|
||||
image: csi-resizer
|
||||
csi-external-health-monitor-controller:
|
||||
tag: v0.16.0
|
||||
|
||||
@@ -15,7 +15,41 @@ spec:
|
||||
singular: linstorcluster
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
- additionalPrinterColumns:
|
||||
- description: If the LINSTOR Cluster is available
|
||||
jsonPath: .status.conditions[?(@.type=='Available')].status
|
||||
name: Available
|
||||
type: string
|
||||
- description: If the LINSTOR Cluster is fully configured
|
||||
jsonPath: .status.conditions[?(@.type=='Configured')].status
|
||||
name: Configured
|
||||
type: string
|
||||
- description: The version of the LINSTOR Cluster
|
||||
jsonPath: .status.version
|
||||
name: Version
|
||||
priority: 10
|
||||
type: string
|
||||
- description: The number of running/expected Satellites
|
||||
jsonPath: .status.satellites
|
||||
name: Satellites
|
||||
type: string
|
||||
- description: The used capacity in all storage pools
|
||||
jsonPath: .status.capacity
|
||||
name: Used Capacity
|
||||
type: string
|
||||
- description: The number of volumes in the cluster
|
||||
jsonPath: .status.numberOfVolumes
|
||||
name: Volumes
|
||||
type: integer
|
||||
- description: The number of snapshots in the cluster
|
||||
jsonPath: .status.numberOfSnapshots
|
||||
name: Snapshots
|
||||
priority: 10
|
||||
type: integer
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: LinstorCluster is the Schema for the linstorclusters API
|
||||
@@ -40,6 +74,30 @@ spec:
|
||||
spec:
|
||||
description: LinstorClusterSpec defines the desired state of LinstorCluster
|
||||
properties:
|
||||
affinityController:
|
||||
description: AffinityController controls the deployment of the Affinity
|
||||
Controller Deployment.
|
||||
properties:
|
||||
enabled:
|
||||
default: true
|
||||
description: Enable the component.
|
||||
type: boolean
|
||||
podTemplate:
|
||||
description: |-
|
||||
Template to apply to Pods of the component.
|
||||
|
||||
The template is applied as a patch to the default deployment, so it can be "sparse", not listing any
|
||||
containers or volumes that should remain unchanged.
|
||||
See https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates
|
||||
type: object
|
||||
x-kubernetes-map-type: atomic
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
replicas:
|
||||
description: Number of desired pods. Defaults to 1.
|
||||
format: int32
|
||||
minimum: 0
|
||||
type: integer
|
||||
type: object
|
||||
apiTLS:
|
||||
description: |-
|
||||
ApiTLS secures the LINSTOR API.
|
||||
@@ -47,6 +105,11 @@ spec:
|
||||
This configures the TLS key and certificate used to secure the LINSTOR API.
|
||||
nullable: true
|
||||
properties:
|
||||
affinityControllerSecretName:
|
||||
description: |-
|
||||
AffinityControllerSecretName references a secret holding the TLS key and certificate used by the Affinity
|
||||
Controller to monitor volume state. Defaults to "linstor-affinity-controller-tls".
|
||||
type: string
|
||||
apiSecretName:
|
||||
description: |-
|
||||
ApiSecretName references a secret holding the TLS key and certificate used to protect the API.
|
||||
@@ -114,6 +177,11 @@ spec:
|
||||
CsiNodeSecretName references a secret holding the TLS key and certificate used by the CSI Nodes to query
|
||||
the volume state. Defaults to "linstor-csi-node-tls".
|
||||
type: string
|
||||
nfsServerSecretName:
|
||||
description: |-
|
||||
NFSServerSecretName references a secret holding the TLS key and certificate used by the NFS Server to query
|
||||
the cluster state. Defaults to "linstor-csi-nfs-server-tls".
|
||||
type: string
|
||||
type: object
|
||||
controller:
|
||||
description: Controller controls the deployment of the LINSTOR Controller
|
||||
@@ -152,6 +220,11 @@ spec:
|
||||
type: object
|
||||
x-kubernetes-map-type: atomic
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
replicas:
|
||||
description: Number of desired pods. Defaults to 1.
|
||||
format: int32
|
||||
minimum: 0
|
||||
type: integer
|
||||
type: object
|
||||
csiNode:
|
||||
description: CSINode controls the deployment of the CSI Node DaemonSet.
|
||||
@@ -272,6 +345,25 @@ spec:
|
||||
* Store credentials for accessing remotes for backups.
|
||||
See https://linbit.com/drbd-user-guide/linstor-guide-1_0-en/#s-encrypt_commands for more information.
|
||||
type: string
|
||||
nfsServer:
|
||||
description: NFSServer controls the deployment of the LINSTOR CSI
|
||||
NFS Server DaemonSet.
|
||||
properties:
|
||||
enabled:
|
||||
default: true
|
||||
description: Enable the component.
|
||||
type: boolean
|
||||
podTemplate:
|
||||
description: |-
|
||||
Template to apply to Pods of the component.
|
||||
|
||||
The template is applied as a patch to the default deployment, so it can be "sparse", not listing any
|
||||
containers or volumes that should remain unchanged.
|
||||
See https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates
|
||||
type: object
|
||||
x-kubernetes-map-type: atomic
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
nodeAffinity:
|
||||
description: |-
|
||||
NodeAffinity selects the nodes on which LINSTOR Satellites will be deployed.
|
||||
@@ -379,9 +471,16 @@ spec:
|
||||
JSON patch and its targets.
|
||||
properties:
|
||||
options:
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
description: Options is a list of options for the patch
|
||||
properties:
|
||||
allowKindChange:
|
||||
description: AllowKindChange allows kind changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
allowNameChange:
|
||||
description: AllowNameChange allows name changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
type: object
|
||||
patch:
|
||||
description: Patch is the content of a patch.
|
||||
@@ -493,6 +592,15 @@ spec:
|
||||
status:
|
||||
description: LinstorClusterStatus defines the observed state of LinstorCluster
|
||||
properties:
|
||||
availableCapacityBytes:
|
||||
description: The number of bytes in total in all storage pools in
|
||||
the LINSTOR Cluster.
|
||||
format: int64
|
||||
type: integer
|
||||
capacity:
|
||||
description: Capacity mirrors the information from TotalCapacityBytes
|
||||
and FreeCapacityBytes in a human-readable string
|
||||
type: string
|
||||
conditions:
|
||||
description: Current LINSTOR Cluster state
|
||||
items:
|
||||
@@ -553,6 +661,35 @@ spec:
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
freeCapacityBytes:
|
||||
description: The number of bytes free in all storage pools in the
|
||||
LINSTOR Cluster.
|
||||
format: int64
|
||||
type: integer
|
||||
numberOfSnapshots:
|
||||
description: The number of snapshots in the LINSTOR Cluster.
|
||||
format: int32
|
||||
type: integer
|
||||
numberOfVolumes:
|
||||
description: The number of volumes in the LINSTOR Cluster.
|
||||
format: int32
|
||||
type: integer
|
||||
runningSatellites:
|
||||
description: The number of LINSTOR Satellites currently running.
|
||||
format: int32
|
||||
type: integer
|
||||
satellites:
|
||||
description: Satellites mirrors the information from ScheduledSatellites
|
||||
and RunningSatellites in a human-readable string
|
||||
type: string
|
||||
scheduledSatellites:
|
||||
description: The number of LINSTOR Satellites that are expected to
|
||||
run.
|
||||
format: int32
|
||||
type: integer
|
||||
version:
|
||||
description: The Version of the LINSTOR Cluster.
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
@@ -575,7 +712,15 @@ spec:
|
||||
singular: linstornodeconnection
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
- additionalPrinterColumns:
|
||||
- description: If the LINSTOR Node Connection is fully configured
|
||||
jsonPath: .status.conditions[?(@.type=='Configured')].status
|
||||
name: Configured
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: LinstorNodeConnection is the Schema for the linstornodeconnections
|
||||
@@ -777,7 +922,28 @@ spec:
|
||||
singular: linstorsatelliteconfiguration
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
- additionalPrinterColumns:
|
||||
- description: The node selector used
|
||||
jsonPath: .spec.nodeSelector
|
||||
name: Selector
|
||||
type: string
|
||||
- description: If the Configuration was applied
|
||||
jsonPath: .status.conditions[?(@.type=='Applied')].status
|
||||
name: Applied
|
||||
type: string
|
||||
- description: Number of Satellites this Configuration has been applied to
|
||||
jsonPath: .status.matched
|
||||
name: Matched
|
||||
type: integer
|
||||
- description: Satellites this Configuration has been applied to
|
||||
jsonPath: .status.appliedTo
|
||||
name: Satellites
|
||||
priority: 10
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: LinstorSatelliteConfiguration is the Schema for the linstorsatelliteconfigurations
|
||||
@@ -1013,9 +1179,16 @@ spec:
|
||||
JSON patch and its targets.
|
||||
properties:
|
||||
options:
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
description: Options is a list of options for the patch
|
||||
properties:
|
||||
allowKindChange:
|
||||
description: AllowKindChange allows kind changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
allowNameChange:
|
||||
description: AllowNameChange allows name changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
type: object
|
||||
patch:
|
||||
description: Patch is the content of a patch.
|
||||
@@ -1274,6 +1447,12 @@ spec:
|
||||
description: LinstorSatelliteConfigurationStatus defines the observed
|
||||
state of LinstorSatelliteConfiguration
|
||||
properties:
|
||||
appliedTo:
|
||||
description: AppliedTo lists the LinstorSatellite resource this configuration
|
||||
was applied to
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
conditions:
|
||||
description: Current LINSTOR Satellite Config state
|
||||
items:
|
||||
@@ -1334,6 +1513,10 @@ spec:
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
matched:
|
||||
description: Number of configured LinstorSatellite resource.
|
||||
format: int64
|
||||
type: integer
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
@@ -1356,7 +1539,51 @@ spec:
|
||||
singular: linstorsatellite
|
||||
scope: Cluster
|
||||
versions:
|
||||
- name: v1
|
||||
- additionalPrinterColumns:
|
||||
- description: If the LINSTOR Satellite is connected
|
||||
jsonPath: .status.conditions[?(@.type=='Available')].status
|
||||
name: Connected
|
||||
type: string
|
||||
- description: If the LINSTOR Satellite is fully configured
|
||||
jsonPath: .status.conditions[?(@.type=='Configured')].status
|
||||
name: Configured
|
||||
type: string
|
||||
- description: The Satellite Configurations applied to this Satellite
|
||||
jsonPath: .metadata.annotations.piraeus\.io/applied-configurations
|
||||
name: Applied Configurations
|
||||
priority: 10
|
||||
type: string
|
||||
- description: The deletion policy of the Satellite
|
||||
jsonPath: .spec.deletionPolicy
|
||||
name: Deletion Policy
|
||||
type: string
|
||||
- description: The used capacity on the node
|
||||
jsonPath: .status.capacity
|
||||
name: Used Capacity
|
||||
type: string
|
||||
- description: The number of volumes on the node
|
||||
jsonPath: .status.numberOfVolumes
|
||||
name: Volumes
|
||||
type: integer
|
||||
- description: The number of snapshots on the node
|
||||
jsonPath: .status.numberOfSnapshots
|
||||
name: Snapshots
|
||||
priority: 10
|
||||
type: integer
|
||||
- description: The storage providers supported by the node
|
||||
jsonPath: .status.storageProviders
|
||||
name: Storage Providers
|
||||
priority: 10
|
||||
type: string
|
||||
- description: The device layers supported by the node
|
||||
jsonPath: .status.deviceLayers
|
||||
name: Device Layers
|
||||
priority: 10
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: LinstorSatellite is the Schema for the linstorsatellites API
|
||||
@@ -1546,9 +1773,16 @@ spec:
|
||||
JSON patch and its targets.
|
||||
properties:
|
||||
options:
|
||||
additionalProperties:
|
||||
type: boolean
|
||||
description: Options is a list of options for the patch
|
||||
properties:
|
||||
allowKindChange:
|
||||
description: AllowKindChange allows kind changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
allowNameChange:
|
||||
description: AllowNameChange allows name changes to the
|
||||
resource.
|
||||
type: boolean
|
||||
type: object
|
||||
patch:
|
||||
description: Patch is the content of a patch.
|
||||
@@ -1801,6 +2035,15 @@ spec:
|
||||
status:
|
||||
description: LinstorSatelliteStatus defines the observed state of LinstorSatellite
|
||||
properties:
|
||||
availableCapacityBytes:
|
||||
description: The number of bytes in total in all storage pools on
|
||||
this Satellite.
|
||||
format: int64
|
||||
type: integer
|
||||
capacity:
|
||||
description: Capacity mirrors the information from TotalCapacityBytes
|
||||
and FreeCapacityBytes in a human-readable string.
|
||||
type: string
|
||||
conditions:
|
||||
description: Current LINSTOR Satellite state
|
||||
items:
|
||||
@@ -1861,6 +2104,31 @@ spec:
|
||||
x-kubernetes-list-map-keys:
|
||||
- type
|
||||
x-kubernetes-list-type: map
|
||||
deviceLayers:
|
||||
description: DeviceLayers lists the device layers (LUKS, CACHE, etc...)
|
||||
this Satellite supports.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
freeCapacityBytes:
|
||||
description: The number of bytes free in all storage pools on this
|
||||
Satellite.
|
||||
format: int64
|
||||
type: integer
|
||||
numberOfSnapshots:
|
||||
description: The number of snapshots on this Satellite.
|
||||
format: int32
|
||||
type: integer
|
||||
numberOfVolumes:
|
||||
description: The number of volumes on this Satellite.
|
||||
format: int32
|
||||
type: integer
|
||||
storageProviders:
|
||||
description: StorageProviders lists the storage providers (LVM, ZFS,
|
||||
etc...) this Satellite supports.
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
type: object
|
||||
served: true
|
||||
|
||||
@@ -13,9 +13,15 @@ spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "piraeus-operator.selectorLabels" . | nindent 8 }}
|
||||
{{- include "piraeus-operator.selectorLabels" . | nindent 8 }}
|
||||
{{- with .Values.podLabels }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
kubectl.kubernetes.io/default-container: manager
|
||||
{{- with .Values.podAnnotations }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
@@ -90,6 +96,9 @@ spec:
|
||||
{{- end }}
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
{{- with .Values.podSecurityContext }}
|
||||
{{ toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "piraeus-operator.serviceAccountName" . }}
|
||||
terminationGracePeriodSeconds: 10
|
||||
priorityClassName: {{ .Values.priorityClassName | default "system-cluster-critical" }}
|
||||
|
||||
@@ -30,8 +30,18 @@ rules:
|
||||
- ""
|
||||
resources:
|
||||
- nodes
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- persistentvolumeclaims
|
||||
verbs:
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
@@ -92,6 +102,21 @@ rules:
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- cluster.x-k8s.io
|
||||
resources:
|
||||
- machines
|
||||
verbs:
|
||||
- get
|
||||
- update
|
||||
- apiGroups:
|
||||
- discovery.k8s.io
|
||||
resources:
|
||||
- endpointslices
|
||||
- endpointslices/restricted
|
||||
verbs:
|
||||
- create
|
||||
- delete
|
||||
- apiGroups:
|
||||
- events.k8s.io
|
||||
resources:
|
||||
@@ -103,6 +128,32 @@ rules:
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- groupsnapshot.storage.k8s.io
|
||||
resources:
|
||||
- volumegroupsnapshotclasses
|
||||
- volumesnapshots
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- groupsnapshot.storage.k8s.io
|
||||
resources:
|
||||
- volumegroupsnapshotcontents
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
- update
|
||||
- watch
|
||||
- apiGroups:
|
||||
- groupsnapshot.storage.k8s.io
|
||||
resources:
|
||||
- volumegroupsnapshotcontents/status
|
||||
verbs:
|
||||
- patch
|
||||
- update
|
||||
- apiGroups:
|
||||
- internal.linstor.linbit.com
|
||||
resources:
|
||||
@@ -194,7 +245,6 @@ rules:
|
||||
resources:
|
||||
- volumesnapshotcontents
|
||||
verbs:
|
||||
- delete
|
||||
- get
|
||||
- list
|
||||
- patch
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
---
|
||||
replicaCount: 1
|
||||
|
||||
installCRDs: false
|
||||
@@ -18,6 +19,7 @@ operator:
|
||||
|
||||
options:
|
||||
leaderElect: true
|
||||
#clusterApiKubeconfig: "" # set to "<none>" to disable ClusterAPI integration
|
||||
|
||||
resources: { }
|
||||
# limits:
|
||||
@@ -80,6 +82,7 @@ rbac:
|
||||
create: true
|
||||
|
||||
podAnnotations: { }
|
||||
podLabels: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
# fsGroup: 2000
|
||||
|
||||
@@ -124,7 +124,7 @@ seaweedfs:
|
||||
bucketClassName: "seaweedfs"
|
||||
region: ""
|
||||
sidecar:
|
||||
image: "ghcr.io/cozystack/cozystack/objectstorage-sidecar:latest@sha256:f4ec2b5ec8183870e710b32fa11b3af5d97fa664572df5edcff4b593b00f9a7b"
|
||||
image: "ghcr.io/cozystack/cozystack/objectstorage-sidecar:v0.38.0@sha256:4548d85e7e69150aaf52fbb17fb9487e9714bdd8407aff49762cf39b9d0ab29c"
|
||||
certificates:
|
||||
commonName: "SeaweedFS CA"
|
||||
ipAddresses: []
|
||||
|
||||
23
packages/tests/cozy-lib-tests/.helmignore
Normal file
23
packages/tests/cozy-lib-tests/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
24
packages/tests/cozy-lib-tests/Chart.yaml
Normal file
24
packages/tests/cozy-lib-tests/Chart.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: v2
|
||||
name: quota
|
||||
description: Testing chart for cozy-lib
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||
# to be deployed.
|
||||
#
|
||||
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||
type: application
|
||||
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.0
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "1.16.0"
|
||||
2
packages/tests/cozy-lib-tests/Makefile
Normal file
2
packages/tests/cozy-lib-tests/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
test:
|
||||
helm unittest .
|
||||
1
packages/tests/cozy-lib-tests/charts/cozy-lib
Symbolic link
1
packages/tests/cozy-lib-tests/charts/cozy-lib
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../library/cozy-lib
|
||||
8
packages/tests/cozy-lib-tests/templates/tests/quota.yaml
Normal file
8
packages/tests/cozy-lib-tests/templates/tests/quota.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
spec:
|
||||
{{- with .Values.quota }}
|
||||
hard: {{- include "cozy-lib.resources.flatten" (list . $) | nindent 4 }}
|
||||
{{- end }}
|
||||
50
packages/tests/cozy-lib-tests/tests/quota_test.yaml
Normal file
50
packages/tests/cozy-lib-tests/tests/quota_test.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
# ./tests/quota_test.yaml
|
||||
suite: quota helper
|
||||
|
||||
templates:
|
||||
- templates/tests/quota.yaml
|
||||
|
||||
tests:
|
||||
- it: correctly interprets special kubernetes quota types
|
||||
values:
|
||||
- quota_values.yaml
|
||||
|
||||
release:
|
||||
name: myrelease
|
||||
namespace: default
|
||||
revision: 1
|
||||
isUpgrade: false
|
||||
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.hard["limits.cpu"]
|
||||
value: "20"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["requests.cpu"]
|
||||
value: "2"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["limits.foobar"]
|
||||
value: "3"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["requests.foobar"]
|
||||
value: "3"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["services.loadbalancers"]
|
||||
value: "2"
|
||||
|
||||
- equal:
|
||||
path: spec.hard["requests.storage"]
|
||||
value: "5Gi"
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["limits.storage"]
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["limits.services.loadbalancers"]
|
||||
|
||||
- notExists:
|
||||
path: spec.hard["requests.services.loadbalancers"]
|
||||
5
packages/tests/cozy-lib-tests/tests/quota_values.yaml
Normal file
5
packages/tests/cozy-lib-tests/tests/quota_values.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
quota:
|
||||
services.loadbalancers: "2"
|
||||
cpu: "20"
|
||||
storage: "5Gi"
|
||||
foobar: "3"
|
||||
@@ -59,11 +59,9 @@ func RegisterStaticTypes(scheme *runtime.Scheme) {
|
||||
&TenantNamespaceList{},
|
||||
&TenantSecret{},
|
||||
&TenantSecretList{},
|
||||
&TenantSecretsTable{},
|
||||
&TenantSecretsTableList{},
|
||||
&TenantModule{},
|
||||
&TenantModuleList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
klog.V(1).Info("Registered static kinds: TenantNamespace, TenantSecret, TenantSecretsTable, TenantModule")
|
||||
klog.V(1).Info("Registered static kinds: TenantNamespace, TenantSecret, TenantModule")
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
package v1alpha1
|
||||
|
||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
// TenantSecretEntry represents a single key from a Secret's data.
|
||||
type TenantSecretEntry struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// TenantSecretsTable is a virtual, namespaced resource that exposes every key
|
||||
// of Secrets labelled cozystack.io/ui=true as a separate object.
|
||||
type TenantSecretsTable struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Data TenantSecretEntry `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// DeepCopy methods are generated by deepcopy-gen
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type TenantSecretsTableList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []TenantSecretsTable `json:"items"`
|
||||
}
|
||||
|
||||
// DeepCopy methods are generated by deepcopy-gen
|
||||
@@ -216,22 +216,6 @@ func (in *TenantSecret) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TenantSecretEntry) DeepCopyInto(out *TenantSecretEntry) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantSecretEntry.
|
||||
func (in *TenantSecretEntry) DeepCopy() *TenantSecretEntry {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TenantSecretEntry)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TenantSecretList) DeepCopyInto(out *TenantSecretList) {
|
||||
*out = *in
|
||||
@@ -264,63 +248,3 @@ func (in *TenantSecretList) DeepCopyObject() runtime.Object {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TenantSecretsTable) DeepCopyInto(out *TenantSecretsTable) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Data = in.Data
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantSecretsTable.
|
||||
func (in *TenantSecretsTable) DeepCopy() *TenantSecretsTable {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TenantSecretsTable)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *TenantSecretsTable) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TenantSecretsTableList) DeepCopyInto(out *TenantSecretsTableList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]TenantSecretsTable, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantSecretsTableList.
|
||||
func (in *TenantSecretsTableList) DeepCopy() *TenantSecretsTableList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TenantSecretsTableList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *TenantSecretsTableList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,26 +30,28 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
genericapiserver "k8s.io/apiserver/pkg/server"
|
||||
"k8s.io/klog/v2"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/cache"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
|
||||
"github.com/cozystack/cozystack/pkg/apis/apps"
|
||||
appsinstall "github.com/cozystack/cozystack/pkg/apis/apps/install"
|
||||
coreinstall "github.com/cozystack/cozystack/pkg/apis/apps/install"
|
||||
"github.com/cozystack/cozystack/pkg/apis/core"
|
||||
coreinstall "github.com/cozystack/cozystack/pkg/apis/core/install"
|
||||
"github.com/cozystack/cozystack/pkg/config"
|
||||
cozyregistry "github.com/cozystack/cozystack/pkg/registry"
|
||||
applicationstorage "github.com/cozystack/cozystack/pkg/registry/apps/application"
|
||||
tenantmodulestorage "github.com/cozystack/cozystack/pkg/registry/core/tenantmodule"
|
||||
tenantnamespacestorage "github.com/cozystack/cozystack/pkg/registry/core/tenantnamespace"
|
||||
tenantsecretstorage "github.com/cozystack/cozystack/pkg/registry/core/tenantsecret"
|
||||
tenantsecretstablestorage "github.com/cozystack/cozystack/pkg/registry/core/tenantsecretstable"
|
||||
)
|
||||
|
||||
var (
|
||||
// Scheme defines methods for serializing and deserializing API objects.
|
||||
Scheme = runtime.NewScheme()
|
||||
Scheme = runtime.NewScheme()
|
||||
mgrScheme = runtime.NewScheme()
|
||||
// Codecs provides methods for retrieving codecs and serializers for specific
|
||||
// versions and content types.
|
||||
Codecs = serializer.NewCodecFactory(Scheme)
|
||||
@@ -58,18 +60,23 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&zap.Options{
|
||||
Development: true,
|
||||
// any other zap.Options tweaks
|
||||
})))
|
||||
klog.SetLogger(ctrl.Log.WithName("klog"))
|
||||
appsinstall.Install(Scheme)
|
||||
coreinstall.Install(Scheme)
|
||||
|
||||
// Register HelmRelease types.
|
||||
if err := helmv2.AddToScheme(Scheme); err != nil {
|
||||
if err := helmv2.AddToScheme(mgrScheme); err != nil {
|
||||
panic(fmt.Errorf("Failed to add HelmRelease types to scheme: %w", err))
|
||||
}
|
||||
|
||||
if err := corev1.AddToScheme(Scheme); err != nil {
|
||||
if err := corev1.AddToScheme(mgrScheme); err != nil {
|
||||
panic(fmt.Errorf("Failed to add core types to scheme: %w", err))
|
||||
}
|
||||
if err := rbacv1.AddToScheme(Scheme); err != nil {
|
||||
if err := rbacv1.AddToScheme(mgrScheme); err != nil {
|
||||
panic(fmt.Errorf("Failed to add RBAC types to scheme: %w", err))
|
||||
}
|
||||
// Add unversioned types.
|
||||
@@ -135,7 +142,7 @@ func (c completedConfig) New() (*CozyServer, error) {
|
||||
}
|
||||
|
||||
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
|
||||
Scheme: Scheme,
|
||||
Scheme: mgrScheme,
|
||||
Cache: cache.Options{SyncPeriod: &syncPeriod},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -165,7 +172,7 @@ func (c completedConfig) New() (*CozyServer, error) {
|
||||
}
|
||||
|
||||
cli := mgr.GetClient()
|
||||
watchCli, err := client.NewWithWatch(cfg, client.Options{Scheme: Scheme})
|
||||
watchCli, err := client.NewWithWatch(cfg, client.Options{Scheme: mgrScheme})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to build watch client: %w", err)
|
||||
}
|
||||
@@ -177,9 +184,6 @@ func (c completedConfig) New() (*CozyServer, error) {
|
||||
coreV1alpha1Storage["tenantsecrets"] = cozyregistry.RESTInPeace(
|
||||
tenantsecretstorage.NewREST(cli, watchCli),
|
||||
)
|
||||
coreV1alpha1Storage["tenantsecretstables"] = cozyregistry.RESTInPeace(
|
||||
tenantsecretstablestorage.NewREST(cli, watchCli),
|
||||
)
|
||||
coreV1alpha1Storage["tenantmodules"] = cozyregistry.RESTInPeace(
|
||||
tenantmodulestorage.NewREST(cli, watchCli),
|
||||
)
|
||||
|
||||
@@ -42,11 +42,11 @@ import (
|
||||
genericoptions "k8s.io/apiserver/pkg/server/options"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
utilversionpkg "k8s.io/apiserver/pkg/util/version"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/component-base/featuregate"
|
||||
baseversion "k8s.io/component-base/version"
|
||||
netutils "k8s.io/utils/net"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
|
||||
)
|
||||
|
||||
// CozyServerOptions holds the state for the Cozy API server
|
||||
@@ -150,7 +150,7 @@ func (o *CozyServerOptions) Complete() error {
|
||||
return fmt.Errorf("failed to register types: %w", err)
|
||||
}
|
||||
|
||||
cfg, err := clientcmd.BuildConfigFromFlags("", "")
|
||||
cfg, err := k8sconfig.GetConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get kubeconfig: %w", err)
|
||||
}
|
||||
|
||||
@@ -39,10 +39,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantNamespace": schema_pkg_apis_core_v1alpha1_TenantNamespace(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantNamespaceList": schema_pkg_apis_core_v1alpha1_TenantNamespaceList(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecret": schema_pkg_apis_core_v1alpha1_TenantSecret(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretEntry": schema_pkg_apis_core_v1alpha1_TenantSecretEntry(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretList": schema_pkg_apis_core_v1alpha1_TenantSecretList(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretsTable": schema_pkg_apis_core_v1alpha1_TenantSecretsTable(ref),
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretsTableList": schema_pkg_apis_core_v1alpha1_TenantSecretsTableList(ref),
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1.ConversionRequest": schema_pkg_apis_apiextensions_v1_ConversionRequest(ref),
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1.ConversionResponse": schema_pkg_apis_apiextensions_v1_ConversionResponse(ref),
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1.ConversionReview": schema_pkg_apis_apiextensions_v1_ConversionReview(ref),
|
||||
@@ -557,37 +554,6 @@ func schema_pkg_apis_core_v1alpha1_TenantSecret(ref common.ReferenceCallback) co
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_core_v1alpha1_TenantSecretEntry(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "TenantSecretEntry represents a single key from a Secret's data.",
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"name": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"key": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"value": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_core_v1alpha1_TenantSecretList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
@@ -636,95 +602,6 @@ func schema_pkg_apis_core_v1alpha1_TenantSecretList(ref common.ReferenceCallback
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_core_v1alpha1_TenantSecretsTable(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "TenantSecretsTable is a virtual, namespaced resource that exposes every key of Secrets labelled cozystack.io/ui=true as a separate object.",
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
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{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"apiVersion": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
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{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
|
||||
},
|
||||
},
|
||||
"data": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretEntry"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretEntry", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_core_v1alpha1_TenantSecretsTableList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
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{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"apiVersion": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
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{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
|
||||
},
|
||||
},
|
||||
"items": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretsTable"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"items"},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/cozystack/cozystack/pkg/apis/core/v1alpha1.TenantSecretsTable", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_apiextensions_v1_ConversionRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
|
||||
@@ -142,9 +142,17 @@ func (r *REST) GetSingularName() string {
|
||||
// Create handles the creation of a new Application by converting it to a HelmRelease
|
||||
func (r *REST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||
// Assert the object is of type Application
|
||||
app, ok := obj.(*appsv1alpha1.Application)
|
||||
us, ok := obj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("expected Application object, got %T", obj)
|
||||
return nil, fmt.Errorf("expected unstructured.Unstructured object, got %T", obj)
|
||||
}
|
||||
|
||||
app := &appsv1alpha1.Application{}
|
||||
|
||||
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(us.Object, app); err != nil {
|
||||
errMsg := fmt.Sprintf("returned unstructured.Unstructured object was not an Application")
|
||||
klog.Errorf(errMsg)
|
||||
return nil, fmt.Errorf(errMsg)
|
||||
}
|
||||
|
||||
// Convert Application to HelmRelease
|
||||
@@ -389,11 +397,9 @@ func (r *REST) List(ctx context.Context, options *metainternalversion.ListOption
|
||||
}
|
||||
|
||||
// Explicitly set apiVersion and kind in unstructured object
|
||||
appList := &unstructured.UnstructuredList{}
|
||||
appList.SetAPIVersion("apps.cozystack.io/v1alpha1")
|
||||
appList.SetKind(r.kindName + "List")
|
||||
appList := r.NewList().(*unstructured.Unstructured)
|
||||
appList.SetResourceVersion(hrList.GetResourceVersion())
|
||||
appList.Items = items
|
||||
appList.Object["items"] = items
|
||||
|
||||
klog.V(6).Infof("Successfully listed %d Application resources in namespace %s", len(items), namespace)
|
||||
return appList, nil
|
||||
@@ -441,9 +447,16 @@ func (r *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObje
|
||||
}
|
||||
|
||||
// Assert the new object is of type Application
|
||||
app, ok := newObj.(*appsv1alpha1.Application)
|
||||
us, ok := newObj.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
errMsg := fmt.Sprintf("expected Application object, got %T", newObj)
|
||||
errMsg := fmt.Sprintf("expected unstructured.Unstructured object, got %T", newObj)
|
||||
klog.Errorf(errMsg)
|
||||
return nil, false, fmt.Errorf(errMsg)
|
||||
}
|
||||
app := &appsv1alpha1.Application{}
|
||||
|
||||
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(us.Object, app); err != nil {
|
||||
errMsg := fmt.Sprintf("returned unstructured.Unstructured object was not an Application")
|
||||
klog.Errorf(errMsg)
|
||||
return nil, false, fmt.Errorf(errMsg)
|
||||
}
|
||||
@@ -516,14 +529,12 @@ func (r *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObje
|
||||
klog.Errorf("Failed to convert Application to unstructured for resource %s: %v", convertedApp.GetName(), err)
|
||||
return nil, false, fmt.Errorf("failed to convert Application to unstructured: %v", err)
|
||||
}
|
||||
|
||||
// Explicitly set apiVersion and kind in unstructured object
|
||||
unstructuredApp["apiVersion"] = "apps.cozystack.io/v1alpha1"
|
||||
unstructuredApp["kind"] = r.kindName
|
||||
obj := &unstructured.Unstructured{Object: unstructuredApp}
|
||||
obj.SetGroupVersionKind(r.gvk)
|
||||
|
||||
klog.V(6).Infof("Returning patched Application object: %+v", unstructuredApp)
|
||||
|
||||
return &unstructured.Unstructured{Object: unstructuredApp}, false, nil
|
||||
return obj, false, nil
|
||||
}
|
||||
|
||||
// Delete removes an Application by deleting the corresponding HelmRelease
|
||||
@@ -723,11 +734,13 @@ func (r *REST) Watch(ctx context.Context, options *metainternalversion.ListOptio
|
||||
klog.Errorf("Failed to convert Application to unstructured: %v", err)
|
||||
continue
|
||||
}
|
||||
obj := &unstructured.Unstructured{Object: unstructuredApp}
|
||||
obj.SetGroupVersionKind(r.gvk)
|
||||
|
||||
// Create watch event with Application object
|
||||
appEvent := watch.Event{
|
||||
Type: event.Type,
|
||||
Object: &unstructured.Unstructured{Object: unstructuredApp},
|
||||
Object: obj,
|
||||
}
|
||||
|
||||
// Send event to custom watcher
|
||||
@@ -1060,6 +1073,34 @@ func (r *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableO
|
||||
table = r.buildTableFromApplications(apps)
|
||||
table.ListMeta.ResourceVersion = obj.GetResourceVersion()
|
||||
case *unstructured.Unstructured:
|
||||
var apps []appsv1alpha1.Application
|
||||
for {
|
||||
var items interface{}
|
||||
var ok bool
|
||||
var objects []unstructured.Unstructured
|
||||
if items, ok = obj.Object["items"]; !ok {
|
||||
break
|
||||
}
|
||||
if objects, ok = items.([]unstructured.Unstructured); !ok {
|
||||
break
|
||||
}
|
||||
apps = make([]appsv1alpha1.Application, 0, len(objects))
|
||||
var a appsv1alpha1.Application
|
||||
for i := range objects {
|
||||
err := runtime.DefaultUnstructuredConverter.FromUnstructured(objects[i].Object, &a)
|
||||
if err != nil {
|
||||
klog.Errorf("Failed to convert Unstructured to Application: %v", err)
|
||||
continue
|
||||
}
|
||||
apps = append(apps, a)
|
||||
}
|
||||
break
|
||||
}
|
||||
if apps != nil {
|
||||
table = r.buildTableFromApplications(apps)
|
||||
table.ListMeta.ResourceVersion = obj.GetResourceVersion()
|
||||
break
|
||||
}
|
||||
var app appsv1alpha1.Application
|
||||
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), &app)
|
||||
if err != nil {
|
||||
@@ -1196,12 +1237,17 @@ func (r *REST) Destroy() {
|
||||
|
||||
// New creates a new instance of Application
|
||||
func (r *REST) New() runtime.Object {
|
||||
return &appsv1alpha1.Application{}
|
||||
obj := &unstructured.Unstructured{}
|
||||
obj.SetGroupVersionKind(r.gvk)
|
||||
return obj
|
||||
}
|
||||
|
||||
// NewList returns an empty list of Application objects
|
||||
func (r *REST) NewList() runtime.Object {
|
||||
return &appsv1alpha1.ApplicationList{}
|
||||
obj := &unstructured.Unstructured{}
|
||||
obj.SetGroupVersionKind(r.gvk.GroupVersion().WithKind(r.kindName + "List"))
|
||||
obj.Object["items"] = make([]interface{}, 0)
|
||||
return obj
|
||||
}
|
||||
|
||||
// Kind returns the resource kind used for API discovery
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -226,6 +226,9 @@ func (r *REST) Get(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if sec.Labels == nil || sec.Labels[tsLabelKey] != tsLabelValue {
|
||||
return nil, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
return secretToTenant(sec), nil
|
||||
}
|
||||
|
||||
@@ -253,11 +256,13 @@ func (r *REST) List(ctx context.Context, opts *metainternal.ListOptions) (runtim
|
||||
list := &corev1.SecretList{}
|
||||
err = r.c.List(ctx, list,
|
||||
&client.ListOptions{
|
||||
Namespace: ns,
|
||||
Namespace: ns,
|
||||
LabelSelector: ls,
|
||||
Raw: &metav1.ListOptions{
|
||||
LabelSelector: ls.String(),
|
||||
FieldSelector: fieldSel,
|
||||
}})
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -273,7 +278,17 @@ func (r *REST) List(ctx context.Context, opts *metainternal.ListOptions) (runtim
|
||||
for i := range list.Items {
|
||||
out.Items = append(out.Items, *secretToTenant(&list.Items[i]))
|
||||
}
|
||||
sort.Slice(out.Items, func(i, j int) bool { return out.Items[i].Name < out.Items[j].Name })
|
||||
slices.SortFunc(out.Items, func(a, b corev1alpha1.TenantSecret) int {
|
||||
aKey := fmt.Sprintf("%s/%s", a.Namespace, a.Name)
|
||||
bKey := fmt.Sprintf("%s/%s", b.Namespace, b.Name)
|
||||
switch {
|
||||
case aKey < bKey:
|
||||
return -1
|
||||
case aKey > bKey:
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@@ -291,10 +306,17 @@ func (r *REST) Update(
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
cur := &corev1.Secret{}
|
||||
err = r.c.Get(ctx, types.NamespacedName{Namespace: ns, Name: name}, cur, &client.GetOptions{Raw: &metav1.GetOptions{}})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return nil, false, err
|
||||
var cur *corev1.Secret
|
||||
previous := &corev1.Secret{}
|
||||
if err := r.c.Get(ctx, types.NamespacedName{Namespace: ns, Name: name}, previous, &client.GetOptions{Raw: &metav1.GetOptions{}}); err != nil {
|
||||
if !apierrors.IsNotFound(err) {
|
||||
return nil, false, err
|
||||
}
|
||||
} else {
|
||||
if previous.Labels == nil || previous.Labels[tsLabelKey] != tsLabelValue {
|
||||
return nil, false, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
cur = previous
|
||||
}
|
||||
|
||||
newObj, err := objInfo.UpdatedObject(ctx, nil)
|
||||
@@ -306,7 +328,7 @@ func (r *REST) Update(
|
||||
newSec := tenantToSecret(in, cur)
|
||||
newSec.Namespace = ns
|
||||
if cur == nil {
|
||||
if !forceCreate && err == nil {
|
||||
if !forceCreate {
|
||||
return nil, false, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
err := r.c.Create(ctx, newSec, &client.CreateOptions{Raw: &metav1.CreateOptions{}})
|
||||
@@ -328,6 +350,13 @@ func (r *REST) Delete(
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
current := &corev1.Secret{}
|
||||
if err := r.c.Get(ctx, types.NamespacedName{Namespace: ns, Name: name}, current, &client.GetOptions{Raw: &metav1.GetOptions{}}); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if current.Labels == nil || current.Labels[tsLabelKey] != tsLabelValue {
|
||||
return nil, false, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
err = r.c.Delete(ctx, &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Namespace: ns, Name: name}}, &client.DeleteOptions{Raw: opts})
|
||||
return nil, err == nil, err
|
||||
}
|
||||
@@ -347,6 +376,13 @@ func (r *REST) Patch(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
current := &corev1.Secret{}
|
||||
if err := r.c.Get(ctx, types.NamespacedName{Namespace: ns, Name: name}, current, &client.GetOptions{Raw: &metav1.GetOptions{}}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if current.Labels == nil || current.Labels[tsLabelKey] != tsLabelValue {
|
||||
return nil, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
out := &corev1.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: ns,
|
||||
@@ -383,12 +419,16 @@ func (r *REST) Watch(ctx context.Context, opts *metainternal.ListOptions) (watch
|
||||
}
|
||||
|
||||
secList := &corev1.SecretList{}
|
||||
ls := labels.Set{tsLabelKey: tsLabelValue}.AsSelector().String()
|
||||
base, err := r.w.Watch(ctx, secList, &client.ListOptions{Namespace: ns, Raw: &metav1.ListOptions{
|
||||
Watch: true,
|
||||
LabelSelector: ls,
|
||||
ResourceVersion: opts.ResourceVersion,
|
||||
}})
|
||||
ls := labels.Set{tsLabelKey: tsLabelValue}.AsSelector()
|
||||
base, err := r.w.Watch(ctx, secList, &client.ListOptions{
|
||||
Namespace: ns,
|
||||
LabelSelector: ls,
|
||||
Raw: &metav1.ListOptions{
|
||||
Watch: true,
|
||||
LabelSelector: ls.String(),
|
||||
ResourceVersion: opts.ResourceVersion,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,335 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// TenantSecretsTable registry – namespaced, read-only flattened view over
|
||||
// Secrets labelled "internal.cozystack.io/tenantresource=true". Each data key is a separate object.
|
||||
|
||||
package tenantsecretstable
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/selection"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
corev1alpha1 "github.com/cozystack/cozystack/pkg/apis/core/v1alpha1"
|
||||
)
|
||||
|
||||
const (
|
||||
tsLabelKey = corev1alpha1.TenantResourceLabelKey
|
||||
tsLabelValue = corev1alpha1.TenantResourceLabelValue
|
||||
kindObj = "TenantSecretsTable"
|
||||
kindObjList = "TenantSecretsTableList"
|
||||
singularName = "tenantsecretstable"
|
||||
resourcePlural = "tenantsecretstables"
|
||||
)
|
||||
|
||||
type REST struct {
|
||||
c client.Client
|
||||
w client.WithWatch
|
||||
gvr schema.GroupVersionResource
|
||||
}
|
||||
|
||||
func NewREST(c client.Client, w client.WithWatch) *REST {
|
||||
return &REST{
|
||||
c: c,
|
||||
w: w,
|
||||
gvr: schema.GroupVersionResource{
|
||||
Group: corev1alpha1.GroupName,
|
||||
Version: "v1alpha1",
|
||||
Resource: resourcePlural,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
_ rest.Getter = &REST{}
|
||||
_ rest.Lister = &REST{}
|
||||
_ rest.Watcher = &REST{}
|
||||
_ rest.TableConvertor = &REST{}
|
||||
_ rest.Scoper = &REST{}
|
||||
_ rest.SingularNameProvider = &REST{}
|
||||
_ rest.Storage = &REST{}
|
||||
)
|
||||
|
||||
func (*REST) NamespaceScoped() bool { return true }
|
||||
func (*REST) New() runtime.Object { return &corev1alpha1.TenantSecretsTable{} }
|
||||
func (*REST) NewList() runtime.Object {
|
||||
return &corev1alpha1.TenantSecretsTableList{}
|
||||
}
|
||||
func (*REST) Kind() string { return kindObj }
|
||||
func (r *REST) GroupVersionKind(_ schema.GroupVersion) schema.GroupVersionKind {
|
||||
return r.gvr.GroupVersion().WithKind(kindObj)
|
||||
}
|
||||
func (*REST) GetSingularName() string { return singularName }
|
||||
func (*REST) Destroy() {}
|
||||
|
||||
func nsFrom(ctx context.Context) (string, error) {
|
||||
ns, ok := request.NamespaceFrom(ctx)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("namespace required")
|
||||
}
|
||||
return ns, nil
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Get/List
|
||||
// -----------------------
|
||||
|
||||
func (r *REST) Get(ctx context.Context, name string, opts *metav1.GetOptions) (runtime.Object, error) {
|
||||
ns, err := nsFrom(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// We need to identify secret name and key. Iterate secrets in namespace with tenant secret label
|
||||
// and return the matching composed object.
|
||||
list := &corev1.SecretList{}
|
||||
err = r.c.List(ctx, list,
|
||||
&client.ListOptions{
|
||||
Namespace: ns,
|
||||
Raw: &metav1.ListOptions{
|
||||
LabelSelector: labels.Set{tsLabelKey: tsLabelValue}.AsSelector().String(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range list.Items {
|
||||
sec := &list.Items[i]
|
||||
for k, v := range sec.Data {
|
||||
composed := composedName(sec.Name, k)
|
||||
if composed == name {
|
||||
return secretKeyToObj(sec, k, v), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, apierrors.NewNotFound(r.gvr.GroupResource(), name)
|
||||
}
|
||||
|
||||
func (r *REST) List(ctx context.Context, opts *metainternal.ListOptions) (runtime.Object, error) {
|
||||
ns, err := nsFrom(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sel := labels.NewSelector()
|
||||
req, _ := labels.NewRequirement(tsLabelKey, selection.Equals, []string{tsLabelValue})
|
||||
sel = sel.Add(*req)
|
||||
if opts.LabelSelector != nil {
|
||||
if reqs, _ := opts.LabelSelector.Requirements(); len(reqs) > 0 {
|
||||
sel = sel.Add(reqs...)
|
||||
}
|
||||
}
|
||||
fieldSel := ""
|
||||
if opts.FieldSelector != nil {
|
||||
fieldSel = opts.FieldSelector.String()
|
||||
}
|
||||
|
||||
list := &corev1.SecretList{}
|
||||
err = r.c.List(ctx, list,
|
||||
&client.ListOptions{
|
||||
Namespace: ns,
|
||||
Raw: &metav1.ListOptions{
|
||||
LabelSelector: labels.Set{tsLabelKey: tsLabelValue}.AsSelector().String(),
|
||||
FieldSelector: fieldSel,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := &corev1alpha1.TenantSecretsTableList{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: corev1alpha1.SchemeGroupVersion.String(), Kind: kindObjList},
|
||||
ListMeta: list.ListMeta,
|
||||
}
|
||||
|
||||
for i := range list.Items {
|
||||
sec := &list.Items[i]
|
||||
// Ensure stable ordering of keys
|
||||
keys := make([]string, 0, len(sec.Data))
|
||||
for k := range sec.Data {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
v := sec.Data[k]
|
||||
o := secretKeyToObj(sec, k, v)
|
||||
out.Items = append(out.Items, *o)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(out.Items, func(i, j int) bool { return out.Items[i].Name < out.Items[j].Name })
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Watch
|
||||
// -----------------------
|
||||
|
||||
func (r *REST) Watch(ctx context.Context, opts *metainternal.ListOptions) (watch.Interface, error) {
|
||||
ns, err := nsFrom(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
secList := &corev1.SecretList{}
|
||||
ls := labels.Set{tsLabelKey: tsLabelValue}.AsSelector().String()
|
||||
base, err := r.w.Watch(ctx, secList, &client.ListOptions{Namespace: ns, Raw: &metav1.ListOptions{
|
||||
Watch: true,
|
||||
LabelSelector: ls,
|
||||
ResourceVersion: opts.ResourceVersion,
|
||||
}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ch := make(chan watch.Event)
|
||||
proxy := watch.NewProxyWatcher(ch)
|
||||
|
||||
go func() {
|
||||
defer proxy.Stop()
|
||||
for ev := range base.ResultChan() {
|
||||
sec, ok := ev.Object.(*corev1.Secret)
|
||||
if !ok || sec == nil {
|
||||
continue
|
||||
}
|
||||
// Emit an event per key
|
||||
for k, v := range sec.Data {
|
||||
obj := secretKeyToObj(sec, k, v)
|
||||
ch <- watch.Event{Type: ev.Type, Object: obj}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return proxy, nil
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// TableConvertor
|
||||
// -----------------------
|
||||
|
||||
func (r *REST) ConvertToTable(_ context.Context, obj runtime.Object, _ runtime.Object) (*metav1.Table, error) {
|
||||
now := time.Now()
|
||||
row := func(o *corev1alpha1.TenantSecretsTable) metav1.TableRow {
|
||||
return metav1.TableRow{
|
||||
Cells: []interface{}{o.Name, o.Data.Name, o.Data.Key, humanAge(o.CreationTimestamp.Time, now)},
|
||||
Object: runtime.RawExtension{Object: o},
|
||||
}
|
||||
}
|
||||
tbl := &metav1.Table{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: "meta.k8s.io/v1", Kind: "Table"},
|
||||
ColumnDefinitions: []metav1.TableColumnDefinition{
|
||||
{Name: "NAME", Type: "string"},
|
||||
{Name: "SECRET", Type: "string"},
|
||||
{Name: "KEY", Type: "string"},
|
||||
{Name: "AGE", Type: "string"},
|
||||
},
|
||||
}
|
||||
switch v := obj.(type) {
|
||||
case *corev1alpha1.TenantSecretsTableList:
|
||||
for i := range v.Items {
|
||||
tbl.Rows = append(tbl.Rows, row(&v.Items[i]))
|
||||
}
|
||||
tbl.ListMeta.ResourceVersion = v.ListMeta.ResourceVersion
|
||||
case *corev1alpha1.TenantSecretsTable:
|
||||
tbl.Rows = append(tbl.Rows, row(v))
|
||||
tbl.ListMeta.ResourceVersion = v.ResourceVersion
|
||||
default:
|
||||
return nil, notAcceptable{r.gvr.GroupResource(), fmt.Sprintf("unexpected %T", obj)}
|
||||
}
|
||||
return tbl, nil
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
// Helpers
|
||||
// -----------------------
|
||||
|
||||
func composedName(secretName, key string) string {
|
||||
return secretName + "-" + key
|
||||
}
|
||||
|
||||
func humanAge(t time.Time, now time.Time) string {
|
||||
d := now.Sub(t)
|
||||
// simple human duration
|
||||
if d.Hours() >= 24 {
|
||||
return fmt.Sprintf("%dd", int(d.Hours()/24))
|
||||
}
|
||||
if d.Hours() >= 1 {
|
||||
return fmt.Sprintf("%dh", int(d.Hours()))
|
||||
}
|
||||
if d.Minutes() >= 1 {
|
||||
return fmt.Sprintf("%dm", int(d.Minutes()))
|
||||
}
|
||||
return fmt.Sprintf("%ds", int(d.Seconds()))
|
||||
}
|
||||
|
||||
func secretKeyToObj(sec *corev1.Secret, key string, val []byte) *corev1alpha1.TenantSecretsTable {
|
||||
return &corev1alpha1.TenantSecretsTable{
|
||||
TypeMeta: metav1.TypeMeta{APIVersion: corev1alpha1.SchemeGroupVersion.String(), Kind: kindObj},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: sec.Name,
|
||||
Namespace: sec.Namespace,
|
||||
UID: sec.UID,
|
||||
ResourceVersion: sec.ResourceVersion,
|
||||
CreationTimestamp: sec.CreationTimestamp,
|
||||
Labels: filterUserLabels(sec.Labels),
|
||||
Annotations: sec.Annotations,
|
||||
},
|
||||
Data: corev1alpha1.TenantSecretEntry{
|
||||
Name: sec.Name,
|
||||
Key: key,
|
||||
Value: toBase64String(val),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func filterUserLabels(m map[string]string) map[string]string {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
out := make(map[string]string, len(m))
|
||||
for k, v := range m {
|
||||
if k == tsLabelKey {
|
||||
continue
|
||||
}
|
||||
out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func toBase64String(b []byte) string {
|
||||
const enc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
// Minimal base64 encoder to avoid extra deps; for readability we could use stdlib encoding/base64
|
||||
// but keeping inline is fine; however using stdlib is clearer.
|
||||
// Using stdlib:
|
||||
return base64.StdEncoding.EncodeToString(b)
|
||||
}
|
||||
|
||||
type notAcceptable struct {
|
||||
resource schema.GroupResource
|
||||
message string
|
||||
}
|
||||
|
||||
func (e notAcceptable) Error() string { return e.message }
|
||||
func (e notAcceptable) Status() metav1.Status {
|
||||
return metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusNotAcceptable,
|
||||
Reason: metav1.StatusReason("NotAcceptable"),
|
||||
Message: e.message,
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,24 @@ sleep 5
|
||||
cozypkg -n cozy-system -C packages/system/cozystack-resource-definition-crd apply cozystack-resource-definition-crd --plain
|
||||
cozypkg -n cozy-system -C packages/system/cozystack-resource-definitions apply cozystack-resource-definitions --plain
|
||||
cozypkg -n cozy-system -C packages/system/cozystack-api apply cozystack-api --plain
|
||||
if kubectl get ds cozystack-api -n cozy-system >/dev/null 2>&1; then
|
||||
echo "Waiting for cozystack-api daemonset"
|
||||
kubectl rollout status ds/cozystack-api -n cozy-system --timeout=5m || exit 1
|
||||
else
|
||||
echo "Waiting for cozystack-api deployment"
|
||||
kubectl rollout status deploy/cozystack-api -n cozy-system --timeout=5m || exit 1
|
||||
fi
|
||||
|
||||
helm upgrade --install -n cozy-system cozystack-controller ./packages/system/cozystack-controller/ --take-ownership
|
||||
echo "Waiting for cozystack-controller"
|
||||
kubectl rollout status deploy/cozystack-controller -n cozy-system --timeout=5m || exit 1
|
||||
|
||||
helm upgrade --install -n cozy-system lineage-controller-webhook ./packages/system/lineage-controller-webhook/ --take-ownership
|
||||
echo "Waiting for lineage-webhook"
|
||||
kubectl rollout status ds/lineage-controller-webhook -n cozy-system --timeout=5m || exit 1
|
||||
|
||||
sleep 5
|
||||
echo "Running lineage-webhook test"
|
||||
kubectl delete ns cozy-lineage-webhook-test --ignore-not-found && kubectl create ns cozy-lineage-webhook-test
|
||||
cleanup_test_ns() {
|
||||
kubectl delete ns cozy-lineage-webhook-test --ignore-not-found
|
||||
@@ -37,9 +51,6 @@ trap cleanup_test_ns ERR
|
||||
timeout 60 sh -c 'until kubectl -n cozy-lineage-webhook-test create service clusterip lineage-webhook-test --clusterip="None" --dry-run=server; do sleep 1; done'
|
||||
cleanup_test_ns
|
||||
|
||||
kubectl wait deployment/cozystack-api -n cozy-system --timeout=4m --for=condition=available || exit 1
|
||||
kubectl wait deployment/cozystack-controller -n cozy-system --timeout=4m --for=condition=available || exit 1
|
||||
|
||||
timestamp=$(date --rfc-3339=ns || date)
|
||||
kubectl get namespace -o custom-columns=NAME:.metadata.name --no-headers |
|
||||
grep '^tenant-' |
|
||||
@@ -50,6 +61,7 @@ kubectl get namespace -o custom-columns=NAME:.metadata.name --no-headers |
|
||||
-n "$namespace" --all \
|
||||
migration.cozystack.io="$timestamp" --overwrite || true)
|
||||
done
|
||||
|
||||
# Stamp version
|
||||
kubectl create configmap -n cozy-system cozystack-version \
|
||||
--from-literal=version=21 --dry-run=client -o yaml | kubectl apply -f-
|
||||
|
||||
Reference in New Issue
Block a user