Skip to content

Commit 981f15e

Browse files
committed
Update konfig module to v0.14.0
Signed-off-by: Mikhail Zholobov <[email protected]>
1 parent d75a536 commit 981f15e

29 files changed

+347
-33
lines changed

konfig/docs/konfig.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ ServerBackend converts the user-written front-end model `Server` into a collecti
160160
|**provider**|[]|||
161161
|**sidecarContainers**|[{str:}]|||
162162
|**workloadAttributes** `required`|{str:}||{<br /> metadata = utils.MetadataBuilder(config) \| {<br /> name = workloadName<br /> }<br /> spec = {<br /> replicas = config.replicas<br /> if config.useBuiltInSelector:<br /> selector: {matchLabels: app.selector \| config.selector \| _applicationLabel}<br /> else:<br /> selector: {matchLabels: config.selector}<br /> template = {<br /> metadata = {<br /> if config.useBuiltInLabels:<br /> labels = app.labels \| _applicationLabel<br /> <br /> **config.podMetadata<br /> }<br /> spec = {<br /> containers = [mainContainer] + (sidecarContainers or [])<br /> initContainers = initContainers<br /> if config.volumes:<br /> volumes = [utils.to_kube_volume(v) for v in config.volumes if v.volumeSource]<br /> <br /> if config.serviceAccount:<br /> serviceAccountName = config.serviceAccount.name<br /> <br /> }<br /> }<br /> }<br />}|
163-
|**workloadName** `required`|str||config.name or "{}{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()|
163+
|**workloadName** `required`|str||config.name or "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()|
164164
### Job
165165

166166
Job is the common user interface for one-time jobs, which is defined by Kubernetes Job. Job supports reliable parallel execution of Pods.
@@ -634,8 +634,8 @@ Resource describes the compute resource requirements.
634634
| name | type | description | default value |
635635
| --- | --- | --- | --- |
636636
|**cpu**|int \| units.NumberMultiplier|A Container-level attribute.<br />CPU, in cores, default 1 core. (500m = .5 cores)|1|
637-
|**disk**|str \| units.NumberMultiplier|A Container-level attribute.<br />Local disk storage, in bytes, default 10Gi. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)|10Gi|
638-
|**memory**|str \| units.NumberMultiplier|A Container-level attribute.<br />Memory, in bytes, default 1024Mi. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)|1024Mi|
637+
|**disk**|units.NumberMultiplier|A Container-level attribute.<br />Local disk storage, in bytes, default 10Gi. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)|10Gi|
638+
|**memory**|units.NumberMultiplier|A Container-level attribute.<br />Memory, in bytes, default 1024Mi. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)|1024Mi|
639639
#### Examples
640640

