diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6e2579..4c48983 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,12 +72,93 @@ jobs: name: "L3 · E2E Kind" needs: [eval-http, csi-grpc] runs-on: ubuntu-latest - if: false # placeholder — enable when container images exist steps: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main + + # Build all OCI images in a single nix build (shared cargoArtifacts) + - name: Build images + run: nix build .#all-images -o result-images + + # Create kind cluster - uses: helm/kind-action@v1 with: cluster_name: niphas-test - - run: nix develop -c cargo nextest run --workspace --test 'e2e_*' + config: hack/kind-config.yaml + + # Load images into kind + - name: Load images into kind + run: | + kind load image-archive result-images/operator.tar.gz --name niphas-test + kind load image-archive result-images/eval.tar.gz --name niphas-test + kind load image-archive result-images/csi.tar.gz --name niphas-test + kind load image-archive result-images/runner.tar.gz --name niphas-test + kind load image-archive result-images/mock-eval.tar.gz --name niphas-test + + # Label nodes for CSI + - name: Label nodes + run: kubectl label nodes --all niphas.io/store=true + + # Verify CRD freshness + - name: Verify CRD freshness + run: | + nix develop -c cargo run --bin niphas-crd-gen 2>/dev/null | grep -v '^niphas devShell ready$' | diff charts/niphas/crds/niphasworkloads.yaml - + + # Install Helm chart + - name: Install niphas + run: | + nix develop -c helm install niphas charts/niphas \ + --namespace niphas-system \ + --create-namespace \ + --set operator.image.pullPolicy=Never \ + --set operator.image.tag=dev \ + --set eval.image.repository=ghcr.io/fullzer4/niphas-mock-eval \ + --set eval.image.pullPolicy=Never \ + --set eval.image.tag=dev \ + --set csi.image.pullPolicy=Never \ + --set csi.image.tag=dev \ + --set runner.image.tag=dev + + # Wait for rollout + - name: Wait for deployments + run: | + kubectl -n niphas-system rollout status deployment/niphas-operator --timeout=120s + kubectl -n niphas-system rollout status deployment/niphas-eval --timeout=120s + kubectl -n niphas-system rollout status daemonset/niphas-csi --timeout=120s + + # Debug on failure + - name: Debug pods on failure + if: failure() + run: | + echo "=== Pod status ===" + kubectl -n niphas-system get pods -o wide + echo "=== Pod descriptions ===" + kubectl -n niphas-system describe pods + echo "=== CSI logs ===" + kubectl -n niphas-system logs -l app.kubernetes.io/name=niphas-csi --all-containers --tail=50 || true + echo "=== Operator logs ===" + kubectl -n niphas-system logs -l app.kubernetes.io/name=niphas-operator --tail=50 || true + echo "=== Eval logs ===" + kubectl -n niphas-system logs -l app.kubernetes.io/name=niphas-eval --tail=50 || true + echo "=== Events ===" + kubectl -n niphas-system get events --sort-by=.lastTimestamp + + # Create e2e namespace + - name: Create e2e namespace + run: kubectl create namespace niphas-e2e + + # Port-forward + - name: Port-forward services + run: | + kubectl -n niphas-system port-forward svc/niphas-eval 8443:8443 & + kubectl -n niphas-system port-forward deployment/niphas-operator 8080:8080 & + sleep 5 + + # Run e2e tests + - name: Run E2E tests + env: + OPERATOR_HEALTH_URL: http://localhost:8080/healthz + EVAL_HEALTH_URL: http://localhost:8443/healthz + E2E_NAMESPACE: niphas-e2e + run: nix develop -c cargo nextest run -p niphas-e2e --test '*' diff --git a/.gitignore b/.gitignore index 8f1517b..6fa57d0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ result-* *.swp *.swo *~ +docs/book/ diff --git a/Cargo.lock b/Cargo.lock index 3f5c2bf..5280fc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1560,6 +1560,22 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "niphas-e2e" +version = "0.1.0" +dependencies = [ + "anyhow", + "axum", + "k8s-openapi", + "kube", + "niphas-core", + "reqwest", + "serde", + "serde_json", + "tokio", + "tracing", +] + [[package]] name = "niphas-eval" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 4eee40a..ab53383 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "crates/niphas-operator", "crates/niphas-csi", "crates/niphas-mesh", + "crates/niphas-e2e", ] [workspace.package] diff --git a/charts/niphas/Chart.yaml b/charts/niphas/Chart.yaml new file mode 100644 index 0000000..c2bd957 --- /dev/null +++ b/charts/niphas/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: niphas +description: Nix-native platform for Kubernetes +version: 0.1.0 +appVersion: "0.1.0" +type: application +keywords: + - nix + - kubernetes + - operator + - csi +home: https://github.com/fullzer4/niphas +sources: + - https://github.com/fullzer4/niphas diff --git a/charts/niphas/crds/niphasworkloads.yaml b/charts/niphas/crds/niphasworkloads.yaml new file mode 100644 index 0000000..9521a7b --- /dev/null +++ b/charts/niphas/crds/niphasworkloads.yaml @@ -0,0 +1,2565 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: niphasworkloads.niphas.io +spec: + group: niphas.io + names: + categories: [] + kind: NiphasWorkload + plural: niphasworkloads + shortNames: + - nw + - niphas + singular: niphasworkload + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.flakeRef + name: Flake + type: string + - jsonPath: .status.phase + name: Phase + type: string + - jsonPath: .status.readyReplicas + name: Ready + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Auto-generated derived type for NiphasWorkloadSpec via `CustomResource` + properties: + spec: + properties: + affinity: + description: Pod affinity/anti-affinity rules. + nullable: true + properties: + nodeAffinity: + description: Describes node affinity scheduling rules for the pod. + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding "weight" to the sum if the node matches the corresponding matchExpressions; the node(s) with the highest sum are the most preferred. + items: + description: An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op). + properties: + preference: + description: A node selector term, associated with the corresponding weight. + properties: + matchExpressions: + description: A list of node selector requirements by node's labels. + items: + description: A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: The label key that the selector applies to. + type: string + operator: + description: Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements by node's fields. + items: + description: A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: The label key that the selector applies to. + type: string + operator: + description: Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + weight: + description: Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100. + format: int32 + type: integer + required: + - preference + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system may or may not try to eventually evict the pod from its node. + properties: + nodeSelectorTerms: + description: Required. A list of node selector terms. The terms are ORed. + items: + description: A null or empty node selector term matches no objects. The requirements of them are ANDed. The TopologySelectorTerm type implements a subset of the NodeSelectorTerm. + properties: + matchExpressions: + description: A list of node selector requirements by node's labels. + items: + description: A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: The label key that the selector applies to. + type: string + operator: + description: Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements by node's fields. + items: + description: A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: The label key that the selector applies to. + type: string + operator: + description: Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: An array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. If the operator is Gt or Lt, the values array must have a single element, which will be interpreted as an integer. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + type: array + required: + - nodeSelectorTerms + type: object + type: object + podAffinity: + description: Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred. + items: + description: The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + mismatchLabelKeys: + description: MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key notin (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + namespaces: + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + weight: + description: weight associated with matching the corresponding podAffinityTerm, in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied. + items: + description: Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key matches that of any node on which a pod of the set of pods is running + properties: + labelSelector: + description: A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + mismatchLabelKeys: + description: MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key notin (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + namespaces: + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + type: array + type: object + podAntiAffinity: + description: Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: The scheduler will prefer to schedule pods to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and subtracting "weight" from the sum if the node has pods which matches the corresponding podAffinityTerm; the node(s) with the highest sum are the most preferred. + items: + description: The weights of all of the matched WeightedPodAffinityTerm fields are added per-node to find the most preferred node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + mismatchLabelKeys: + description: MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key notin (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + namespaces: + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + weight: + description: weight associated with matching the corresponding podAffinityTerm, in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: If the anti-affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to a pod label update), the system may or may not try to eventually evict the pod from its node. When there are multiple elements, the lists of nodes corresponding to each podAffinityTerm are intersected, i.e. all terms must be satisfied. + items: + description: Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key matches that of any node on which a pod of the set of pods is running + properties: + labelSelector: + description: A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + matchLabelKeys: + description: MatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key in (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both matchLabelKeys and labelSelector. Also, matchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + mismatchLabelKeys: + description: MismatchLabelKeys is a set of pod label keys to select which pods will be taken into consideration. The keys are used to lookup values from the incoming pod labels, those key-value labels are merged with `labelSelector` as `key notin (value)` to select the group of existing pods which pods will be taken into consideration for the incoming pod's pod (anti) affinity. Keys that don't exist in the incoming pod labels will be ignored. The default value is empty. The same key is forbidden to exist in both mismatchLabelKeys and labelSelector. Also, mismatchLabelKeys cannot be set when labelSelector isn't set. + items: + type: string + type: array + namespaceSelector: + description: A label query over the set of namespaces that the term applies to. The term is applied to the union of the namespaces selected by this field and the ones listed in the namespaces field. null selector and null or empty namespaces list means "this pod's namespace". An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + namespaces: + description: namespaces specifies a static list of namespace names that the term applies to. The term is applied to the union of the namespaces listed in this field and the ones selected by namespaceSelector. null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + architectures: + description: If set, evaluate per-architecture. Uses `{arch}` template in `attribute`. + items: + type: string + nullable: true + type: array + args: + description: Arguments passed to the command. + items: + type: string + nullable: true + type: array + attribute: + description: Flake output attribute path. E.g. `packages.x86_64-linux.default`. + type: string + binaryCache: + description: Override binary cache URL for this workload. + nullable: true + type: string + command: + description: Override entrypoint. If omitted, resolved from `meta.mainProgram`. + items: + type: string + nullable: true + type: array + env: + description: Environment variables (same schema as K8s container.env). + items: + description: EnvVar represents an environment variable present in a Container. + properties: + name: + description: Name of the environment variable. May consist of any printable ASCII characters except '='. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded using the previously defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless of whether the variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + optional: + description: Specify whether the ConfigMap or its key must be defined + type: boolean + required: + - key + - name + type: object + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified API version. + type: string + required: + - fieldPath + type: object + fileKeyRef: + description: FileKeyRef selects a key of the env file. Requires the EnvFiles feature gate to be enabled. + properties: + key: + description: The key within the env file. An invalid key will prevent the pod from starting. The keys defined within a source may consist of any printable ASCII characters except '='. During Alpha stage of the EnvFiles feature gate, the key size is limited to 128 characters. + type: string + optional: + description: |- + Specify whether the file or its key must be defined. If the file or key does not exist, then the env var is not published. If optional is set to true and the specified key does not exist, the environment variable will not be set in the Pod's containers. + + If optional is set to false and the specified key does not exist, an error will be returned during Pod creation. + type: boolean + path: + description: The path within the volume from which to select the file. Must be relative and may not contain the '..' path or start with '..'. + type: string + volumeName: + description: The name of the volume mount containing the env file. + type: string + required: + - key + - path + - volumeName + type: object + resourceFieldRef: + description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, optional for env vars' + type: string + divisor: + description: Specifies the output format of the exposed resources, defaults to "1" + nullable: true + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the pod's namespace + properties: + key: + description: The key of the secret to select from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + optional: + description: Specify whether the Secret or its key must be defined + type: boolean + required: + - key + - name + type: object + type: object + required: + - name + type: object + nullable: true + type: array + extraVolumeMounts: + description: Mount points for extra volumes. + items: + description: VolumeMount describes a mounting of a Volume within a container. + properties: + mountPath: + description: Path within the container at which the volume should be mounted. Must not contain ':'. + type: string + mountPropagation: + description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. When RecursiveReadOnly is set to IfPossible or to Enabled, MountPropagation must be None or unspecified (which defaults to None). + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false. + type: boolean + recursiveReadOnly: + description: |- + RecursiveReadOnly specifies whether read-only mounts should be handled recursively. + + If ReadOnly is false, this field has no meaning and must be unspecified. + + If ReadOnly is true, and this field is set to Disabled, the mount is not made recursively read-only. If this field is set to IfPossible, the mount is made recursively read-only, if it is supported by the container runtime. If this field is set to Enabled, the mount is made recursively read-only if it is supported by the container runtime, otherwise the pod will not be started and an error will be generated to indicate the reason. + + If this field is set to IfPossible or Enabled, MountPropagation must be set to None (or be unspecified, which defaults to None). + + If this field is not specified, it is treated as an equivalent of Disabled. + type: string + subPath: + description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root). + type: string + subPathExpr: + description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive. + type: string + required: + - mountPath + - name + type: object + nullable: true + type: array + extraVolumes: + description: Additional K8s volumes (ConfigMaps, Secrets, etc.). + items: + description: Volume represents a named volume in a pod that may be accessed by any container in the pod. + properties: + awsElasticBlockStore: + description: 'awsElasticBlockStore represents an AWS Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. Deprecated: AWSElasticBlockStore is deprecated. All operations for the in-tree awsElasticBlockStore type are redirected to the ebs.csi.aws.com CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + properties: + fsType: + description: 'fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + type: string + partition: + description: 'partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as "1". Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty).' + format: int32 + type: integer + readOnly: + description: 'readOnly value true will force the readOnly setting in VolumeMounts. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + type: boolean + volumeID: + description: 'volumeID is unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore' + type: string + required: + - volumeID + type: object + azureDisk: + description: 'azureDisk represents an Azure Data Disk mount on the host and bind mount to the pod. Deprecated: AzureDisk is deprecated. All operations for the in-tree azureDisk type are redirected to the disk.csi.azure.com CSI driver.' + properties: + cachingMode: + description: 'cachingMode is the Host Caching mode: None, Read Only, Read Write.' + type: string + diskName: + description: diskName is the Name of the data disk in the blob storage + type: string + diskURI: + description: diskURI is the URI of data disk in the blob storage + type: string + fsType: + description: fsType is Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. + type: string + kind: + description: 'kind expected values are Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared' + type: string + readOnly: + description: readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. + type: boolean + required: + - diskName + - diskURI + type: object + azureFile: + description: 'azureFile represents an Azure File Service mount on the host and bind mount to the pod. Deprecated: AzureFile is deprecated. All operations for the in-tree azureFile type are redirected to the file.csi.azure.com CSI driver.' + properties: + readOnly: + description: readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretName: + description: secretName is the name of secret that contains Azure Storage Account Name and Key + type: string + shareName: + description: shareName is the azure share Name + type: string + required: + - secretName + - shareName + type: object + cephfs: + description: 'cephFS represents a Ceph FS mount on the host that shares a pod''s lifetime. Deprecated: CephFS is deprecated and the in-tree cephfs type is no longer supported.' + properties: + monitors: + description: 'monitors is Required: Monitors is a collection of Ceph monitors More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + items: + type: string + type: array + path: + description: 'path is Optional: Used as the mounted root, rather than the full Ceph tree, default is /' + type: string + readOnly: + description: 'readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: boolean + secretFile: + description: 'secretFile is Optional: SecretFile is the path to key ring for User, default is /etc/ceph/user.secret More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: string + secretRef: + description: 'secretRef is Optional: SecretRef is reference to the authentication secret for User, default is empty. More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + user: + description: 'user is optional: User is the rados user name, default is admin More info: https://examples.k8s.io/volumes/cephfs/README.md#how-to-use-it' + type: string + required: + - monitors + type: object + cinder: + description: 'cinder represents a cinder volume attached and mounted on kubelets host machine. Deprecated: Cinder is deprecated. All operations for the in-tree cinder type are redirected to the cinder.csi.openstack.org CSI driver. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + properties: + fsType: + description: 'fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + type: string + readOnly: + description: 'readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + type: boolean + secretRef: + description: 'secretRef is optional: points to a secret object containing parameters used to connect to OpenStack.' + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + volumeID: + description: 'volumeID used to identify the volume in cinder. More info: https://examples.k8s.io/mysql-cinder-pd/README.md' + type: string + required: + - volumeID + type: object + configMap: + description: configMap represents a configMap that should populate this volume + properties: + defaultMode: + description: 'defaultMode is optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + items: + description: items if unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + optional: + description: optional specify whether the ConfigMap or its keys must be defined + type: boolean + required: + - name + type: object + csi: + description: csi (Container Storage Interface) represents ephemeral storage that is handled by certain external CSI drivers. + properties: + driver: + description: driver is the name of the CSI driver that handles this volume. Consult with your admin for the correct name as registered in the cluster. + type: string + fsType: + description: fsType to mount. Ex. "ext4", "xfs", "ntfs". If not provided, the empty value is passed to the associated CSI driver which will determine the default filesystem to apply. + type: string + nodePublishSecretRef: + description: nodePublishSecretRef is a reference to the secret object containing sensitive information to pass to the CSI driver to complete the CSI NodePublishVolume and NodeUnpublishVolume calls. This field is optional, and may be empty if no secret is required. If the secret object contains more than one secret, all secret references are passed. + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + readOnly: + description: readOnly specifies a read-only configuration for the volume. Defaults to false (read/write). + type: boolean + volumeAttributes: + additionalProperties: + type: string + description: volumeAttributes stores driver-specific properties that are passed to the CSI driver. Consult your driver's documentation for supported values. + type: object + required: + - driver + type: object + downwardAPI: + description: downwardAPI represents downward API about the pod that should populate this volume + properties: + defaultMode: + description: 'Optional: mode bits to use on created files by default. Must be a Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + items: + description: Items is a list of downward API volume file + items: + description: DownwardAPIVolumeFile represents information to create the file containing the pod field + properties: + fieldRef: + description: 'Required: Selects a field of the pod: only annotations, labels, name, namespace and uid are supported.' + properties: + apiVersion: + description: Version of the schema the FieldPath is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified API version. + type: string + required: + - fieldPath + type: object + mode: + description: 'Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: 'Required: Path is the relative path name of the file to be created. Must not be absolute or contain the ''..'' path. Must be utf-8 encoded. The first item of the relative path must not start with ''..''' + type: string + resourceFieldRef: + description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, optional for env vars' + type: string + divisor: + description: Specifies the output format of the exposed resources, defaults to "1" + nullable: true + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + required: + - path + type: object + type: array + type: object + emptyDir: + description: 'emptyDir represents a temporary directory that shares a pod''s lifetime. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' + properties: + medium: + description: 'medium represents what type of storage medium should back this directory. The default is "" which means to use the node''s default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' + type: string + sizeLimit: + description: 'sizeLimit is the total amount of local storage required for this EmptyDir volume. The size limit is also applicable for memory medium. The maximum usage on memory medium EmptyDir would be the minimum value between the SizeLimit specified here and the sum of memory limits of all containers in a pod. The default is nil which means that the limit is undefined. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir' + nullable: true + x-kubernetes-int-or-string: true + type: object + ephemeral: + description: |- + ephemeral represents a volume that is handled by a cluster storage driver. The volume's lifecycle is tied to the pod that defines it - it will be created before the pod starts, and deleted when the pod is removed. + + Use this if: a) the volume is only needed while the pod runs, b) features of normal volumes like restoring from snapshot or capacity + tracking are needed, + c) the storage driver is specified through a storage class, and d) the storage driver supports dynamic volume provisioning through + a PersistentVolumeClaim (see EphemeralVolumeSource for more + information on the connection between this volume type + and PersistentVolumeClaim). + + Use PersistentVolumeClaim or one of the vendor-specific APIs for volumes that persist for longer than the lifecycle of an individual pod. + + Use CSI for light-weight local ephemeral volumes if the CSI driver is meant to be used that way - see the documentation of the driver for more information. + + A pod can use both types of ephemeral volumes and persistent volumes at the same time. + properties: + volumeClaimTemplate: + description: |- + Will be used to create a stand-alone PVC to provision the volume. The pod in which this EphemeralVolumeSource is embedded will be the owner of the PVC, i.e. the PVC will be deleted together with the pod. The name of the PVC will be `-` where `` is the name from the `PodSpec.Volumes` array entry. Pod validation will reject the pod if the concatenated name is not valid for a PVC (for example, too long). + + An existing PVC with that name that is not owned by the pod will *not* be used for the pod to avoid using an unrelated volume by mistake. Starting the pod is then blocked until the unrelated PVC is removed. If such a pre-created PVC is meant to be used by the pod, the PVC has to updated with an owner reference to the pod once the pod exists. Normally this should not be necessary, but it may be useful when manually reconstructing a broken cluster. + + This field is read-only and no changes will be made by Kubernetes to the PVC after it has been created. + + Required, must not be nil. + properties: + metadata: + description: May contain labels and annotations that will be copied into the PVC when creating it. No other fields are allowed and will be rejected during validation. + properties: + annotations: + additionalProperties: + type: string + description: 'Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations' + type: object + creationTimestamp: + description: |- + CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. + + Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + format: date-time + type: string + deletionGracePeriodSeconds: + description: Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only. + format: int64 + type: integer + deletionTimestamp: + description: |- + DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested. + + Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + format: date-time + type: string + finalizers: + description: Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list. + items: + type: string + type: array + generateName: + description: |- + GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server. + + If this field is specified and the generated name exists, the server will return a 409. + + Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency + type: string + generation: + description: A sequence number representing a specific generation of the desired state. Populated by the system. Read-only. + format: int64 + type: integer + labels: + additionalProperties: + type: string + description: 'Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels' + type: object + managedFields: + description: ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like "ci-cd". The set of fields is always in the version that the workflow used when modifying the object. + items: + description: ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to. + properties: + apiVersion: + description: APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. + type: string + fieldsType: + description: 'FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1"' + type: string + fieldsV1: + description: FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. + type: object + manager: + description: Manager is an identifier of the workflow managing these fields. + type: string + operation: + description: Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. + type: string + subresource: + description: Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource. + type: string + time: + description: Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over. + format: date-time + type: string + type: object + type: array + name: + description: 'Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names' + type: string + namespace: + description: |- + Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. + + Must be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces + type: string + ownerReferences: + description: List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller. + items: + description: OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field. + properties: + apiVersion: + description: API version of the referent. + type: string + blockOwnerDeletion: + description: If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. See https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion for how the garbage collector interacts with this field and enforces the foreground deletion. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. + type: boolean + controller: + description: If true, this reference points to the managing controller. + type: boolean + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names' + type: string + uid: + description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids' + type: string + required: + - apiVersion + - kind + - name + - uid + type: object + type: array + resourceVersion: + description: |- + An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. + + Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + type: string + selfLink: + description: 'Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.' + type: string + uid: + description: |- + UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. + + Populated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids + type: string + type: object + spec: + description: The specification for the PersistentVolumeClaim. The entire content is copied unchanged into the PVC that gets created from this template. The same fields as in a PersistentVolumeClaim are also valid here. + properties: + accessModes: + description: 'accessModes contains the desired access modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + dataSource: + description: 'dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner or an external controller can support the specified data source, it will create a new volume based on the contents of the specified data source. When the AnyVolumeDataSource feature gate is enabled, dataSource contents will be copied to dataSourceRef, and dataSourceRef contents will be copied to dataSource when dataSourceRef.namespace is not specified. If the namespace is specified, then dataSourceRef will not be copied to dataSource.' + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + dataSourceRef: + description: |- + dataSourceRef specifies the object from which to populate the volume with data, if a non-empty volume is desired. This may be any object from a non-empty API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed volume populator or dynamic provisioner. This field will replace the functionality of the dataSource field and as such if both fields are non-empty, they must have the same value. For backwards compatibility, when namespace isn't specified in dataSourceRef, both fields (dataSource and dataSourceRef) will be set to the same value automatically if one of them is empty and the other is non-empty. When namespace is specified in dataSourceRef, dataSource isn't set to the same value and must be empty. There are three important differences between dataSource and dataSourceRef: * While dataSource only allows two specific types of objects, dataSourceRef + allows any non-core object, as well as PersistentVolumeClaim objects. + * While dataSource ignores disallowed values (dropping them), dataSourceRef + preserves all values, and generates an error if a disallowed value is + specified. + * While dataSource only allows local objects, dataSourceRef allows objects + in any namespaces. + (Beta) Using this field requires the AnyVolumeDataSource feature gate to be enabled. (Alpha) Using the namespace field of dataSourceRef requires the CrossNamespaceVolumeDataSource feature gate to be enabled. + properties: + apiGroup: + description: APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + namespace: + description: Namespace is the namespace of resource being referenced Note that when a namespace is specified, a gateway.networking.k8s.io/ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. (Alpha) This field requires the CrossNamespaceVolumeDataSource feature gate to be enabled. + type: string + required: + - kind + - name + type: object + resources: + description: 'resources represents the minimum resources the volume should have. Users are allowed to specify resource requirements that are lower than previous value but must still be higher than capacity recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' + properties: + limits: + additionalProperties: + description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation." + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation." + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + selector: + description: selector is a label query over volumes to consider for binding. + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + storageClassName: + description: 'storageClassName is the name of the StorageClass required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' + type: string + volumeAttributesClassName: + description: 'volumeAttributesClassName may be used to set the VolumeAttributesClass used by this claim. If specified, the CSI driver will create or update the volume with the attributes defined in the corresponding VolumeAttributesClass. This has a different purpose than storageClassName, it can be changed after the claim is created. An empty string or nil value indicates that no VolumeAttributesClass will be applied to the claim. If the claim enters an Infeasible error state, this field can be reset to its previous value (including nil) to cancel the modification. If the resource referred to by volumeAttributesClass does not exist, this PersistentVolumeClaim will be set to a Pending state, as reflected by the modifyVolumeStatus field, until such as a resource exists. More info: https://kubernetes.io/docs/concepts/storage/volume-attributes-classes/' + type: string + volumeMode: + description: volumeMode defines what type of volume is required by the claim. Value of Filesystem is implied when not included in claim spec. + type: string + volumeName: + description: volumeName is the binding reference to the PersistentVolume backing this claim. + type: string + type: object + required: + - spec + type: object + type: object + fc: + description: fc represents a Fibre Channel resource that is attached to a kubelet's host machine and then exposed to the pod. + properties: + fsType: + description: fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. + type: string + lun: + description: 'lun is Optional: FC target lun number' + format: int32 + type: integer + readOnly: + description: 'readOnly is Optional: Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.' + type: boolean + targetWWNs: + description: 'targetWWNs is Optional: FC target worldwide names (WWNs)' + items: + type: string + type: array + wwids: + description: 'wwids Optional: FC volume world wide identifiers (wwids) Either wwids or combination of targetWWNs and lun must be set, but not both simultaneously.' + items: + type: string + type: array + type: object + flexVolume: + description: 'flexVolume represents a generic volume resource that is provisioned/attached using an exec based plugin. Deprecated: FlexVolume is deprecated. Consider using a CSIDriver instead.' + properties: + driver: + description: driver is the name of the driver to use for this volume. + type: string + fsType: + description: fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". The default filesystem depends on FlexVolume script. + type: string + options: + additionalProperties: + type: string + description: 'options is Optional: this field holds extra command options if any.' + type: object + readOnly: + description: 'readOnly is Optional: defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.' + type: boolean + secretRef: + description: 'secretRef is Optional: secretRef is reference to the secret object containing sensitive information to pass to the plugin scripts. This may be empty if no secret object is specified. If the secret object contains more than one secret, all secrets are passed to the plugin scripts.' + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + required: + - driver + type: object + flocker: + description: 'flocker represents a Flocker volume attached to a kubelet''s host machine. This depends on the Flocker control service being running. Deprecated: Flocker is deprecated and the in-tree flocker type is no longer supported.' + properties: + datasetName: + description: datasetName is Name of the dataset stored as metadata -> name on the dataset for Flocker should be considered as deprecated + type: string + datasetUUID: + description: datasetUUID is the UUID of the dataset. This is unique identifier of a Flocker dataset + type: string + type: object + gcePersistentDisk: + description: 'gcePersistentDisk represents a GCE Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. Deprecated: GCEPersistentDisk is deprecated. All operations for the in-tree gcePersistentDisk type are redirected to the pd.csi.storage.gke.io CSI driver. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + properties: + fsType: + description: 'fsType is filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + type: string + partition: + description: 'partition is the partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as "1". Similarly, the volume partition for /dev/sda is "0" (or you can leave the property empty). More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + format: int32 + type: integer + pdName: + description: 'pdName is unique name of the PD resource in GCE. Used to identify the disk in GCE. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + type: string + readOnly: + description: 'readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#gcepersistentdisk' + type: boolean + required: + - pdName + type: object + gitRepo: + description: 'gitRepo represents a git repository at a particular revision. Deprecated: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod''s container.' + properties: + directory: + description: directory is the target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name. + type: string + repository: + description: repository is the URL + type: string + revision: + description: revision is the commit hash for the specified revision. + type: string + required: + - repository + type: object + glusterfs: + description: 'glusterfs represents a Glusterfs mount on the host that shares a pod''s lifetime. Deprecated: Glusterfs is deprecated and the in-tree glusterfs type is no longer supported.' + properties: + endpoints: + description: endpoints is the endpoint name that details Glusterfs topology. + type: string + path: + description: 'path is the Glusterfs volume path. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' + type: string + readOnly: + description: 'readOnly here will force the Glusterfs volume to be mounted with read-only permissions. Defaults to false. More info: https://examples.k8s.io/volumes/glusterfs/README.md#create-a-pod' + type: boolean + required: + - endpoints + - path + type: object + hostPath: + description: 'hostPath represents a pre-existing file or directory on the host machine that is directly exposed to the container. This is generally used for system agents or other privileged things that are allowed to see the host machine. Most containers will NOT need this. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + properties: + path: + description: 'path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + type: + description: 'type for HostPath Volume Defaults to "" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + required: + - path + type: object + image: + description: |- + image represents an OCI object (a container image or artifact) pulled and mounted on the kubelet's host machine. The volume is resolved at pod startup depending on which PullPolicy value is provided: + + - Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails. - Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn't present. - IfNotPresent: the kubelet pulls if the reference isn't already present on disk. Container creation will fail if the reference isn't present and the pull fails. + + The volume gets re-resolved if the pod gets deleted and recreated, which means that new remote content will become available on pod recreation. A failure to resolve or pull the image during pod startup will block containers from starting and may add significant latency. Failures will be retried using normal volume backoff and will be reported on the pod reason and message. The types of objects that may be mounted by this volume are defined by the container runtime implementation on a host machine and at minimum must include all valid types supported by the container image field. The OCI object gets mounted in a single directory (spec.containers[*].volumeMounts.mountPath) by merging the manifest layers in the same way as for container images. The volume will be mounted read-only (ro) and non-executable files (noexec). Sub path mounts for containers are not supported (spec.containers[*].volumeMounts.subpath) before 1.33. The field spec.securityContext.fsGroupChangePolicy has no effect on this volume type. + properties: + pullPolicy: + description: 'Policy for pulling OCI objects. Possible values are: Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails. Never: the kubelet never pulls the reference and only uses a local image or artifact. Container creation will fail if the reference isn''t present. IfNotPresent: the kubelet pulls if the reference isn''t already present on disk. Container creation will fail if the reference isn''t present and the pull fails. Defaults to Always if :latest tag is specified, or IfNotPresent otherwise.' + type: string + reference: + description: 'Required: Image or artifact reference to be used. Behaves in the same way as pod.spec.containers[*].image. Pull secrets will be assembled in the same way as for the container image by looking up node credentials, SA image pull secrets, and pod spec image pull secrets. More info: https://kubernetes.io/docs/concepts/containers/images This field is optional to allow higher level config management to default or override container images in workload controllers like Deployments and StatefulSets.' + type: string + type: object + iscsi: + description: 'iscsi represents an ISCSI Disk resource that is attached to a kubelet''s host machine and then exposed to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes/#iscsi' + properties: + chapAuthDiscovery: + description: chapAuthDiscovery defines whether support iSCSI Discovery CHAP authentication + type: boolean + chapAuthSession: + description: chapAuthSession defines whether support iSCSI Session CHAP authentication + type: boolean + fsType: + description: 'fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#iscsi' + type: string + initiatorName: + description: initiatorName is the custom iSCSI Initiator Name. If initiatorName is specified with iscsiInterface simultaneously, new iSCSI interface : will be created for the connection. + type: string + iqn: + description: iqn is the target iSCSI Qualified Name. + type: string + iscsiInterface: + description: iscsiInterface is the interface Name that uses an iSCSI transport. Defaults to 'default' (tcp). + type: string + lun: + description: lun represents iSCSI Target Lun number. + format: int32 + type: integer + portals: + description: portals is the iSCSI Target Portal List. The portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260). + items: + type: string + type: array + readOnly: + description: readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. + type: boolean + secretRef: + description: secretRef is the CHAP Secret for iSCSI target and initiator authentication + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + targetPortal: + description: targetPortal is iSCSI Target Portal. The Portal is either an IP or ip_addr:port if the port is other than default (typically TCP ports 860 and 3260). + type: string + required: + - iqn + - lun + - targetPortal + type: object + name: + description: 'name of the volume. Must be a DNS_LABEL and unique within the pod. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + nfs: + description: 'nfs represents an NFS mount on the host that shares a pod''s lifetime More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + properties: + path: + description: 'path that is exported by the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: string + readOnly: + description: 'readOnly here will force the NFS export to be mounted with read-only permissions. Defaults to false. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: boolean + server: + description: 'server is the hostname or IP address of the NFS server. More info: https://kubernetes.io/docs/concepts/storage/volumes#nfs' + type: string + required: + - path + - server + type: object + persistentVolumeClaim: + description: 'persistentVolumeClaimVolumeSource represents a reference to a PersistentVolumeClaim in the same namespace. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + properties: + claimName: + description: 'claimName is the name of a PersistentVolumeClaim in the same namespace as the pod using this volume. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + type: string + readOnly: + description: readOnly Will force the ReadOnly setting in VolumeMounts. Default false. + type: boolean + required: + - claimName + type: object + photonPersistentDisk: + description: 'photonPersistentDisk represents a PhotonController persistent disk attached and mounted on kubelets host machine. Deprecated: PhotonPersistentDisk is deprecated and the in-tree photonPersistentDisk type is no longer supported.' + properties: + fsType: + description: fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. + type: string + pdID: + description: pdID is the ID that identifies Photon Controller persistent disk + type: string + required: + - pdID + type: object + portworxVolume: + description: 'portworxVolume represents a portworx volume attached and mounted on kubelets host machine. Deprecated: PortworxVolume is deprecated. All operations for the in-tree portworxVolume type are redirected to the pxd.portworx.com CSI driver when the CSIMigrationPortworx feature-gate is on.' + properties: + fsType: + description: fSType represents the filesystem type to mount Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs". Implicitly inferred to be "ext4" if unspecified. + type: string + readOnly: + description: readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. + type: boolean + volumeID: + description: volumeID uniquely identifies a Portworx volume + type: string + required: + - volumeID + type: object + projected: + description: projected items for all in one resources secrets, configmaps, and downward API + properties: + defaultMode: + description: defaultMode are the mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set. + format: int32 + type: integer + sources: + description: sources is the list of volume projections. Each entry in this list handles one source. + items: + description: Projection that may be projected along with other supported volume types. Exactly one of these fields must be set. + properties: + clusterTrustBundle: + description: |- + ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file. + + Alpha, gated by the ClusterTrustBundleProjection feature gate. + + ClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector. + + Kubelet performs aggressive normalization of the PEM contents written into the pod filesystem. Esoteric PEM features such as inter-block comments and block headers are stripped. Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time. + properties: + labelSelector: + description: Select all ClusterTrustBundles that match this label selector. Only has effect if signerName is set. Mutually-exclusive with name. If unset, interpreted as "match nothing". If set but empty, interpreted as "match everything". + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + properties: + key: + description: key is the label key that the selector applies to. + type: string + operator: + description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + name: + description: Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector. + type: string + optional: + description: If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available. If using name, then the named ClusterTrustBundle is allowed not to exist. If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles. + type: boolean + path: + description: Relative path from the volume root to write the bundle. + type: string + signerName: + description: Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated. + type: string + required: + - path + type: object + configMap: + description: configMap information about the configMap data to project + properties: + items: + description: items if unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + optional: + description: optional specify whether the ConfigMap or its keys must be defined + type: boolean + required: + - name + type: object + downwardAPI: + description: downwardAPI information about the downwardAPI data to project + properties: + items: + description: Items is a list of DownwardAPIVolume file + items: + description: DownwardAPIVolumeFile represents information to create the file containing the pod field + properties: + fieldRef: + description: 'Required: Selects a field of the pod: only annotations, labels, name, namespace and uid are supported.' + properties: + apiVersion: + description: Version of the schema the FieldPath is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified API version. + type: string + required: + - fieldPath + type: object + mode: + description: 'Optional: mode bits used to set permissions on this file, must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: 'Required: Path is the relative path name of the file to be created. Must not be absolute or contain the ''..'' path. Must be utf-8 encoded. The first item of the relative path must not start with ''..''' + type: string + resourceFieldRef: + description: 'Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, optional for env vars' + type: string + divisor: + description: Specifies the output format of the exposed resources, defaults to "1" + nullable: true + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + required: + - path + type: object + type: array + type: object + podCertificate: + description: |- + Projects an auto-rotating credential bundle (private key and certificate chain) that the pod can use either as a TLS client or server. + + Kubelet generates a private key and uses it to send a PodCertificateRequest to the named signer. Once the signer approves the request and issues a certificate chain, Kubelet writes the key and certificate chain to the pod filesystem. The pod does not start until certificates have been issued for each podCertificate projected volume source in its spec. + + Kubelet will begin trying to rotate the certificate at the time indicated by the signer using the PodCertificateRequest.Status.BeginRefreshAt timestamp. + + Kubelet can write a single file, indicated by the credentialBundlePath field, or separate files, indicated by the keyPath and certificateChainPath fields. + + The credential bundle is a single file in PEM format. The first PEM entry is the private key (in PKCS#8 format), and the remaining PEM entries are the certificate chain issued by the signer (typically, signers will return their certificate chain in leaf-to-root order). + + Prefer using the credential bundle format, since your application code can read it atomically. If you use keyPath and certificateChainPath, your application must make two separate file reads. If these coincide with a certificate rotation, it is possible that the private key and leaf certificate you read may not correspond to each other. Your application will need to check for this condition, and re-read until they are consistent. + + The named signer controls chooses the format of the certificate it issues; consult the signer implementation's documentation to learn how to use the certificates it issues. + properties: + certificateChainPath: + description: |- + Write the certificate chain at this path in the projected volume. + + Most applications should use credentialBundlePath. When using keyPath and certificateChainPath, your application needs to check that the key and leaf certificate are consistent, because it is possible to read the files mid-rotation. + type: string + credentialBundlePath: + description: |- + Write the credential bundle at this path in the projected volume. + + The credential bundle is a single file that contains multiple PEM blocks. The first PEM block is a PRIVATE KEY block, containing a PKCS#8 private key. + + The remaining blocks are CERTIFICATE blocks, containing the issued certificate chain from the signer (leaf and any intermediates). + + Using credentialBundlePath lets your Pod's application code make a single atomic read that retrieves a consistent key and certificate chain. If you project them to separate files, your application code will need to additionally check that the leaf certificate was issued to the key. + type: string + keyPath: + description: |- + Write the key at this path in the projected volume. + + Most applications should use credentialBundlePath. When using keyPath and certificateChainPath, your application needs to check that the key and leaf certificate are consistent, because it is possible to read the files mid-rotation. + type: string + keyType: + description: |- + The type of keypair Kubelet will generate for the pod. + + Valid values are "RSA3072", "RSA4096", "ECDSAP256", "ECDSAP384", "ECDSAP521", and "ED25519". + type: string + maxExpirationSeconds: + description: |- + maxExpirationSeconds is the maximum lifetime permitted for the certificate. + + Kubelet copies this value verbatim into the PodCertificateRequests it generates for this projection. + + If omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour). The maximum allowable value is 7862400 (91 days). + + The signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour). This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours. + format: int32 + type: integer + signerName: + description: Kubelet's generated CSRs will be addressed to this signer. + type: string + userAnnotations: + additionalProperties: + type: string + description: |- + userAnnotations allow pod authors to pass additional information to the signer implementation. Kubernetes does not restrict or validate this metadata in any way. + + These values are copied verbatim into the `spec.unverifiedUserAnnotations` field of the PodCertificateRequest objects that Kubelet creates. + + Entries are subject to the same validation as object metadata annotations, with the addition that all keys must be domain-prefixed. No restrictions are placed on values, except an overall size limitation on the entire field. + + Signers should document the keys and values they support. Signers should deny requests that contain keys they do not recognize. + type: object + required: + - keyType + - signerName + type: object + secret: + description: secret information about the secret data to project + properties: + items: + description: items if unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. + type: string + required: + - key + - path + type: object + type: array + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + optional: + description: optional field specify whether the Secret or its key must be defined + type: boolean + required: + - name + type: object + serviceAccountToken: + description: serviceAccountToken is information about the serviceAccountToken data to project + properties: + audience: + description: audience is the intended audience of the token. A recipient of a token must identify itself with an identifier specified in the audience of the token, and otherwise should reject the token. The audience defaults to the identifier of the apiserver. + type: string + expirationSeconds: + description: expirationSeconds is the requested duration of validity of the service account token. As the token approaches expiration, the kubelet volume plugin will proactively rotate the service account token. The kubelet will start trying to rotate the token if the token is older than 80 percent of its time to live or if the token is older than 24 hours.Defaults to 1 hour and must be at least 10 minutes. + format: int64 + type: integer + path: + description: path is the path relative to the mount point of the file to project the token into. + type: string + required: + - path + type: object + type: object + type: array + type: object + quobyte: + description: 'quobyte represents a Quobyte mount on the host that shares a pod''s lifetime. Deprecated: Quobyte is deprecated and the in-tree quobyte type is no longer supported.' + properties: + group: + description: group to map volume access to Default is no group + type: string + readOnly: + description: readOnly here will force the Quobyte volume to be mounted with read-only permissions. Defaults to false. + type: boolean + registry: + description: registry represents a single or multiple Quobyte Registry services specified as a string as host:port pair (multiple entries are separated with commas) which acts as the central registry for volumes + type: string + tenant: + description: tenant owning the given Quobyte volume in the Backend Used with dynamically provisioned Quobyte volumes, value is set by the plugin + type: string + user: + description: user to map volume access to Defaults to serivceaccount user + type: string + volume: + description: volume is a string that references an already created Quobyte volume by name. + type: string + required: + - registry + - volume + type: object + rbd: + description: 'rbd represents a Rados Block Device mount on the host that shares a pod''s lifetime. Deprecated: RBD is deprecated and the in-tree rbd type is no longer supported.' + properties: + fsType: + description: 'fsType is the filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#rbd' + type: string + image: + description: 'image is the rados image name. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + keyring: + description: 'keyring is the path to key ring for RBDUser. Default is /etc/ceph/keyring. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + monitors: + description: 'monitors is a collection of Ceph monitors. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + items: + type: string + type: array + pool: + description: 'pool is the rados pool name. Default is rbd. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + readOnly: + description: 'readOnly here will force the ReadOnly setting in VolumeMounts. Defaults to false. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: boolean + secretRef: + description: 'secretRef is name of the authentication secret for RBDUser. If provided overrides keyring. Default is nil. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + user: + description: 'user is the rados user name. Default is admin. More info: https://examples.k8s.io/volumes/rbd/README.md#how-to-use-it' + type: string + required: + - image + - monitors + type: object + scaleIO: + description: 'scaleIO represents a ScaleIO persistent volume attached and mounted on Kubernetes nodes. Deprecated: ScaleIO is deprecated and the in-tree scaleIO type is no longer supported.' + properties: + fsType: + description: fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Default is "xfs". + type: string + gateway: + description: gateway is the host address of the ScaleIO API Gateway. + type: string + protectionDomain: + description: protectionDomain is the name of the ScaleIO Protection Domain for the configured storage. + type: string + readOnly: + description: readOnly Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretRef: + description: secretRef references to the secret for ScaleIO user and other sensitive information. If this is not provided, Login operation will fail. + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + sslEnabled: + description: sslEnabled Flag enable/disable SSL communication with Gateway, default false + type: boolean + storageMode: + description: storageMode indicates whether the storage for a volume should be ThickProvisioned or ThinProvisioned. Default is ThinProvisioned. + type: string + storagePool: + description: storagePool is the ScaleIO Storage Pool associated with the protection domain. + type: string + system: + description: system is the name of the storage system as configured in ScaleIO. + type: string + volumeName: + description: volumeName is the name of a volume already created in the ScaleIO system that is associated with this volume source. + type: string + required: + - gateway + - secretRef + - system + type: object + secret: + description: 'secret represents a secret that should populate this volume. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + properties: + defaultMode: + description: 'defaultMode is Optional: mode bits used to set permissions on created files by default. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + items: + description: items If unspecified, each key-value pair in the Data field of the referenced Secret will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the Secret, the volume setup will error unless it is marked optional. Paths must be relative and may not contain the '..' path or start with '..'. + items: + description: Maps a string key to a path within a volume. + properties: + key: + description: key is the key to project. + type: string + mode: + description: 'mode is Optional: mode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511. YAML accepts both octal and decimal values, JSON requires decimal values for mode bits. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.' + format: int32 + type: integer + path: + description: path is the relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'. + type: string + required: + - key + - path + type: object + type: array + optional: + description: optional field specify whether the Secret or its keys must be defined + type: boolean + secretName: + description: 'secretName is the name of the secret in the pod''s namespace to use. More info: https://kubernetes.io/docs/concepts/storage/volumes#secret' + type: string + type: object + storageos: + description: 'storageOS represents a StorageOS volume attached and mounted on Kubernetes nodes. Deprecated: StorageOS is deprecated and the in-tree storageos type is no longer supported.' + properties: + fsType: + description: fsType is the filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. + type: string + readOnly: + description: readOnly defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts. + type: boolean + secretRef: + description: secretRef specifies the secret to use for obtaining the StorageOS API credentials. If not specified, default values will be attempted. + properties: + name: + description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + required: + - name + type: object + volumeName: + description: volumeName is the human-readable name of the StorageOS volume. Volume names are only unique within a namespace. + type: string + volumeNamespace: + description: volumeNamespace specifies the scope of the volume within StorageOS. If no namespace is specified then the Pod's namespace will be used. This allows the Kubernetes name scoping to be mirrored within StorageOS for tighter integration. Set VolumeName to any name to override the default behaviour. Set to "default" if you are not using namespaces within StorageOS. Namespaces that do not pre-exist within StorageOS will be created. + type: string + type: object + vsphereVolume: + description: 'vsphereVolume represents a vSphere volume attached and mounted on kubelets host machine. Deprecated: VsphereVolume is deprecated. All operations for the in-tree vsphereVolume type are redirected to the csi.vsphere.vmware.com CSI driver.' + properties: + fsType: + description: fsType is filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. "ext4", "xfs", "ntfs". Implicitly inferred to be "ext4" if unspecified. + type: string + storagePolicyID: + description: storagePolicyID is the storage Policy Based Management (SPBM) profile ID associated with the StoragePolicyName. + type: string + storagePolicyName: + description: storagePolicyName is the storage Policy Based Management (SPBM) profile name. + type: string + volumePath: + description: volumePath is the path that identifies vSphere volume vmdk + type: string + required: + - volumePath + type: object + required: + - name + type: object + nullable: true + type: array + flakeRef: + description: Flake reference. E.g. `github:myorg/myapp`. + type: string + ingress: + description: If set, the operator creates an Ingress with ownerReferences. + nullable: true + properties: + className: + description: Ingress class name. + nullable: true + type: string + enabled: + default: false + description: Whether to create the Ingress resource. + type: boolean + hosts: + description: Ingress host rules. + items: + properties: + host: + description: Hostname. + type: string + paths: + description: Paths for this host. + items: + properties: + path: + description: URL path. + type: string + pathType: + description: 'Path type: Prefix, Exact, ImplementationSpecific.' + nullable: true + type: string + port: + description: Backend port (name or number as string). + type: string + required: + - path + - port + type: object + type: array + required: + - host + - paths + type: object + nullable: true + type: array + tls: + description: TLS configuration. + items: + properties: + hosts: + description: Hostnames covered by this TLS config. + items: + type: string + type: array + secretName: + description: Secret name containing TLS cert. + type: string + required: + - hosts + - secretName + type: object + nullable: true + type: array + type: object + livenessProbe: + description: Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic. + nullable: true + properties: + exec: + description: Exec specifies a command to execute in the container. + properties: + command: + description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies a GRPC HealthCheckRequest. + properties: + port: + description: Port number of the gRPC service. Number must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies an HTTP GET request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header to be used in HTTP probes + properties: + name: + description: The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + description: Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies a connection to a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults to the pod IP.' + type: string + port: + description: Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + nodeSelector: + additionalProperties: + type: string + description: Additional node selector labels (merged with `niphas.io/store=true`). + nullable: true + type: object + ports: + description: Exposed ports (same schema as K8s container.ports). + items: + description: ContainerPort represents a network port in a single container. + properties: + containerPort: + description: Number of port to expose on the pod's IP address. This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + hostPort: + description: Number of port to expose on the host. If specified, this must be a valid port number, 0 < x < 65536. If HostNetwork is specified, this must match ContainerPort. Most containers do not need this. + format: int32 + type: integer + name: + description: If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services. + type: string + protocol: + description: Protocol for port. Must be UDP, TCP, or SCTP. Defaults to "TCP". + type: string + required: + - containerPort + type: object + nullable: true + type: array + readinessProbe: + description: Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic. + nullable: true + properties: + exec: + description: Exec specifies a command to execute in the container. + properties: + command: + description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies a GRPC HealthCheckRequest. + properties: + port: + description: Port number of the gRPC service. Number must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies an HTTP GET request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header to be used in HTTP probes + properties: + name: + description: The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + description: Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies a connection to a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults to the pod IP.' + type: string + port: + description: Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + replicas: + description: Number of pod replicas. Defaults to 1. + format: int32 + nullable: true + type: integer + resources: + description: CPU/memory requests and limits. + nullable: true + properties: + claims: + description: |- + Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + + This field depends on the DynamicResourceAllocation feature gate. + + This field is immutable. It can only be set for containers. + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container. + type: string + request: + description: Request is the name chosen for a request in the referenced claim. If empty, everything from the claim is made available, otherwise only the result of this request. + type: string + required: + - name + type: object + type: array + limits: + additionalProperties: + description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation." + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation." + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + revision: + description: Git revision to pin. Must be a 6-40 char hex string. + nullable: true + type: string + service: + description: If set, the operator creates a Service with ownerReferences. + nullable: true + properties: + ports: + description: Service ports. + items: + properties: + name: + description: Port name. + nullable: true + type: string + port: + description: Service port number. + format: int32 + type: integer + protocol: + description: Protocol (TCP, UDP). Defaults to TCP. + nullable: true + type: string + targetPort: + description: Target port (name or number as string). + nullable: true + type: string + required: + - port + type: object + type: array + type: + description: 'Service type: ClusterIP, NodePort, LoadBalancer. Defaults to ClusterIP.' + nullable: true + type: string + required: + - ports + type: object + startupProbe: + description: Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic. + nullable: true + properties: + exec: + description: Exec specifies a command to execute in the container. + properties: + command: + description: Command is the command line to execute inside the container, the working directory for the command is root ('/') in the container's filesystem. The command is simply exec'd, it is not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use a shell, you need to explicitly call out to that shell. Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies a GRPC HealthCheckRequest. + properties: + port: + description: Port number of the gRPC service. Number must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies an HTTP GET request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header to be used in HTTP probes + properties: + name: + description: The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header. + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + description: Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies a connection to a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults to the pod IP.' + type: string + port: + description: Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + tolerations: + description: Extra tolerations. Operator always injects not-ready/unreachable (30s). + items: + description: The pod this Toleration is attached to tolerates any taint that matches the triple using the matching operator . + properties: + effect: + description: Effect indicates the taint effect to match. Empty means match all taint effects. When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: Key is the taint key that the toleration applies to. Empty means match all taint keys. If the key is empty, operator must be Exists; this combination means to match all values and all keys. + type: string + operator: + description: Operator represents a key's relationship to the value. Valid operators are Exists, Equal, Lt, and Gt. Defaults to Equal. Exists is equivalent to wildcard for value, so that a pod can tolerate all taints of a particular category. Lt and Gt perform numeric comparisons (requires feature gate TaintTolerationComparisonOperators). + type: string + tolerationSeconds: + description: TolerationSeconds represents the period of time the toleration (which must be of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, it is not set, which means tolerate the taint forever (do not evict). Zero and negative values will be treated as 0 (evict immediately) by the system. + format: int64 + type: integer + value: + description: Value is the taint value the toleration matches to. If the operator is Exists, the value should be empty, otherwise just a regular string. + type: string + type: object + nullable: true + type: array + required: + - attribute + - flakeRef + type: object + status: + nullable: true + properties: + architectures: + description: Per-architecture status (only when `spec.architectures` is set). + items: + description: Per-architecture status for multi-arch workloads. + properties: + arch: + description: Architecture name (e.g. `x86_64`, `aarch64`). + type: string + closurePaths: + description: Closure paths for this architecture. + items: + type: string + nullable: true + type: array + readyReplicas: + description: Ready replicas for this architecture. + format: int32 + nullable: true + type: integer + resolvedCommand: + description: Resolved entrypoint for this architecture. + nullable: true + type: string + storePath: + description: Resolved store path for this architecture. + type: string + required: + - arch + - storePath + type: object + nullable: true + type: array + closurePaths: + description: |- + Full transitive closure (root + all references). + The CSI driver uses this to fetch NARs without depending on binary cache .narinfo. + items: + type: string + nullable: true + type: array + conditions: + description: Standard K8s-style conditions. + items: + properties: + lastTransitionTime: + description: When this condition last transitioned (ISO 8601). + type: string + message: + description: Human-readable message. + type: string + observedGeneration: + description: The generation this condition was set at. + format: int64 + nullable: true + type: integer + reason: + description: 'Machine-readable reason: EvalSucceeded, NarFetchFailed, ReplicasReady, etc.' + type: string + status: + description: Condition status. + enum: + - 'True' + - 'False' + - Unknown + type: string + type: + description: 'Condition type: Evaluated, ClosureCached, Available, Progressing, Degraded.' + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + nullable: true + type: array + lastEval: + description: ISO 8601 timestamp of last successful evaluation. + nullable: true + type: string + observedGeneration: + description: The `metadata.generation` most recently processed by the controller. + format: int64 + nullable: true + type: integer + phase: + default: Pending + description: 'High-level phase: Pending, Evaluating, Provisioning, Running, Failed.' + enum: + - Pending + - Evaluating + - Provisioning + - Running + - Failed + type: string + readyReplicas: + description: Number of pods in Ready state. + format: int32 + nullable: true + type: integer + resolvedCommand: + description: The actual entrypoint command. E.g. `/nix/store/abc123-myapp-1.0.0/bin/myapp`. + nullable: true + type: string + storePath: + description: Resolved Nix store path. E.g. `/nix/store/abc123-myapp-1.0.0`. + nullable: true + type: string + type: object + required: + - spec + title: NiphasWorkload + type: object + served: true + storage: true + subresources: + status: {} diff --git a/charts/niphas/templates/_helpers.tpl b/charts/niphas/templates/_helpers.tpl new file mode 100644 index 0000000..7b1f290 --- /dev/null +++ b/charts/niphas/templates/_helpers.tpl @@ -0,0 +1,46 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "niphas.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "niphas.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Common labels. +*/}} +{{- define "niphas.labels" -}} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/part-of: niphas +helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} +{{- end }} + +{{/* +Selector labels for a component. +*/}} +{{- define "niphas.selectorLabels" -}} +app.kubernetes.io/name: {{ .name }} +app.kubernetes.io/instance: {{ .root.Release.Name }} +{{- end }} + +{{/* +Namespace helper. +*/}} +{{- define "niphas.namespace" -}} +{{ .Values.namespace | default "niphas-system" }} +{{- end }} diff --git a/charts/niphas/templates/configmap.yaml b/charts/niphas/templates/configmap.yaml new file mode 100644 index 0000000..160aef6 --- /dev/null +++ b/charts/niphas/templates/configmap.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: niphas-config + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} +data: + config.yaml: | + log_level: {{ .Values.config.logLevel | quote }} + binary_caches: + {{- range .Values.config.binaryCaches }} + - {{ . | quote }} + {{- end }} + allowed_flake_origins: + {{- range .Values.config.allowedFlakeOrigins }} + - {{ . | quote }} + {{- end }} + eval_webhook_url: {{ .Values.config.evalWebhookUrl | quote }} + health_port: {{ .Values.config.healthPort }} + eval_timeout: {{ .Values.config.evalTimeout | quote }} + cache: + path: {{ .Values.config.cache.path | quote }} + high_watermark: {{ .Values.config.cache.highWatermark }} + low_watermark: {{ .Values.config.cache.lowWatermark }} + gc_interval: {{ .Values.config.cache.gcInterval | quote }} diff --git a/charts/niphas/templates/csi/csidriver.yaml b/charts/niphas/templates/csi/csidriver.yaml new file mode 100644 index 0000000..9de99a8 --- /dev/null +++ b/charts/niphas/templates/csi/csidriver.yaml @@ -0,0 +1,12 @@ +apiVersion: storage.k8s.io/v1 +kind: CSIDriver +metadata: + name: niphas.io.csi + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: csi +spec: + attachRequired: false + podInfoOnMount: true + volumeLifecycleModes: + - Ephemeral diff --git a/charts/niphas/templates/csi/daemonset.yaml b/charts/niphas/templates/csi/daemonset.yaml new file mode 100644 index 0000000..dd96a99 --- /dev/null +++ b/charts/niphas/templates/csi/daemonset.yaml @@ -0,0 +1,98 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: niphas-csi + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: csi + {{- include "niphas.selectorLabels" (dict "name" "niphas-csi" "root" .) | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "niphas.selectorLabels" (dict "name" "niphas-csi" "root" .) | nindent 6 }} + template: + metadata: + labels: + {{- include "niphas.labels" . | nindent 8 }} + app.kubernetes.io/component: csi + {{- include "niphas.selectorLabels" (dict "name" "niphas-csi" "root" .) | nindent 8 }} + spec: + nodeSelector: + {{- toYaml .Values.csi.nodeSelector | nindent 8 }} + containers: + - name: csi-driver + image: "{{ .Values.csi.image.repository }}:{{ .Values.csi.image.tag }}" + imagePullPolicy: {{ .Values.csi.image.pullPolicy }} + args: + - "--endpoint=unix:///csi/csi.sock" + env: + - name: NIPHAS_CONFIG + value: /etc/niphas/config.yaml + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + securityContext: + privileged: true + ports: + - name: healthz + containerPort: 9808 + protocol: TCP + livenessProbe: + httpGet: + path: /healthz + port: healthz + initialDelaySeconds: 10 + periodSeconds: 10 + resources: + {{- toYaml .Values.csi.resources | nindent 12 }} + volumeMounts: + - name: socket-dir + mountPath: /csi + - name: pods-mount-dir + mountPath: /var/lib/kubelet/pods + mountPropagation: Bidirectional + - name: cache + mountPath: /var/lib/niphas/cache + - name: config + mountPath: /etc/niphas + readOnly: true + - name: node-driver-registrar + image: "{{ .Values.csi.registrar.image.repository }}:{{ .Values.csi.registrar.image.tag }}" + args: + - "--csi-address=/csi/csi.sock" + - "--kubelet-registration-path=/var/lib/kubelet/plugins/niphas.io.csi/csi.sock" + volumeMounts: + - name: socket-dir + mountPath: /csi + - name: registration-dir + mountPath: /registration + - name: liveness-probe + image: "{{ .Values.csi.liveness.image.repository }}:{{ .Values.csi.liveness.image.tag }}" + args: + - "--csi-address=/csi/csi.sock" + - "--health-port=9808" + volumeMounts: + - name: socket-dir + mountPath: /csi + volumes: + - name: socket-dir + hostPath: + path: /var/lib/kubelet/plugins/niphas.io.csi + type: DirectoryOrCreate + - name: registration-dir + hostPath: + path: /var/lib/kubelet/plugins_registry + type: Directory + - name: pods-mount-dir + hostPath: + path: /var/lib/kubelet/pods + type: Directory + - name: cache + hostPath: + path: /var/lib/niphas/cache + type: DirectoryOrCreate + - name: config + configMap: + name: niphas-config diff --git a/charts/niphas/templates/eval/deployment.yaml b/charts/niphas/templates/eval/deployment.yaml new file mode 100644 index 0000000..7115302 --- /dev/null +++ b/charts/niphas/templates/eval/deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: niphas-eval + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: eval + {{- include "niphas.selectorLabels" (dict "name" "niphas-eval" "root" .) | nindent 4 }} +spec: + replicas: {{ .Values.eval.replicas }} + selector: + matchLabels: + {{- include "niphas.selectorLabels" (dict "name" "niphas-eval" "root" .) | nindent 6 }} + template: + metadata: + labels: + {{- include "niphas.labels" . | nindent 8 }} + app.kubernetes.io/component: eval + {{- include "niphas.selectorLabels" (dict "name" "niphas-eval" "root" .) | nindent 8 }} + spec: + containers: + - name: eval + image: "{{ .Values.eval.image.repository }}:{{ .Values.eval.image.tag }}" + imagePullPolicy: {{ .Values.eval.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.eval.targetPort }} + protocol: TCP + env: + - name: NIPHAS_CONFIG + value: /etc/niphas/config.yaml + livenessProbe: + httpGet: + path: /healthz + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /healthz + port: http + initialDelaySeconds: 5 + periodSeconds: 5 + resources: + {{- toYaml .Values.eval.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /etc/niphas + readOnly: true + - name: nix-var + mountPath: /nix/var + - name: nix-tmp + mountPath: /tmp + volumes: + - name: config + configMap: + name: niphas-config + - name: nix-var + emptyDir: {} + - name: nix-tmp + emptyDir: {} diff --git a/charts/niphas/templates/eval/service.yaml b/charts/niphas/templates/eval/service.yaml new file mode 100644 index 0000000..e6024a6 --- /dev/null +++ b/charts/niphas/templates/eval/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: niphas-eval + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: eval +spec: + type: ClusterIP + ports: + - name: http + port: {{ .Values.eval.servicePort }} + targetPort: {{ .Values.eval.targetPort }} + protocol: TCP + selector: + {{- include "niphas.selectorLabels" (dict "name" "niphas-eval" "root" .) | nindent 4 }} diff --git a/charts/niphas/templates/namespace.yaml b/charts/niphas/templates/namespace.yaml new file mode 100644 index 0000000..56c498d --- /dev/null +++ b/charts/niphas/templates/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} diff --git a/charts/niphas/templates/operator/clusterrole.yaml b/charts/niphas/templates/operator/clusterrole.yaml new file mode 100644 index 0000000..b0103ad --- /dev/null +++ b/charts/niphas/templates/operator/clusterrole.yaml @@ -0,0 +1,39 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: niphas-operator + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator +rules: + # NiphasWorkload CRD + - apiGroups: ["niphas.io"] + resources: ["niphasworkloads"] + verbs: ["get", "list", "watch", "update", "patch"] + - apiGroups: ["niphas.io"] + resources: ["niphasworkloads/status"] + verbs: ["get", "update", "patch"] + - apiGroups: ["niphas.io"] + resources: ["niphasworkloads/finalizers"] + verbs: ["update", "patch"] + # Child resources + - apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + - apiGroups: [""] + resources: ["services"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + - apiGroups: ["networking.k8s.io"] + resources: ["ingresses"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + - apiGroups: ["policy"] + resources: ["poddisruptionbudgets"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + # Events + - apiGroups: [""] + resources: ["events"] + verbs: ["create", "patch"] + # Pod status (for ready replica counting) + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch"] diff --git a/charts/niphas/templates/operator/clusterrolebinding.yaml b/charts/niphas/templates/operator/clusterrolebinding.yaml new file mode 100644 index 0000000..4d5f5e3 --- /dev/null +++ b/charts/niphas/templates/operator/clusterrolebinding.yaml @@ -0,0 +1,15 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: niphas-operator + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: niphas-operator +subjects: + - kind: ServiceAccount + name: niphas-operator + namespace: {{ include "niphas.namespace" . }} diff --git a/charts/niphas/templates/operator/deployment.yaml b/charts/niphas/templates/operator/deployment.yaml new file mode 100644 index 0000000..dbf1259 --- /dev/null +++ b/charts/niphas/templates/operator/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: niphas-operator + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator + {{- include "niphas.selectorLabels" (dict "name" "niphas-operator" "root" .) | nindent 4 }} +spec: + replicas: {{ .Values.operator.replicas }} + selector: + matchLabels: + {{- include "niphas.selectorLabels" (dict "name" "niphas-operator" "root" .) | nindent 6 }} + template: + metadata: + labels: + {{- include "niphas.labels" . | nindent 8 }} + app.kubernetes.io/component: operator + {{- include "niphas.selectorLabels" (dict "name" "niphas-operator" "root" .) | nindent 8 }} + spec: + serviceAccountName: niphas-operator + containers: + - name: operator + image: "{{ .Values.operator.image.repository }}:{{ .Values.operator.image.tag }}" + imagePullPolicy: {{ .Values.operator.image.pullPolicy }} + ports: + - name: health + containerPort: {{ .Values.config.healthPort }} + protocol: TCP + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: NIPHAS_CONFIG + value: /etc/niphas/config.yaml + livenessProbe: + httpGet: + path: /healthz + port: health + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /readyz + port: health + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + {{- toYaml .Values.operator.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /etc/niphas + readOnly: true + volumes: + - name: config + configMap: + name: niphas-config diff --git a/charts/niphas/templates/operator/role.yaml b/charts/niphas/templates/operator/role.yaml new file mode 100644 index 0000000..a57f915 --- /dev/null +++ b/charts/niphas/templates/operator/role.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: niphas-operator-leader-election + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator +rules: + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] diff --git a/charts/niphas/templates/operator/rolebinding.yaml b/charts/niphas/templates/operator/rolebinding.yaml new file mode 100644 index 0000000..c9f0371 --- /dev/null +++ b/charts/niphas/templates/operator/rolebinding.yaml @@ -0,0 +1,16 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: niphas-operator-leader-election + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: niphas-operator-leader-election +subjects: + - kind: ServiceAccount + name: niphas-operator + namespace: {{ include "niphas.namespace" . }} diff --git a/charts/niphas/templates/operator/serviceaccount.yaml b/charts/niphas/templates/operator/serviceaccount.yaml new file mode 100644 index 0000000..58a2632 --- /dev/null +++ b/charts/niphas/templates/operator/serviceaccount.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: niphas-operator + namespace: {{ include "niphas.namespace" . }} + labels: + {{- include "niphas.labels" . | nindent 4 }} + app.kubernetes.io/component: operator diff --git a/charts/niphas/values.yaml b/charts/niphas/values.yaml new file mode 100644 index 0000000..47835f6 --- /dev/null +++ b/charts/niphas/values.yaml @@ -0,0 +1,74 @@ +namespace: niphas-system + +operator: + image: + repository: ghcr.io/fullzer4/niphas-operator + tag: latest + pullPolicy: IfNotPresent + replicas: 1 + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 500m + memory: 256Mi + +eval: + image: + repository: ghcr.io/fullzer4/niphas-eval + tag: latest + pullPolicy: IfNotPresent + replicas: 1 + servicePort: 8443 + targetPort: 8080 + resources: + requests: + cpu: 200m + memory: 256Mi + limits: + cpu: "1" + memory: 1Gi + +csi: + image: + repository: ghcr.io/fullzer4/niphas-csi + tag: latest + pullPolicy: IfNotPresent + nodeSelector: + niphas.io/store: "true" + registrar: + image: + repository: registry.k8s.io/sig-storage/csi-node-driver-registrar + tag: v2.13.0 + liveness: + image: + repository: registry.k8s.io/sig-storage/livenessprobe + tag: v2.14.0 + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + cpu: 200m + memory: 256Mi + +runner: + image: + repository: ghcr.io/fullzer4/niphas-runner + tag: latest + +config: + logLevel: info + binaryCaches: + - https://cache.nixos.org + allowedFlakeOrigins: + - "github:*" + evalWebhookUrl: http://niphas-eval.niphas-system.svc:8443 + healthPort: 8080 + evalTimeout: 300s + cache: + path: /var/lib/niphas/cache + highWatermark: 15000000000 + lowWatermark: 10000000000 + gcInterval: 300s diff --git a/crates/niphas-core/Cargo.toml b/crates/niphas-core/Cargo.toml index 5b0f7dd..53c3ce5 100644 --- a/crates/niphas-core/Cargo.toml +++ b/crates/niphas-core/Cargo.toml @@ -47,6 +47,10 @@ sha2.workspace = true ed25519-dalek.workspace = true base64.workspace = true +[[bin]] +name = "niphas-crd-gen" +path = "src/bin/crd_gen.rs" + [features] default = [] runtime = ["kube/runtime"] diff --git a/crates/niphas-core/src/bin/crd_gen.rs b/crates/niphas-core/src/bin/crd_gen.rs new file mode 100644 index 0000000..ee33b58 --- /dev/null +++ b/crates/niphas-core/src/bin/crd_gen.rs @@ -0,0 +1,6 @@ +use kube::CustomResourceExt; +use niphas_core::crd::NiphasWorkload; + +fn main() { + print!("{}", serde_yaml::to_string(&NiphasWorkload::crd()).unwrap()); +} diff --git a/crates/niphas-e2e/Cargo.toml b/crates/niphas-e2e/Cargo.toml new file mode 100644 index 0000000..316df42 --- /dev/null +++ b/crates/niphas-e2e/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "niphas-e2e" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +publish = false + +[[bin]] +name = "niphas-mock-eval" +path = "src/bin/mock_eval.rs" + +[dependencies] +niphas-core = { workspace = true, features = ["runtime"] } +kube.workspace = true +k8s-openapi.workspace = true +tokio.workspace = true +serde_json.workspace = true +anyhow.workspace = true +reqwest.workspace = true +axum.workspace = true +serde.workspace = true +tracing.workspace = true diff --git a/crates/niphas-e2e/src/bin/mock_eval.rs b/crates/niphas-e2e/src/bin/mock_eval.rs new file mode 100644 index 0000000..9da33d1 --- /dev/null +++ b/crates/niphas-e2e/src/bin/mock_eval.rs @@ -0,0 +1,56 @@ +use axum::{Json, Router, http::StatusCode, response::IntoResponse, routing::get, routing::post}; +use niphas_core::eval::{EvalRequest, EvalResponse}; +use std::net::SocketAddr; + +async fn evaluate(Json(req): Json) -> impl IntoResponse { + // Simulate failure for flake refs containing "nonexistent" or "does-not-exist" + if req.flake_ref.contains("nonexistent") || req.flake_ref.contains("does-not-exist") { + return Err(( + StatusCode::UNPROCESSABLE_ENTITY, + format!("evaluation failed: flake '{}' not found", req.flake_ref), + )); + } + + let store_path = format!( + "/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-{}", + req.flake_ref.split(':').next_back().unwrap_or("mock") + ); + let name = req + .flake_ref + .split('/') + .next_back() + .unwrap_or("mock-app") + .to_string(); + + Ok(Json(EvalResponse { + store_path: store_path.clone(), + name: name.clone(), + main_program: Some(name), + closure_paths: vec![store_path], + })) +} + +async fn healthz() -> &'static str { + "ok" +} + +async fn readyz() -> &'static str { + "ok" +} + +#[tokio::main] +async fn main() { + let addr: SocketAddr = std::env::var("LISTEN_ADDR") + .unwrap_or_else(|_| "0.0.0.0:8080".to_string()) + .parse() + .expect("invalid LISTEN_ADDR"); + + let app = Router::new() + .route("/evaluate", post(evaluate)) + .route("/healthz", get(healthz)) + .route("/readyz", get(readyz)); + + println!("mock-eval listening on {addr}"); + let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); + axum::serve(listener, app).await.unwrap(); +} diff --git a/crates/niphas-e2e/src/lib.rs b/crates/niphas-e2e/src/lib.rs new file mode 100644 index 0000000..9497bfa --- /dev/null +++ b/crates/niphas-e2e/src/lib.rs @@ -0,0 +1,2 @@ +// niphas-e2e: end-to-end test crate for niphas platform. +// This crate contains mock binaries and integration tests. diff --git a/crates/niphas-e2e/tests/e2e_platform.rs b/crates/niphas-e2e/tests/e2e_platform.rs new file mode 100644 index 0000000..1369f99 --- /dev/null +++ b/crates/niphas-e2e/tests/e2e_platform.rs @@ -0,0 +1,175 @@ +use anyhow::{Context, Result, bail}; +use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition; +use kube::{ + Api, Client, + api::{DeleteParams, PostParams}, +}; +use niphas_core::crd::{NiphasWorkload, WorkloadPhase}; +use std::time::Duration; + +/// Poll the NiphasWorkload status until it reaches `expected` phase or timeout. +async fn wait_for_phase( + api: &Api, + name: &str, + expected: WorkloadPhase, + timeout: Duration, +) -> Result { + let start = std::time::Instant::now(); + loop { + if start.elapsed() > timeout { + bail!( + "timed out waiting for workload '{}' to reach phase {:?}", + name, + expected + ); + } + if let Some(wl) = api.get_opt(name).await? { + if let Some(ref status) = wl.status { + if status.phase == expected { + return Ok(wl); + } + } + } + tokio::time::sleep(Duration::from_secs(2)).await; + } +} + +/// Wait until the workload no longer exists. +async fn wait_for_deletion(api: &Api, name: &str, timeout: Duration) -> Result<()> { + let start = std::time::Instant::now(); + loop { + if start.elapsed() > timeout { + bail!("timed out waiting for workload '{}' to be deleted", name); + } + if api.get_opt(name).await?.is_none() { + return Ok(()); + } + tokio::time::sleep(Duration::from_secs(2)).await; + } +} + +fn test_workload(name: &str, flake_ref: &str) -> NiphasWorkload { + serde_json::from_value(serde_json::json!({ + "apiVersion": "niphas.io/v1alpha1", + "kind": "NiphasWorkload", + "metadata": { + "name": name, + }, + "spec": { + "flakeRef": flake_ref, + "attribute": "packages.x86_64-linux.default", + } + })) + .expect("valid test workload") +} + +#[tokio::test] +async fn test_crd_installed() -> Result<()> { + let client = Client::try_default().await?; + let crds: Api = Api::all(client); + let crd = crds + .get("niphasworkloads.niphas.io") + .await + .context("CRD niphasworkloads.niphas.io not found in cluster")?; + + assert_eq!(crd.spec.group, "niphas.io", "CRD group must be niphas.io"); + Ok(()) +} + +#[tokio::test] +async fn test_operator_healthy() -> Result<()> { + let url = std::env::var("OPERATOR_HEALTH_URL") + .unwrap_or_else(|_| "http://localhost:8080/healthz".to_string()); + + let resp = reqwest::get(&url) + .await + .context("failed to reach operator healthz")?; + assert!( + resp.status().is_success(), + "operator healthz returned {}", + resp.status() + ); + Ok(()) +} + +#[tokio::test] +async fn test_eval_healthy() -> Result<()> { + let url = std::env::var("EVAL_HEALTH_URL") + .unwrap_or_else(|_| "http://localhost:8443/healthz".to_string()); + + let resp = reqwest::get(&url) + .await + .context("failed to reach eval healthz")?; + assert!( + resp.status().is_success(), + "eval healthz returned {}", + resp.status() + ); + Ok(()) +} + +#[tokio::test] +async fn test_workload_eval_failure_sets_failed() -> Result<()> { + let client = Client::try_default().await?; + let ns = std::env::var("E2E_NAMESPACE").unwrap_or_else(|_| "niphas-e2e".to_string()); + let api: Api = Api::namespaced(client, &ns); + + let name = "e2e-fail-test"; + let wl = test_workload(name, "github:nonexistent/does-not-exist-12345"); + + // Clean up if leftover from previous run + let _ = api.delete(name, &DeleteParams::default()).await; + tokio::time::sleep(Duration::from_secs(2)).await; + + api.create(&PostParams::default(), &wl) + .await + .context("failed to create test workload")?; + + let result = wait_for_phase(&api, name, WorkloadPhase::Failed, Duration::from_secs(120)).await; + + // Cleanup + let _ = api.delete(name, &DeleteParams::default()).await; + + let wl = result.context("workload did not reach Failed phase")?; + let status = wl.status.expect("status should be set"); + + // Check Evaluated condition is False + if let Some(conditions) = &status.conditions { + let eval_cond = conditions.iter().find(|c| c.type_ == "Evaluated"); + assert!(eval_cond.is_some(), "expected Evaluated condition to exist"); + } + + Ok(()) +} + +#[tokio::test] +async fn test_workload_deletion_cleanup() -> Result<()> { + let client = Client::try_default().await?; + let ns = std::env::var("E2E_NAMESPACE").unwrap_or_else(|_| "niphas-e2e".to_string()); + let api: Api = Api::namespaced(client, &ns); + + let name = "e2e-delete-test"; + let wl = test_workload(name, "github:nixos/nixpkgs"); + + // Clean up if leftover + let _ = api.delete(name, &DeleteParams::default()).await; + tokio::time::sleep(Duration::from_secs(2)).await; + + api.create(&PostParams::default(), &wl) + .await + .context("failed to create test workload")?; + + // Wait for it to get a finalizer (operator picks it up) + tokio::time::sleep(Duration::from_secs(10)).await; + + // Delete it + api.delete(name, &DeleteParams::default()) + .await + .context("failed to delete test workload")?; + + wait_for_deletion(&api, name, Duration::from_secs(60)) + .await + .context("workload was not cleaned up after deletion")?; + + Ok(()) +} diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 0000000..3a35962 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,14 @@ +[book] +title = "niphas" +description = "νιφάς — Nix-native platform for Kubernetes" +authors = ["fullzer4"] +language = "en" +src = "src" + +[build] +build-dir = "book" + +[output.html] +default-theme = "ayu" +preferred-dark-theme = "ayu" +git-repository-url = "https://github.com/fullzer4/niphas" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 0000000..0f87737 --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,29 @@ +# Summary + +# Architecture + +- [Overview](./architecture/README.md) +- [Runtime Model](./architecture/runtime-model.md) +- [Deploy Flow](./architecture/deploy-flow.md) + +# Components + +- [Overview](./components/README.md) +- [Operator](./components/operator.md) +- [Evaluator](./components/eval.md) +- [CSI Driver](./components/csi-driver.md) +- [Mesh Protocol](./components/mesh-protocol.md) + +# Reference + +- [Overview](./reference/README.md) +- [CRD Reference](./reference/crd-reference.md) +- [Nix Wire Format](./reference/nix-wire.md) +- [Security Design](./reference/security-design.md) +- [Resilience](./reference/resilience.md) +- [Testing](./reference/testing.md) + +--- + +- [Security Policy](./reference/security.md) +- [Known Issues](./reference/problem.md) diff --git a/docs/src/architecture/README.md b/docs/src/architecture/README.md new file mode 100644 index 0000000..3fd93e8 --- /dev/null +++ b/docs/src/architecture/README.md @@ -0,0 +1,64 @@ +# Architecture & Project Structure + +Niphas is a Nix-native platform for Kubernetes, organized as a Rust workspace with five crates. + +## Directory Layout + +``` +niphas/ +├── crates/ +│ ├── niphas-core/ # shared library (CRDs, Nix formats, cache client) +│ ├── niphas-eval/ # Nix evaluator webhook (C FFI) +│ ├── niphas-operator/ # Kubernetes operator +│ ├── niphas-csi/ # CSI node driver +│ └── niphas-mesh/ # P2P NAR distribution (libp2p) +├── proto/ # vendored CSI gRPC proto +├── nix/ # flake-parts modules +├── chart/ # Helm chart +└── flake.nix # Nix build with Crane +``` + +## Core Crate + +`niphas-core` is the shared library used by all other crates: + +| Module | Purpose | +|--------|---------| +| `crd.rs` | `NiphasWorkload` CRD definition | +| `hash.rs` | Nix-base32 encoding, SHA-256, `NixHash` | +| `nar.rs` | NAR streaming parser and extractor | +| `narinfo.rs` | `.narinfo` parser | +| `store_path.rs` | Store path validation | +| `cache_client.rs` | Binary cache HTTP client | +| `signature.rs` | Ed25519 signature verification | +| `closure.rs` | Parallel closure resolution (BFS) | + +## Build System + +The Nix build uses [Crane](https://crane.dev) with a two-phase strategy: + +1. **`buildDepsOnly`** — cacheable dependency layer (only `Cargo.lock` and `Cargo.toml` files) +2. **`buildPackage`** — per-crate build on top of cached deps + +OCI images are produced via `dockerTools.buildLayeredImage` with minimal contents (static musl binaries). + +## Key Design Decisions + +- **Axum** over actix-web — native tower/hyper ecosystem, async-first +- **Vendored CSI proto** — sandboxed Nix builds can't fetch at build time +- **Selective libp2p** — only TCP, QUIC, Noise, Yamux, Gossipsub features enabled +- **Workspace dependency inheritance** — single source of truth in root `Cargo.toml` + +## Observability + +- Structured JSON logging via `tracing-subscriber` +- Optional OpenTelemetry integration (zero overhead without `OTEL_*` env vars) +- Distributed tracing via W3C TraceContext propagation + +## Input Validation + +Three-layer defense against Nix injection: + +1. **Regex validation** — `flake_ref`, `attribute`, `revision` validated before use +2. **Flake allowlist** — deny-by-default glob matching +3. **Nix sandbox** — `restrict_eval=true`, `allow_import_from_derivation=false`, `max_jobs=0` diff --git a/docs/src/architecture/deploy-flow.md b/docs/src/architecture/deploy-flow.md new file mode 100644 index 0000000..0d470b8 --- /dev/null +++ b/docs/src/architecture/deploy-flow.md @@ -0,0 +1,113 @@ +# Deploy Flow + +From a single CRD to a running workload — no Dockerfile, no registry, no image tags. + +## User Experience + +```yaml +apiVersion: niphas.io/v1 +kind: NiphasWorkload +metadata: + name: hello +spec: + flakeRef: "github:NixOS/nixpkgs" + attribute: "hello" +``` + +That's it. The operator evaluates the flake reference, resolves the closure, creates a Deployment with CSI volumes, and the workload runs. + +## Production Example + +```yaml +apiVersion: niphas.io/v1 +kind: NiphasWorkload +metadata: + name: my-app +spec: + flakeRef: "github:myorg/myapp" + attribute: "packages.x86_64-linux.default" + revision: "abc123" + replicas: 3 + args: ["--port", "8080"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: db-credentials + key: url + ports: + - containerPort: 8080 + resources: + requests: + cpu: "100m" + memory: "128Mi" + limits: + cpu: "500m" + memory: "512Mi" + livenessProbe: + httpGet: + path: /healthz + port: 8080 + service: + type: ClusterIP + ports: + - port: 80 + targetPort: 8080 + ingress: + enabled: true + className: nginx + hosts: + - host: my-app.example.com + paths: + - path: / + pathType: Prefix +``` + +## Build Model + +**CI builds, the cluster evaluates and fetches** (never builds). + +1. CI runs `nix build` and pushes to a binary cache +2. `niphas-eval` runs `nix eval` to resolve the store path deterministically +3. If the path isn't cached, the workload fails with `StorePathNotCached` + +## End-to-End Sequence + +1. User creates `NiphasWorkload` CR +2. Operator detects new resource, sets phase `Evaluating` +3. Operator calls eval webhook with `flakeRef`, `attribute`, `revision` +4. Eval validates against flake allowlist (deny-by-default) +5. Eval resolves store path via Nix C FFI +6. Eval resolves full closure via binary cache `.narinfo` (parallel BFS) +7. Operator receives `storePath`, `closurePaths`, `mainProgram` +8. Operator creates Deployment, Service, Ingress (server-side apply) +9. Kubelet schedules pods on nodes with `niphas.io/store=true` label +10. CSI driver fetches NARs (cache → mesh → binary cache) +11. Pod starts with Nix binary as entrypoint +12. Operator sets phase `Running` + +## Command Resolution + +If `spec.command` is omitted: + +1. Eval checks `meta.mainProgram` in the derivation +2. If not set, lists `$out/bin/` +3. If exactly one binary found, uses it +4. Otherwise, fails with an error + +## Updates and Rollouts + +Changing the spec increments `metadata.generation`: + +1. Operator detects `observedGeneration < generation` +2. Re-evaluates if `flakeRef`, `attribute`, or `revision` changed +3. Patches Deployment with new CSI `volumeAttributes` and command +4. Kubernetes performs a rolling update + +## Multi-Architecture + +The `architectures` field triggers parallel evaluation: + +- `attribute` must contain `{arch}` placeholder (e.g., `packages.{arch}.default`) +- One Deployment created per architecture +- A single Service selects all pods via shared labels diff --git a/docs/src/architecture/runtime-model.md b/docs/src/architecture/runtime-model.md new file mode 100644 index 0000000..9e79fe7 --- /dev/null +++ b/docs/src/architecture/runtime-model.md @@ -0,0 +1,57 @@ +# Runtime Model + +How Nix-built binaries run inside Kubernetes without traditional container images. + +## The Core Insight + +Nix closures are more self-contained than OCI images. Every binary carries absolute `/nix/store` paths for all dependencies — the dynamic linker, shared libraries, and runtime data are all pinned. + +## How Nix Makes Binaries Self-Contained + +- **`patchelf`** rewrites `PT_INTERP` (dynamic linker) and `DT_RUNPATH` (shared lib search) to `/nix/store` paths +- **`patchShebangs`** fixes script interpreters (`#!/nix/store/...`) +- **Closures** are transitively complete — every referenced store path is included +- **Static builds** (musl) have no `PT_INTERP` or `DT_RUNPATH` at all + +## How It Runs in Kubernetes + +**Problem:** Kubernetes requires an `image` field on every container. + +**Solution:** A stub image (`niphas-runner`, ~1 MB) provides the minimal filesystem, while the actual binary comes from a CSI volume mount. + +The stub provides only: +- `/etc/passwd`, `/etc/group`, `/etc/nsswitch.conf` +- `/tmp` + +The CSI driver mounts the Nix closure at `/nix/store`, making the binary and all its dependencies available. + +### Execution Sequence + +1. Kubelet calls `NodePublishVolume` on the CSI driver +2. CSI checks local cache → mesh peers → binary cache HTTP +3. NAR is fetched, verified (Ed25519 + hash), and extracted +4. Bind-mount at the pod's volume target +5. Container starts with the Nix binary as entrypoint +6. Dynamic linker loads from `/nix/store` paths — no host dependencies needed + +Kubelet automatically provides `/proc`, `/sys`, `/dev`, `/etc/resolv.conf`, `/etc/hosts`. + +## Edge Cases + +| Scenario | Solution | +|----------|----------| +| Programs hardcoding `/bin/sh` | Fix at package level or symlink in stub | +| GPU workloads | Standard NVIDIA device plugin pattern | +| `setuid` binaries | CSI mount uses `MS_NOSUID` | +| `dlopen` plugins | `patchelf`, `wrapProgram`, or CRD env vars | + +## Comparison with Traditional Containers + +| Aspect | Traditional OCI | Niphas | +|--------|----------------|--------| +| Build | Dockerfile → layers | Nix derivation → NAR | +| Size | 50MB–1GB typical | Exact closure size | +| Deduplication | Per-layer | Per-store-path | +| Reproducibility | Best-effort | Bit-for-bit | +| Registry | Required | Binary cache (optional) | +| Update granularity | Full layer | Individual store paths | diff --git a/docs/src/components/README.md b/docs/src/components/README.md new file mode 100644 index 0000000..ef240d7 --- /dev/null +++ b/docs/src/components/README.md @@ -0,0 +1,29 @@ +# Components + +Niphas is composed of four core components that work together to deliver Nix-built workloads on Kubernetes. + +``` + ┌──────────────┐ + NiphasWorkload │ Operator │──── eval webhook ────► Evaluator + CR ────────────►│ (reconcile) │ │ + └──────┬───────┘ nix eval C FFI + │ │ + create Deployment binary cache + + CSI volume closure resolve + │ + ┌──────▼───────┐ ┌─────────────┐ + kubelet ──►│ CSI Driver │◄──────►│ Mesh │ + │ (DaemonSet) │ socket │ (DaemonSet) │ + └──────────────┘ └─────────────┘ + fetch NAR P2P distribute + bind-mount gossipsub +``` + +## Overview + +| Component | Type | Role | +|-----------|------|------| +| [Operator](/components/operator) | Deployment | Watches CRDs, reconciles into Deployments/Services/Ingress | +| [Evaluator](/components/eval) | Deployment | Nix evaluation via C FFI, closure resolution | +| [CSI Driver](/components/csi-driver) | DaemonSet | Fetches NARs, mounts `/nix/store` into pods | +| [Mesh](/components/mesh-protocol) | DaemonSet | Optional P2P NAR distribution between nodes | diff --git a/docs/src/components/csi-driver.md b/docs/src/components/csi-driver.md new file mode 100644 index 0000000..8d341e6 --- /dev/null +++ b/docs/src/components/csi-driver.md @@ -0,0 +1,94 @@ +# CSI Driver Design + +The niphas-csi driver mounts Nix store paths as ephemeral volumes inside Kubernetes pods. + +## Why CSI + +- Official Kubernetes storage abstraction +- Works under Pod Security Standards Restricted (consumer pods stay unprivileged) +- Functions on all managed Kubernetes providers +- CSI ephemeral inline volumes are GA since Kubernetes 1.25 + +## Architecture + +Node-only plugin — no Controller service. The driver runs as a DaemonSet on nodes labeled `niphas.io/store=true`. + +### gRPC Services + +**Identity Service:** +- `GetPluginInfo` — returns driver name and version +- `GetPluginCapabilities` — no optional capabilities +- `Probe` — readiness check + +**Node Service:** +- `NodePublishVolume` — fetch NAR and bind-mount at target +- `NodeUnpublishVolume` — unmount and clean up +- `NodeGetCapabilities` — reports supported features +- `NodeGetInfo` — returns node ID + +No Controller service is needed — everything is node-local. + +## Volume Lifecycle + +1. **Pod creation** → kubelet calls `NodePublishVolume` +2. Driver checks local cache → mesh peers → binary cache HTTP +3. NAR fetched, verified (Ed25519 signatures + hash), extracted +4. Bind-mount at target path +5. **Pod deletion** → kubelet calls `NodeUnpublishVolume` +6. Unmount, cached data persists for future pods + +Both publish and unpublish are idempotent. + +## NAR Fetch Chain + +``` +local cache ──miss──► mesh P2P ──miss──► binary cache HTTP ──miss──► gRPC Unavailable + (instant) (LAN, 5s) (WAN, HTTPS) (kubelet retries) +``` + +For each NAR: + +1. Fetch `.narinfo` → verify Ed25519 signature +2. Download compressed NAR → verify `FileHash` +3. Decompress → verify `NarHash` (inline streaming) +4. Extract to `.tmp-*` → atomic rename (CVE-2024-45593 mitigations) + +**Unverified NAR never reaches a pod.** + +## Node-Local Cache + +Location: `/var/lib/niphas/cache/` + +- Content-addressed storage +- Atomic population (`.tmp-*` then rename) +- Crash-safe — incomplete downloads are cleaned up +- LRU garbage collection (high watermark 85%, low watermark 75%) + +## Closure Handling + +The eval webhook pre-resolves the full closure and passes it via `volumeAttributes.closurePaths`. The CSI driver fetches individual NARs — it doesn't need `.narinfo` parsing for closure resolution. + +## DaemonSet + +The CSI DaemonSet requires: + +- **Privileged mode** — needed for `Bidirectional` mount propagation +- `hostPath` volumes for socket registration and NAR cache +- Sidecars: `node-driver-registrar` (required), `livenessprobe` (recommended) + +Consumer pods remain fully unprivileged — the CSI abstraction layer handles the privilege boundary. + +## CSIDriver Object + +```yaml +apiVersion: storage.k8s.io/v1 +kind: CSIDriver +metadata: + name: niphas.io.csi +spec: + attachRequired: false + podInfoOnMount: true + volumeLifecycleModes: + - Ephemeral + fsGroupPolicy: None +``` diff --git a/docs/src/components/eval.md b/docs/src/components/eval.md new file mode 100644 index 0000000..d0a33d8 --- /dev/null +++ b/docs/src/components/eval.md @@ -0,0 +1,111 @@ +# Eval Webhook Design + +The niphas-eval service evaluates Nix flake references and resolves closures via the Nix C FFI — no subprocess, no container. + +## Architecture + +``` + operator ──POST /evaluate──► niphas-eval + │ + ┌───────┼────────┐ + │ │ │ + validate nix eval closure + allowlist C FFI resolution + │ + binary cache + GET /.narinfo +``` + +## HTTP API + +### `POST /evaluate` + +**Request:** +```json +{ + "flakeRef": "github:myorg/myapp", + "attribute": "packages.x86_64-linux.default", + "revision": "abc123", + "binaryCache": "https://cache.example.com" +} +``` + +**Response (200):** +```json +{ + "storePath": "/nix/store/abc...-myapp-1.0", + "name": "myapp-1.0", + "mainProgram": "myapp", + "closurePaths": [ + "/nix/store/abc...-myapp-1.0", + "/nix/store/def...-glibc-2.38" + ] +} +``` + +**Error responses:** + +| Code | Error | Meaning | +|------|-------|---------| +| 403 | `FlakeNotAllowed` | Flake origin not in allowlist | +| 404 | `StorePathNotCached` | Path not found in binary cache | +| 408 | `EvalTimeout` | Evaluation exceeded timeout | +| 422 | `EvalFailed` | Nix evaluation error | +| 502 | `ClosureResolutionFailed` | Cannot resolve full closure | + +### Health Endpoints + +- `GET /healthz` — process running +- `GET /readyz` — evaluator initialized (503 during cold start) + +## Nix C FFI + +niphas-eval links directly against the Nix C libraries (`libexpr-c`, `libstore-c`, `libflake-c`) via `nix-bindings-rust`. The evaluator runs in-process. + +- `EvalState` initialized once, shared across requests (thread-safe C API) +- CPU-bound evaluation dispatched via `spawn_blocking` +- Nix C API serializes evaluations internally (internal mutex) + +## Eval Settings + +``` +sandbox = true +restrict_eval = true +allowed_uris = [github.com, cache.nixos.org] +allow_import_from_derivation = false # critical +max_jobs = 0 +``` + +## Flake Allowlist + +Deny-by-default glob matching. Patterns support `*` wildcards. Validated **before** the evaluator is invoked. + +## Closure Resolution + +After evaluation, the eval service resolves the full transitive closure via binary cache HTTP: + +1. Fetch `.narinfo` for the root store path +2. Parse `References` field +3. Recursively fetch `.narinfo` for each reference (parallel BFS) +4. Return complete closure list + +Uses `FuturesUnordered` with bounded concurrency (default 32). + +## Eval Cache + +The `/nix/store` PVC persists fetched flake inputs and evaluated derivations: + +| Scenario | Latency | +|----------|---------| +| Cold eval (first time) | 5–15s | +| Same revision | 1–3s | +| Same flake, cached inputs | less than 100ms | + +**PVC sizing:** 10–20 GB typical (nixpkgs alone is ~1 GB). + +## Deployment + +- 2 replicas recommended +- PVC for `/nix/store` (eval cache must persist) +- Non-root, read-only rootfs, no capabilities +- Resource requests: 500m CPU, 1Gi RAM diff --git a/docs/src/components/mesh-protocol.md b/docs/src/components/mesh-protocol.md new file mode 100644 index 0000000..cf1456e --- /dev/null +++ b/docs/src/components/mesh-protocol.md @@ -0,0 +1,94 @@ +# Mesh Protocol Design + +Optional P2P distribution of NARs between nodes via libp2p. An optimization for scale, speed, and resilience. + +## Overview + +The mesh is a DaemonSet providing peer-to-peer NAR distribution across cluster nodes. It's optional — the system works without it, falling back to binary cache HTTP. + +**When it helps:** +- Scale: 100+ nodes pulling the same NAR +- Speed: LAN transfer vs WAN binary cache +- Resilience: if binary cache is temporarily down + +## Architecture + +Every mesh pod is equal — no leader election needed. NARs are content-addressed and immutable, so any peer can serve any cached NAR. + +Deployed only on nodes with both `niphas.io/store=true` and `niphas.io/mesh=true` labels. Resource usage: ~40–60 MB RAM when idle. + +## libp2p Stack + +| Layer | Choice | +|-------|--------| +| Transport | TCP + QUIC | +| Encryption | Noise XX (mutual auth, PFS) | +| Multiplexing | Yamux | +| Discovery | DNS (Headless Service) + K8s API watch | +| Messaging | Gossipsub | +| Data transfer | libp2p streams | + +Port: 4001 (TCP + UDP) + +## Protocol Messages + +### Gossipsub (topic: `niphas/nar/v1`) + +- **Have** — announces a NAR is available locally (`nar_hash`, `store_path`, `nar_size`) +- **Evicted** — announces a NAR was garbage-collected (`nar_hash`) + +### Control Plane (CBOR) + +- **HasNar** / **QueryNarInfo** — point-to-point queries +- Responses: `Available`, `NarSize`, `NarInfo`, `NotFound`, `Busy` + +### Data Plane (libp2p streams) + +- `TransferHeader` (48 bytes fixed) + raw compressed NAR bytes +- For NARs larger than 64 MB: parallel range download (swarming) from multiple peers + +## NAR Index + +Each node maintains a local `HashMap` — "who has NAR X?" — populated entirely from gossipsub messages. O(1) lookup, ~240 KB for 3000 store paths. + +## Peer Discovery + +1. **Bootstrap:** Headless Service DNS resolution +2. **Dynamic:** K8s API watch for real-time membership changes + node labels + +## CSI Integration + +The CSI driver communicates with the mesh via a Unix socket at `/var/run/niphas/mesh.sock` using JSON-RPC: + +``` +CSI ──FetchNar──► mesh socket + │ + NAR index lookup + │ + fetch from best peer + (same zone preferred) + │ + verify + announce Have + │ + respond Fetched +``` + +If mesh is unavailable, CSI falls back to binary cache HTTP transparently. + +## Cache Management + +- **Per-node lazy caching** — each node only caches NARs for pods it runs +- No proactive replication — minimal bandwidth overhead +- **GC:** high watermark 85% → evict LRU unmounted NARs → low watermark 75% + +## Authentication + +- Noise XX handshake provides mutual authentication and perfect forward secrecy +- Closed mesh: PeerId allowlist populated from K8s API watch +- Keys generated on first boot, stored in K8s Secret per node + +## Bandwidth Control + +- Per-peer rate limiting via `governor` crate +- Priority queue: CSI mount requests take priority over peer-serving requests +- Configurable connection limits diff --git a/docs/src/components/operator.md b/docs/src/components/operator.md new file mode 100644 index 0000000..4e5e299 --- /dev/null +++ b/docs/src/components/operator.md @@ -0,0 +1,102 @@ +# Operator Design + +The niphas-operator watches `NiphasWorkload` custom resources and reconciles them into running Kubernetes workloads. + +## Reconciliation State Machine + +``` + ┌──────────┐ + create │ Pending │ + ────────► └────┬─────┘ + │ + ┌────▼─────┐ + eval ok │Evaluating│──── eval error ──► Failed + └────┬─────┘ + │ + ┌─────▼──────┐ + apply ok │Provisioning│──── apply error ─► Failed + └─────┬──────┘ + │ + ┌────▼─────┐ + ready │ Running │──── spec change ──► Evaluating + └──────────┘ +``` + +## Reconciler Loop + +Each reconciliation: + +1. Compare `observedGeneration` vs `metadata.generation` +2. If eval needed → call eval webhook (POST to niphas-eval) +3. On success → generate child resources (Deployment, Service, Ingress, PDB) +4. Apply via server-side apply (SSA) for idempotence +5. Check replica readiness → update phase +6. Requeue with interval + +## Eval Webhook Integration + +The operator calls `POST /evaluate` on niphas-eval: + +**Request:** +```json +{ + "flakeRef": "github:myorg/myapp", + "attribute": "packages.x86_64-linux.default", + "revision": "abc123", + "binaryCache": "https://cache.example.com" +} +``` + +**Response (200):** +```json +{ + "storePath": "/nix/store/abc...-myapp-1.0", + "name": "myapp-1.0", + "mainProgram": "myapp", + "closurePaths": ["/nix/store/abc...-myapp-1.0", "/nix/store/def...-glibc-2.38", "..."] +} +``` + +**Error codes:** `FlakeNotAllowed` (403), `EvalFailed` (422), `EvalTimeout` (408), `StorePathNotCached` (404), `ClosureResolutionFailed` (502) + +## Child Resources + +The operator generates and applies: + +- **Deployment** — with `nodeSelector` (`niphas.io/store=true`), CSI ephemeral volume, runner image, tolerations for fast failover +- **Service** — conditional, created only if `spec.service` is set +- **Ingress** — conditional, created only if `spec.ingress.enabled` is true +- **PodDisruptionBudget** — created when `replicas >= 2`, `maxUnavailable=1` + +All child resources use `ownerReferences` pointing back to the `NiphasWorkload`. + +## Leader Election + +Lease-based leader election with: +- 15s TTL +- 5s renewal interval +- 5s retry interval + +New leader acquired within ~15s on failure. Reconciliation is idempotent, so brief dual-leader windows are safe. + +## Error Handling + +| Error | Strategy | +|-------|----------| +| Eval timeout | Requeue after 30s | +| Eval unreachable | Exponential backoff | +| SSA conflict | Immediate retry | +| Transient K8s error | 5s + backoff | +| Permanent error | Set phase `Failed` | + +## Events + +The operator emits Kubernetes Events: + +`EvalStarted`, `EvalSucceeded`, `EvalFailed`, `FlakeNotAllowed`, `StorePathNotCached`, `Provisioned`, `Available`, `Degraded`, `Deleting` + +## Health Probes + +- `/healthz` — process alive +- `/readyz` — leader acquired and watching +- `/metrics` — Prometheus endpoint diff --git a/docs/src/reference/README.md b/docs/src/reference/README.md new file mode 100644 index 0000000..288600c --- /dev/null +++ b/docs/src/reference/README.md @@ -0,0 +1,25 @@ +# Reference + +Technical reference documentation for niphas internals, APIs, and operational concerns. + +## API & Formats + +| Document | Description | +|----------|-------------| +| [CRD Reference](/reference/crd-reference) | Complete `NiphasWorkload` API spec — fields, status, conditions, validation | +| [Nix Wire Format](/reference/nix-wire) | NAR format, `.narinfo`, hashing, Ed25519 signatures, binary cache protocol | + +## Operations + +| Document | Description | +|----------|-------------| +| [Security Design](/reference/security-design) | Threat model, RBAC, pod security, network policies, eval sandboxing | +| [Resilience](/reference/resilience) | Failure handling, fallback chains, PDB, topology spread, priority classes | +| [Testing](/reference/testing) | Test strategy, sans-IO patterns, trait injection, tiers | + +## Other + +| Document | Description | +|----------|-------------| +| [Security Policy](/reference/security) | Vulnerability reporting and disclosure policy | +| [Known Issues](/reference/problem) | Tracked problems and planned fixes | diff --git a/docs/src/reference/crd-reference.md b/docs/src/reference/crd-reference.md new file mode 100644 index 0000000..1ff3a7f --- /dev/null +++ b/docs/src/reference/crd-reference.md @@ -0,0 +1,121 @@ +# CRD Reference + +Complete API reference for the `NiphasWorkload` custom resource. + +## Spec — Core Fields + +| Field | Type | Required | Default | Description | +|-------|------|----------|---------|-------------| +| `flakeRef` | string | yes | — | Nix flake reference | +| `attribute` | string | yes | — | Flake output attribute | +| `revision` | string | no | latest | Git revision (6–40 hex chars) | +| `replicas` | integer | no | 1 | Number of pod replicas | +| `binaryCache` | string | no | ConfigMap | Binary cache URL | + +## Spec — Container Fields + +| Field | Type | Description | +|-------|------|-------------| +| `command` | string | Entrypoint (auto-detected from `meta.mainProgram` if omitted) | +| `args` | list of strings | Arguments passed to the entrypoint | +| `env` | list of EnvVar | Environment variables (standard K8s schema) | +| `ports` | list of ContainerPort | Container port definitions | + +## Spec — Resource Management + +| Field | Type | Description | +|-------|------|-------------| +| `resources` | ResourceRequirements | CPU/memory requests and limits | + +## Spec — Health Checks + +| Field | Type | Description | +|-------|------|-------------| +| `livenessProbe` | Probe | Liveness probe (standard K8s schema) | +| `readinessProbe` | Probe | Readiness probe | +| `startupProbe` | Probe | Startup probe | + +## Spec — Scheduling + +| Field | Type | Description | +|-------|------|-------------| +| `nodeSelector` | map | Merged with `niphas.io/store=true` | +| `tolerations` | list | Appended to failover tolerations | +| `affinity` | Affinity | Standard K8s affinity rules | + +## Spec — Service Exposure + +| Field | Type | Description | +|-------|------|-------------| +| `service` | ServiceSpec | Service type and ports | +| `ingress` | IngressSpec | `enabled`, `className`, `hosts`, `tls` | + +## Spec — Multi-Architecture + +| Field | Type | Description | +|-------|------|-------------| +| `architectures` | list of strings | Target Nix systems | + +When set, `attribute` must contain `{arch}` placeholder. One Deployment per architecture, single Service selects all. + +## Status + +| Field | Type | Description | +|-------|------|-------------| +| `observedGeneration` | integer | Last reconciled generation | +| `phase` | string | `Pending`, `Evaluating`, `Provisioning`, `Running`, `Failed` | +| `storePath` | string | Resolved Nix store path | +| `resolvedCommand` | string | Resolved entrypoint binary | +| `closurePaths` | list of strings | Full transitive closure | +| `lastEval` | timestamp | Last successful evaluation time | +| `readyReplicas` | integer | Number of ready replicas | +| `conditions` | list of Condition | Detailed status conditions | + +## Conditions + +| Type | True | False | +|------|------|-------| +| `Evaluated` | Eval succeeded | Eval failed or pending | +| `ClosureCached` | All paths available | Missing paths | +| `Available` | Minimum replicas ready | Insufficient replicas | +| `Progressing` | Rollout in progress | Stable | +| `Degraded` | Partial failure | Fully healthy | + +## Validation Rules + +- `flakeRef` must match allowed regex pattern +- `attribute` must not be empty +- `replicas` must be >= 0 +- `revision` must be 6–40 hex characters +- Port names must be unique +- `architectures` must be valid Nix system strings +- `{arch}` required in `attribute` when `architectures` is set + +## Defaults Injected by Operator + +- `nodeSelector` always includes `niphas.io/store=true` +- Tolerations injected for fast failover (30s vs default 300s) +- `topologySpreadConstraints` for `replicas >= 2` +- CSI volume for `/nix/store` +- Runner image as container image +- Command resolved from eval if not specified + +## Labels on Child Resources + +``` +niphas.io/workload: +niphas.io/managed-by: niphas-operator +niphas.io/store-path: +niphas.io/flake-ref: +app.kubernetes.io/name: +app.kubernetes.io/managed-by: niphas +``` + +## kubectl Output + +``` +NAME FLAKE PHASE READY +hello github:NixOS/nixpkgs Running 1/1 +``` + +Short names: `nw`, `niphas` diff --git a/docs/src/reference/nix-wire.md b/docs/src/reference/nix-wire.md new file mode 100644 index 0000000..5ddcee6 --- /dev/null +++ b/docs/src/reference/nix-wire.md @@ -0,0 +1,101 @@ +# Nix Wire Formats & Binary Cache Protocol + +How niphas-core implements NAR parsing, `.narinfo` handling, Nix hashing, signature verification, and binary cache interaction. + +## Module Layout + +All wire format code lives in `niphas-core`: + +| Module | Purpose | +|--------|---------| +| `nar.rs` | NAR streaming parser and extractor | +| `narinfo.rs` | `.narinfo` text parser | +| `hash.rs` | Nix-base32 encoding, SHA-256 | +| `signature.rs` | Ed25519 signature verification | +| `store_path.rs` | Store path validation | +| `cache_client.rs` | Binary cache HTTP client | +| `closure.rs` | Parallel closure resolution | + +## NAR Format + +NAR (Nix ARchive) is a deterministic serialization format for file system objects. + +**Wire primitives:** +- 64-bit unsigned little-endian integers +- Length-prefixed strings padded to 8-byte alignment + +**Node types:** `regular` (files), `symlink`, `directory` (with sorted entries) + +**Constraints:** +- Magic: `nix-archive-1` +- Directory entries must be strictly ascending (no duplicates) +- No `/` or `\0` in entry names +- Depth limit: 256 +- Zero padding, no trailing data + +**Extractor safety (CVE-2024-45593):** +- Atomic extraction to `.tmp-*` then rename +- Symlink validation via `O_NOFOLLOW` and `*at()` syscalls +- No symlink following during extraction + +## `.narinfo` Format + +Plain text `field=value` pairs: + +``` +StorePath: /nix/store/abc...-hello-2.12 +URL: nar/abc....nar.zst +Compression: zstd +FileHash: sha256:abc... +FileSize: 12345 +NarHash: sha256:def... +NarSize: 67890 +References: abc...-glibc-2.38 def...-hello-2.12 +Sig: cache.nixos.org-1:base64signature... +``` + +## Nix Hashing + +SHA-256 with a custom base32 encoding: + +- **Nix-base32 alphabet:** `0123456789abcdfghijklmnpqrsvwxyz` (omits `e`, `o`, `t`, `u`) +- Encoding is reversed (LSB first) +- Store path hash: 32-char Nix-base32 in `/nix/store/-` + +## Ed25519 Signature Verification + +Fingerprint format: + +``` +1;;;; +``` + +At least one signature must validate against trusted public keys. Unverified NARs are rejected. + +## Verification Chain + +Every NAR goes through a complete verification pipeline: + +1. Fetch `.narinfo` → verify Ed25519 signature +2. Download compressed NAR → verify `FileHash` +3. Decompress → verify `NarHash` (inline streaming) +4. Extract → atomic rename + +**Unverified NAR never reaches a pod.** + +## Binary Cache HTTP Client + +**Endpoints:** +- `GET /nix-cache-info` — cache metadata +- `GET /.narinfo` — store path info +- `GET /nar/.nar.zst` — compressed NAR data + +The client supports priority-ordered cache lists and streams large NARs without loading them entirely into memory. + +## Closure Resolution + +Pure HTTP, no Nix needed. Recursive BFS of `.narinfo` `References` fields with parallel resolution (configurable concurrency, default 32). + +## Decompression + +Supported formats: `zstd` (most common), `xz`, `bzip2`, `br` (brotli), `none`. Uses `async-compression` for streaming decompression. diff --git a/docs/src/reference/problem.md b/docs/src/reference/problem.md new file mode 100644 index 0000000..0e1af76 --- /dev/null +++ b/docs/src/reference/problem.md @@ -0,0 +1,89 @@ +# Known Issues + +Tracked problems and their planned fixes, ordered by priority. + +## Critical + +### P1 — Nix Expression Injection + +`flake_ref` and `attribute` are interpolated into Nix expressions without character validation. A crafted input could execute arbitrary Nix code. + +**Fix:** Regex validation + reject special characters before interpolation. + +### P2 — No Leader Election + +Running multiple operator replicas causes duplicate evaluations and SSA conflicts. + +**Fix:** Lease-based leader election via `kube-leader-election`, or single replica for MVP. + +## High + +### P3 — Revision Field Not Validated + +The `revision` field accepts any string. Should be constrained to 6–40 hex characters. + +### P4 — No Eval Concurrency Limit + +No limit on concurrent eval subprocesses — potential fork-bomb under load. + +**Fix:** Semaphore with configurable `max_concurrent_evals`. + +### P5 — NAR Buffered in Memory + +Large NARs are held in memory 3x during processing (1.5 GB for a 500 MB package like gcc). + +**Fix phase 1:** 2 GB decompressed size limit. **Phase 2:** Streaming `NarVisitor`. + +### P6 — Readiness Race Condition + +Ready flag set before the controller starts watching, causing a brief window where the probe reports ready prematurely. + +**Fix:** Set ready flag inside `for_each()` callback. + +## Medium + +### P7 — Silent Serialization Failures + +`unwrap_or_default()` on serialization errors produces null instead of an error. + +### P8 — Glob Matching ReDoS + +Current glob implementation has potential quadratic complexity. + +**Fix:** Use `glob-match` crate with O(n) worst-case. + +### P9 — Lock Map Grows Unbounded + +Download lock map entries are never cleaned up after completion. + +### P10 — Runner Image Hardcoded + +The runner image tag is hardcoded to `:latest`. + +**Fix:** Make configurable + per-workload override. + +### P11 — ownerReference with Empty UID + +If the workload UID is `None`, child resources get an empty ownerReference, breaking garbage collection. + +## Low + +### P12 — Unused Workspace Dependencies + +`libp2p`, `rkyv`, `smallvec`, and others are declared but not used. + +### P13 — niphas-mesh is a Stub + +The mesh crate has no implementation yet. + +### P14 — AppError Missing Traits + +`AppError` doesn't implement `Display` or `Error`. + +### P15 — Manual humantime_serde + +Duration serialization is hand-rolled instead of using `humantime_serde`. + +### P16 — No Integration Tests + +Zero integration tests — only unit tests for parsing and crypto. diff --git a/docs/src/reference/resilience.md b/docs/src/reference/resilience.md new file mode 100644 index 0000000..027a778 --- /dev/null +++ b/docs/src/reference/resilience.md @@ -0,0 +1,103 @@ +# Resilience & Failure Handling + +How niphas handles node failures, cache misses, component crashes, and maintains availability. + +## Node Failure Timeline + +``` +T+0s Node stops heartbeating +T+40s Taint: NotReady + unreachable:NoExecute +T+70s Pods evicted (Niphas tolerationSeconds=30s, not default 300s) +T+70s Pods rescheduled to healthy nodes +``` + +Niphas overrides the default 300s toleration to 30s for faster failover. + +## Fetch Fallback Chain + +When a pod is rescheduled, the CSI driver fetches NARs through a 4-source fallback: + +``` +1. Local cache ─ instant, always valid + │ miss +2. Mesh P2P ─ LAN transfer, 5s timeout (optional) + │ miss +3. Binary cache ─ WAN HTTPS, priority-ordered + │ miss +4. gRPC Unavailable ─ kubelet retries with backoff +``` + +## Per-Node Lazy Cache + +Each node only caches NARs for pods it actually runs — no proactive replication. + +**Benefits:** +- Minimal resource usage +- No bandwidth overhead +- Scales to any cluster size +- No coordination needed + +## PodDisruptionBudget + +Created automatically for workloads with `replicas >= 2`: + +- `maxUnavailable: 1` +- `unhealthyPodEvictionPolicy: AlwaysAllow` (K8s 1.31+) + +## Topology Spread + +- **Hard constraint:** no two replicas on the same node +- **Soft constraint:** prefer spreading across zones (don't block scheduling) + +## PriorityClass + +| Component | Priority | Class | +|-----------|----------|-------| +| CSI DaemonSet | system-cluster-critical | Must survive resource pressure | +| Operator, Mesh | 1,000,000 | `niphas-infrastructure` | +| Workloads | 100,000 | `niphas-workload` | + +## Leader Election + +Operator uses Lease-based leader election: + +- 15s TTL, 5s renewal +- New leader acquired within ~15s on failure +- Reconciliation is idempotent — brief dual-leader windows are safe + +## CSI Error Handling + +| gRPC Code | Meaning | Action | +|-----------|---------|--------| +| `Unavailable` | Transient error | kubelet retries | +| `Internal` | Mount failure | kubelet retries | +| `InvalidArgument` | User configuration error | Requires fix | +| `NotFound` | Store path doesn't exist | Requires fix | + +Never leaves a partial mount — operations are atomic. + +## Status Conditions + +Five condition types track the workload state: + +- **Evaluated** — eval succeeded or failed +- **ClosureCached** — all paths available in cache +- **Available** — minimum replicas ready +- **Progressing** — rollout in progress +- **Degraded** — partial failure + +All tracked via `observedGeneration` for eventual consistency. + +## Failure Scenario Matrix + +| Failure | Impact | Recovery | +|---------|--------|----------| +| Node dies | Pods rescheduled in ~70s | CSI re-fetches NARs | +| Binary cache down | New pods can't start | Mesh + local cache still work | +| Mesh + cache down | New pods can't start | Wait for binary cache | +| CSI pod crashes | DaemonSet restarts it | Cached data persists | +| Operator dies | No reconciliation | Leader re-elected in ~15s | +| Eval pod dies | Evals fail | Deployment restarts, PVC preserves cache | +| NAR corrupted | Re-hash detects | Evict and re-fetch | +| CRD deleted | Finalizer cleanup | ownerReferences cascade delete | +| All nodes die | Total outage | Restore from binary cache | diff --git a/docs/src/reference/security-design.md b/docs/src/reference/security-design.md new file mode 100644 index 0000000..3be5aea --- /dev/null +++ b/docs/src/reference/security-design.md @@ -0,0 +1,88 @@ +# Security Design + +Niphas security architecture: threat model, RBAC, pod security, network policies, and defense in depth. + +## Threat Model + +| Threat | Mitigation | +|--------|-----------| +| Compromised binary cache | Ed25519 signature verification on every NAR | +| Malicious flakeRef (arbitrary Nix code) | Flake allowlist + eval sandbox (4 layers) | +| Rogue mesh peer | Noise XX mutual auth + PeerId allowlist | +| Privilege escalation from CSI mount | Read-only bind mounts, `MS_NOSUID`, `MS_NODEV` | +| Lateral movement via RBAC | Minimal per-component RBAC, least privilege | + +## RBAC + +Each component has the minimum RBAC required: + +| Component | Scope | Access | +|-----------|-------|--------| +| niphas-operator | ClusterRole | NiphasWorkload CRUD, Deployments, PDBs, Pods, Events | +| niphas-eval | ClusterRole | NiphasWorkload read/update, Events | +| niphas-csi | **None** | Zero K8s API access | +| niphas-mesh | ClusterRole | Read-only NiphasWorkload, Pods, Nodes | + +## Pod Security + +**CSI DaemonSet** (only privileged component): +- `privileged=true` — required for Bidirectional mount propagation +- `runAsUser=0` +- `readOnlyRootFilesystem=true` + +**All other components:** +- `runAsNonRoot=true`, `runAsUser=65534` +- `allowPrivilegeEscalation=false` +- `readOnlyRootFilesystem=true` +- `capabilities: drop: [ALL]` +- `seccompProfile: RuntimeDefault` + +## Network Policies + +Default deny all. Explicit allow per component: + +| Component | Allowed Egress | +|-----------|---------------| +| operator | K8s API (443/6443), DNS | +| eval | Git HTTPS (443), binary cache HTTPS, DNS | +| csi | Binary cache HTTPS, mesh peer (4001), DNS | +| mesh | Mesh peers (4001 TCP+UDP), CSI socket, K8s API, DNS | + +## Eval Sandboxing (4 Layers) + +1. **Nix evaluator settings:** `sandbox=true`, `restrict_eval=true`, `allow_import_from_derivation=false`, `max_jobs=0` +2. **Flake allowlist:** deny-by-default glob matching before evaluator invoked +3. **Container isolation:** non-root, no capabilities, read-only rootfs, resource limits +4. **Network isolation:** NetworkPolicy allows only git/binary cache HTTPS and DNS + +`allow_import_from_derivation=false` is critical — it prevents evaluation from triggering builds. + +## Mount Isolation + +- Symlink validation: rejects symlinks pointing outside `/nix/store/` or relative escapes +- Mount flags: `MS_BIND | MS_RDONLY | MS_NOSUID | MS_NODEV` +- Target path validation: must be within `/var/lib/kubelet/pods/` + +## Mesh Authentication + +- libp2p Noise XX handshake (mutual authentication, perfect forward secrecy) +- Closed mesh: PeerId allowlist from K8s API watch +- Keys generated on first boot, stored in K8s Secret per node + +## Secrets Management + +| Secret | Storage | +|--------|---------| +| Binary cache private keys | External Secrets Operator (Vault, AWS SM) | +| Binary cache public keys | ConfigMap | +| TLS certificates | cert-manager | +| Mesh identity keys | K8s Secret per node | + +Kubernetes Secret encryption at rest is required. + +## Container Images + +- Scratch/distroless base (static musl binaries) +- Read-only root filesystem +- Non-root where possible +- No shell, no package manager diff --git a/docs/src/reference/security.md b/docs/src/reference/security.md new file mode 100644 index 0000000..71bf2a8 --- /dev/null +++ b/docs/src/reference/security.md @@ -0,0 +1,21 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report security vulnerabilities via email to **security@niphas.io**. + +- Expect a response within 48 hours +- Fix targeted within 30 days +- Coordinated vulnerability disclosure + +**Do not open public GitHub issues for security vulnerabilities.** + +## Supported Versions + +| Version | Supported | +|---------|-----------| +| 0.1.x | Yes | + +## Disclosure Policy + +We follow coordinated vulnerability disclosure. After a fix is released, the vulnerability details will be published with credit to the reporter. diff --git a/docs/src/reference/testing.md b/docs/src/reference/testing.md new file mode 100644 index 0000000..5d80695 --- /dev/null +++ b/docs/src/reference/testing.md @@ -0,0 +1,93 @@ +# Testing Strategy + +Testability patterns and test architecture for the niphas codebase. + +## Current State + +~4,500 lines of Rust, 32 tests covering only parsing and crypto. Zero tests for operator, CSI, and eval pipeline. Root cause: logic mixed with IO, making it untestable without real infrastructure. + +## Approach: Sans-IO + Trait Injection + +Separate pure logic from side effects. Extract traits for IO boundaries, use fakes (not mocks) in tests. + +### Three Core Traits + +```rust +// Binary cache interaction +trait BinaryCacheClient { + async fn fetch_narinfo(&self, hash: &str) -> Result; + async fn fetch_nar(&self, url: &str) -> Result; +} + +// CSI mount operations +trait MountOps { + fn bind_mount(&self, source: &Path, target: &Path) -> Result<()>; + fn unmount(&self, target: &Path) -> Result<()>; +} + +// Nix evaluation +trait NixEval { + async fn evaluate(&self, req: &EvalRequest) -> Result; +} +``` + +Fakes implement simplified logic — they work rather than just verify calls. More robust to refactoring. + +## Test Tiers + +### Tier 1 — Fast (every commit) + +- No network, no K8s, no root, no nix +- Fakes, builders, snapshots, property tests +- Target: less than 5s, ~100 tests +- Run: `cargo test --workspace` + +### Tier 2 — Integration (CI only) + +- Requires kind cluster, nix binary, root +- Real CSI mounts, actual eval calls +- Run: `cargo test --workspace -- --ignored` + +## Patterns + +### Test Fixtures — Builder Pattern + +```rust +WorkloadBuilder::new("test-app") + .flake_ref("github:test/app") + .attribute("packages.x86_64-linux.default") + .replicas(3) + .build() +``` + +Sensible defaults, chainable methods, feature-gated `testutils` module. + +### Snapshot Testing (insta) + +Capture complex outputs (JSON Kubernetes resources) as snapshots. First run creates the snapshot, subsequent runs compare. Use redactions for non-deterministic fields (UIDs, timestamps). + +### Property Testing (proptest) + +Generate valid inputs and test invariants: +- Roundtrip: `parse(display(x)) == x` +- No-panic: random inputs don't crash parsers +- Forbidden patterns: outputs never contain injection vectors + +### kube-rs Operator Testing + +Use `tower_test` mock client. Inject `mock::Handle` into `kube::Client`. Verify API calls in an async task. + +### Axum Handler Testing + +Use `tower::ServiceExt::oneshot` to call handlers directly without HTTP transport. + +## Expected Results + +| Metric | Before | After | +|--------|--------|-------| +| Tier 1 tests | 32 | ~100 | +| Crates with tests | 2/5 | 4/5 | +| Tier 1 runtime | less than 1s | less than 5s | +| Traits extracted | 0 | 3 | +| Snapshot tests | 0 | ~15 | +| Property tests | 0 | ~8 | diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6c7909e --- /dev/null +++ b/flake.lock @@ -0,0 +1,114 @@ +{ + "nodes": { + "crane": { + "locked": { + "lastModified": 1780532242, + "narHash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=", + "owner": "ipetkov", + "repo": "crane", + "rev": "59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1778781969, + "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=", + "owner": "vic", + "repo": "import-tree", + "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1781074563, + "narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1777168982, + "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-parts": "flake-parts", + "import-tree": "import-tree", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1781493707, + "narHash": "sha256-lzf7qdQWuiY0T9VEbfH2CmP1LZQAYooU/sZuSgEJEBk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "06f25b8e40805beb2121a4dae4cc37d6f981800f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/hack/kind-config.yaml b/hack/kind-config.yaml new file mode 100644 index 0000000..cebee6d --- /dev/null +++ b/hack/kind-config.yaml @@ -0,0 +1,5 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + - role: worker diff --git a/nix/devShell.nix b/nix/devShell.nix index ddb8552..66cefc6 100644 --- a/nix/devShell.nix +++ b/nix/devShell.nix @@ -12,9 +12,16 @@ rustToolchain pkgs.pkg-config pkgs.protobuf + pkgs.clang + pkgs.lld + pkgs.git pkgs.cargo-deny pkgs.cargo-nextest pkgs.cargo-watch + pkgs.kubectl + pkgs.kubernetes-helm + pkgs.kind + pkgs.mdbook ]; buildInputs = [ @@ -26,6 +33,13 @@ PROTOC = "${pkgs.protobuf}/bin/protoc"; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ + pkgs.openssl + pkgs.zstd + pkgs.xz + pkgs.bzip2 + ]; + shellHook = '' echo "niphas devShell ready" ''; diff --git a/nix/docs.nix b/nix/docs.nix new file mode 100644 index 0000000..68dd3e8 --- /dev/null +++ b/nix/docs.nix @@ -0,0 +1,41 @@ +{ self, ... }: +{ + perSystem = { pkgs, ... }: + let + docs-site = pkgs.stdenvNoCC.mkDerivation { + name = "niphas-docs"; + src = self; + nativeBuildInputs = [ pkgs.mdbook ]; + buildPhase = "mdbook build docs"; + installPhase = '' + mkdir -p $out + cp -r docs/book/* $out/ + ''; + }; + in + { + packages = { + niphas-docs = pkgs.writeShellApplication { + name = "niphas-docs"; + runtimeInputs = [ pkgs.darkhttpd ]; + text = '' + PORT="''${PORT:-8080}" + echo "niphas docs: http://localhost:$PORT" + exec darkhttpd ${docs-site} --port "$PORT" + ''; + }; + + niphas-docs-site = docs-site; + + image-niphas-docs = pkgs.dockerTools.buildLayeredImage { + name = "ghcr.io/fullzer4/niphas-docs"; + tag = "dev"; + contents = [ pkgs.darkhttpd docs-site pkgs.cacert ]; + config = { + Entrypoint = [ "${pkgs.darkhttpd}/bin/darkhttpd" "${docs-site}" "--port" "8080" ]; + ExposedPorts = { "8080/tcp" = {}; }; + }; + }; + }; + }; +} diff --git a/nix/images.nix b/nix/images.nix new file mode 100644 index 0000000..0b3183d --- /dev/null +++ b/nix/images.nix @@ -0,0 +1,94 @@ +{ inputs, ... }: +{ + perSystem = { pkgs, self', system, ... }: + let + # Runtime shared libraries needed by all Rust binaries + runtimeLibs = [ + pkgs.openssl.out + pkgs.zstd.out + pkgs.xz.out + pkgs.bzip2.out + ]; + + runtimeLibPath = pkgs.lib.makeLibraryPath runtimeLibs; + + # Nix configuration for eval container (single-user, no sandbox) + nixConf = pkgs.writeTextDir "etc/nix/nix.conf" '' + sandbox = false + experimental-features = nix-command flakes + accept-flake-config = false + filter-syscalls = false + ''; + + mkImage = { name, pkg, extraPaths ? [], entrypoint }: + pkgs.dockerTools.buildLayeredImage { + inherit name; + tag = "dev"; + contents = [ + pkg + pkgs.cacert + pkgs.tzdata + ] ++ runtimeLibs ++ extraPaths; + config = { + Entrypoint = [ entrypoint ]; + Env = [ + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + "TZDIR=${pkgs.tzdata}/share/zoneinfo" + "LD_LIBRARY_PATH=${runtimeLibPath}" + ]; + }; + }; + in + { + packages = { + image-niphas-operator = mkImage { + name = "ghcr.io/fullzer4/niphas-operator"; + pkg = self'.packages.niphas-operator; + entrypoint = "/bin/niphas-operator"; + }; + + image-niphas-eval = mkImage { + name = "ghcr.io/fullzer4/niphas-eval"; + pkg = self'.packages.niphas-eval; + extraPaths = [ pkgs.nix pkgs.git nixConf ]; + entrypoint = "/bin/niphas-eval"; + }; + + image-niphas-csi = mkImage { + name = "ghcr.io/fullzer4/niphas-csi"; + pkg = self'.packages.niphas-csi; + extraPaths = [ pkgs.util-linux ]; + entrypoint = "/bin/niphas-csi"; + }; + + image-niphas-runner = pkgs.dockerTools.buildLayeredImage { + name = "ghcr.io/fullzer4/niphas-runner"; + tag = "dev"; + contents = [ + pkgs.busybox + pkgs.cacert + ]; + config = { + Entrypoint = [ "/bin/sh" ]; + Env = [ + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + ]; + }; + }; + + image-niphas-mock-eval = mkImage { + name = "ghcr.io/fullzer4/niphas-mock-eval"; + pkg = self'.packages.niphas-mock-eval; + entrypoint = "/bin/niphas-mock-eval"; + }; + + all-images = pkgs.linkFarm "niphas-all-images" [ + { name = "operator.tar.gz"; path = self'.packages.image-niphas-operator; } + { name = "eval.tar.gz"; path = self'.packages.image-niphas-eval; } + { name = "csi.tar.gz"; path = self'.packages.image-niphas-csi; } + { name = "runner.tar.gz"; path = self'.packages.image-niphas-runner; } + { name = "mock-eval.tar.gz"; path = self'.packages.image-niphas-mock-eval; } + ]; + }; + }; +} diff --git a/nix/packages.nix b/nix/packages.nix index 6069b9d..a9620f5 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -1,19 +1,29 @@ -{ inputs, ... }: +{ inputs, self, ... }: { perSystem = { pkgs, system, ... }: let rustToolchain = inputs.rust-overlay.packages.${system}.rust; craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain; - src = craneLib.cleanCargoSource (craneLib.path ../..); + protoFilter = path: _type: builtins.match ".*\.proto$" path != null; + srcFilter = path: type: + (protoFilter path type) || (craneLib.filterCargoSources path type); + + src = pkgs.lib.cleanSourceWith { + src = self; + filter = srcFilter; + }; commonArgs = { inherit src; + pname = "niphas"; strictDeps = true; nativeBuildInputs = [ pkgs.pkg-config pkgs.protobuf + pkgs.clang + pkgs.lld ]; buildInputs = [ @@ -27,12 +37,24 @@ }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; + + mkBin = name: craneLib.buildPackage (commonArgs // { + inherit cargoArtifacts; + cargoExtraArgs = "--bin ${name}"; + doCheck = false; + }); in { packages = { default = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); + + niphas-operator = mkBin "niphas-operator"; + niphas-eval = mkBin "niphas-eval"; + niphas-csi = mkBin "niphas-csi"; + niphas-crd-gen = mkBin "niphas-crd-gen"; + niphas-mock-eval = mkBin "niphas-mock-eval"; }; }; }