641641
```

konfig/kcl.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "konfig"
3-
version = "0.11.0"
3+
version = "0.14.0"
44
description = "Konfig provides users with an out-of-the-box, highly abstract configuration interface. The original starting point of the model library is to improve the efficiency and experience of YAML users. We hope to simplify the writing of user-side configuration code by abstracting and encapsulating the model with more complex code into a unified model."
55

66
[dependencies]

konfig/kcl.mod.lock

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
name = "k8s"
44
full_name = "k8s_1.31.2"
55
version = "1.31.2"
6+
sum = "xBZgPsnpVVyWBpahuPQHReeRx28eUHGFoaPeqbct+vs="
7+
reg = "ghcr.io"
8+
repo = "kcl-lang/k8s"
9+
oci_tag = "1.31.2"

konfig/models/kube/backend/job_backend.k

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ schema JobBackend[inputConfig: frontend.Job]:
1717
config: frontend.Job = inputConfig
1818

1919
# variables
20-
jobName: str = "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()
20+
jobName: str = config.name or "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()
21+
jobNamespace: str = config.namespace or "{}-{}".format(metadata.__META_APP_NAMESPACE, metadata.__META_ENV_TYPE_NAME).lower()
2122
app: utils.ApplicationBuilder = utils.ApplicationBuilder {}
2223
mainContainerDict: {str:}
2324
mainContainer: {str:}
@@ -31,7 +32,7 @@ schema JobBackend[inputConfig: frontend.Job]:
3132
mainContainerDict = {
3233
**config.mainContainer
3334
if config.mainContainer.useBuiltInEnv:
34-
env += app.envs
35+
env = config.mainContainer.env | app.envs
3536
name = config.mainContainer.name or "main"
3637
image = config.image
3738
resource = config?.schedulingStrategy?.resource
@@ -48,6 +49,7 @@ schema JobBackend[inputConfig: frontend.Job]:
4849
jobAttrs: {str:} = {
4950
metadata = utils.MetadataBuilder(config) | {
5051
name = jobName
52+
namespace = jobNamespace
5153
}
5254
spec = {
5355
activeDeadlineSeconds = config.activeDeadlineSeconds

konfig/models/kube/backend/server_backend.k

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ schema ServerBackend[inputConfig: server.Server]:
2424
# Store the input config parameter, ensure it can be seen in protocol and mixin.
2525
config: server.Server = inputConfig
2626
# Workload name.
27-
workloadName: str = config.name or "{}{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()
27+
workloadName: str = config.name or "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower()
28+
# Workload namespace
29+
workloadNamespace: str = config.namespace or "{}-{}".format(metadata.__META_APP_NAMESPACE, metadata.__META_ENV_TYPE_NAME).lower()
2830
# App variable contains labels, selector and environments.
2931
app: utils.ApplicationBuilder = utils.ApplicationBuilder {}
3032
# Main containers and sidecar contrainers.
@@ -39,7 +41,7 @@ schema ServerBackend[inputConfig: server.Server]:
3941
mainContainer = utils.volume_patch(config.volumes, [utils.ContainerFrontend2Kube({
4042
**config.mainContainer
4143
if config.mainContainer.useBuiltInEnv:
42-
env += app.envs
44+
env = config.mainContainer.env | app.envs
4345
name = config.mainContainer.name or "main"
4446
image = config.image
4547
resource = config?.schedulingStrategy?.resource
@@ -58,6 +60,7 @@ schema ServerBackend[inputConfig: server.Server]:
5860
workloadAttributes: {str:} = {
5961
metadata = utils.MetadataBuilder(config) | {
6062
name = workloadName
63+
namespace = workloadNamespace
6164
}
6265
spec = {
6366
replicas = config.replicas
@@ -79,6 +82,8 @@ schema ServerBackend[inputConfig: server.Server]:
7982
]
8083
if config.serviceAccount:
8184
serviceAccountName = config.serviceAccount.name
85+
if config.affinity:
86+
affinity = config.affinity
8287
}
8388
}
8489
if config.deploymentStrategy:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
This is the affinity module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema Affinity:
9+
r"""
10+
Affinity is a group of affinity scheduling rules.
11+
12+
Attributes
13+
----------
14+
nodeAffinity : NodeAffinity, default is Undefined, optional
15+
Describes node affinity scheduling rules for the pod.
16+
podAffinity : PodAffinity, default is Undefined, optional
17+
Describes pod affinity scheduling rules (e.g. co-locate this pod in the same node, zone, etc. as some other pod(s)).
18+
podAntiAffinity : PodAntiAffinity, default is Undefined, optional
19+
Describes pod anti-affinity scheduling rules (e.g. avoid putting this pod in the same node, zone, etc. as some other pod(s)).
20+
"""
21+
22+
23+
nodeAffinity?: NodeAffinity
24+
25+
podAffinity?: PodAffinity
26+
27+
podAntiAffinity?: PodAntiAffinity
28+
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
This is the node_affinity module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema NodeAffinity:
9+
r"""
10+
Node affinity is a group of node affinity scheduling rules.
11+
12+
Attributes
13+
----------
14+
preferredDuringSchedulingIgnoredDuringExecution : [PreferredSchedulingTerm], default is Undefined, optional
15+
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.
16+
requiredDuringSchedulingIgnoredDuringExecution : NodeSelector, default is Undefined, optional
17+
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.
18+
"""
19+
20+
21+
preferredDuringSchedulingIgnoredDuringExecution?: [PreferredSchedulingTerm]
22+
23+
requiredDuringSchedulingIgnoredDuringExecution?: NodeSelector
24+
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
This is the node_selector module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema NodeSelector:
9+
r"""
10+
A node selector represents the union of the results of one or more label queries over a set of nodes; that is, it represents the OR of the selectors represented by the node selector terms.
11+
12+
Attributes
13+
----------
14+
nodeSelectorTerms : [NodeSelectorTerm], default is Undefined, required
15+
Required. A list of node selector terms. The terms are ORed.
16+
"""
17+
18+
19+
nodeSelectorTerms: [NodeSelectorTerm]
20+
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
This is the node_selector_requirement module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema NodeSelectorRequirement:
9+
r"""
10+
A node selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
11+
12+
Attributes
13+
----------
14+
key : str, default is Undefined, required
15+
The label key that the selector applies to.
16+
operator : str, default is Undefined, required
17+
Represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
18+
values : [str], default is Undefined, optional
19+
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.
20+
"""
21+
22+
23+
key: str
24+
25+
operator: str
26+
27+
values?: [str]
28+
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
This is the node_selector_term module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema NodeSelectorTerm:
9+
r"""
10+
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.
11+
12+
Attributes
13+
----------
14+
matchExpressions : [NodeSelectorRequirement], default is Undefined, optional
15+
A list of node selector requirements by node's labels.
16+
matchFields : [NodeSelectorRequirement], default is Undefined, optional
17+
A list of node selector requirements by node's fields.
18+
"""
19+
20+
21+
matchExpressions?: [NodeSelectorRequirement]
22+
23+
matchFields?: [NodeSelectorRequirement]
24+
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
This is the pod_affinity module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema PodAffinity:
9+
r"""
10+
Pod affinity is a group of inter pod affinity scheduling rules.
11+
12+
Attributes
13+
----------
14+
preferredDuringSchedulingIgnoredDuringExecution : [WeightedPodAffinityTerm], default is Undefined, optional
15+
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.
16+
requiredDuringSchedulingIgnoredDuringExecution : [PodAffinityTerm], default is Undefined, optional
17+
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.
18+
"""
19+
20+
21+
preferredDuringSchedulingIgnoredDuringExecution?: [WeightedPodAffinityTerm]
22+
23+
requiredDuringSchedulingIgnoredDuringExecution?: [PodAffinityTerm]
24+
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
This is the pod_affinity_term module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
import k8s.apimachinery.pkg.apis.meta.v1
7+
8+
9+
schema PodAffinityTerm:
10+
r"""
11+
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 <topologyKey> matches that of any node on which a pod of the set of pods is running
12+
13+
Attributes
14+
----------
15+
labelSelector : v1.LabelSelector, default is Undefined, optional
16+
A label query over a set of resources, in this case pods. If it's null, this PodAffinityTerm matches with no Pods.
17+
matchLabelKeys : [str], default is Undefined, optional
18+
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. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
19+
mismatchLabelKeys : [str], default is Undefined, optional
20+
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. This is a beta field and requires enabling MatchLabelKeysInPodAffinity feature gate (enabled by default).
21+
namespaceSelector : v1.LabelSelector, default is Undefined, optional
22+
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.
23+
namespaces : [str], default is Undefined, optional
24+
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".
25+
topologyKey : str, default is Undefined, required
26+
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.
27+
"""
28+
29+
30+
labelSelector?: v1.LabelSelector
31+
32+
matchLabelKeys?: [str]
33+
34+
mismatchLabelKeys?: [str]
35+
36+
namespaceSelector?: v1.LabelSelector
37+
38+
namespaces?: [str]
39+
40+
topologyKey: str
41+
42+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
This is the pod_anti_affinity module in k8s.api.core.v1 package.
3+
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
4+
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
5+
"""
6+
7+
8+
schema PodAntiAffinity:
9+
r"""
10+
Pod anti affinity is a group of inter pod anti affinity scheduling rules.
11+
12+
Attributes
13+
----------
14+
preferredDuringSchedulingIgnoredDuringExecution : [WeightedPodAffinityTerm], default is Undefined, optional
15+
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 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.
16+
requiredDuringSchedulingIgnoredDuringExecution : [PodAffinityTerm], default is Undefined, optional
17+
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.
18+
"""
19+
20+
21+
preferredDuringSchedulingIgnoredDuringExecution?: [WeightedPodAffinityTerm]
22+
23+
requiredDuringSchedulingIgnoredDuringExecution?: [PodAffinityTerm]
24+
25+

0 commit comments

Comments
 (0)