Skip to content

Commit

Permalink
Merge pull request #59 from srl-labs/feat/config-resource-defaults
Browse files Browse the repository at this point in the history
Feat/config resource defaults
  • Loading branch information
carlmontanari authored Oct 21, 2023
2 parents e82aad1 + 2bebd06 commit 0c23269
Show file tree
Hide file tree
Showing 29 changed files with 612 additions and 68 deletions.
9 changes: 9 additions & 0 deletions .develop/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ pipelines:
create_deployments --all
start_dev --all
deploy:
# override the default dev pipeline to not bother building clabverter or dev image while doing
# deploy pipeline
run: |
run_dependencies --all
ensure_pull_secrets --all
build_images clabernetes clabernetes-launcher
create_deployments --all
purge:
run: |-
stop_dev --all
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ jobs:
- name: deploy clabernetes
run: devspace run deploy --profile debug

- name: wait for clabernetes
run: |
kubectl rollout status deployment clabernetes-manager -n clabernetes
- name: setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_e2e }}

- name: wait for clabernetes
run: |
kubectl rollout status deployment clabernetes-manager -n clabernetes
- name: run the e2e tests
id: run-the-e2e-tests
run: make test-e2e
Expand All @@ -102,8 +102,12 @@ jobs:
run: |
set -x
kubectl get pods -n clabernetes -o yaml
echo "\n********************************\n"
echo "********************************"
echo "**** events ****
echo "********************************"
kubectl get events -n clabernetes --sort-by='.lastTimestamp'
echo "\n********************************\n"
echo "********************************"
echo "**** logs ****
echo "********************************"
kubectl logs -l clabernetes/name=clabernetes-manager -n clabernetes --tail=-1
exit 1
9 changes: 9 additions & 0 deletions apis/topology/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

import (
k8scorev1 "k8s.io/api/core/v1"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -90,6 +91,14 @@ type TopologyCommonSpec struct {
// +kubebuilder:validation:Enum=disabled;critical;warn;info;debug
// +optional
LauncherLogLevel string `json:"launcherLogLevel,omitempty"`
// Resources is a mapping of nodeName (or "default") to kubernetes resource requirements -- any
// value set here overrides the "global" config resource definitions. If a key "default" is set,
// those resource values will be preferred over *all global settings* for this topology --
// meaning, the "global" resource settings will never be looked up for this topology, and any
// kind/type that is *not* in this resources map will have the "default" resources from this
// mapping applied.
// +optional
Resources map[string]k8scorev1.ResourceRequirements `json:"resources"`
}

// LinkEndpoint is a simple struct to hold node/interface name info for a given link.
Expand Down
8 changes: 8 additions & 0 deletions apis/topology/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions assets/crd/topology.clabernetes_containerlabs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,65 @@ spec:
- info
- debug
type: string
resources:
additionalProperties:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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
description: Resources is a mapping of nodeName (or "default") to
kubernetes resource requirements -- any value set here overrides
the "global" config resource definitions. If a key "default" is
set, those resource values will be preferred over *all global settings*
for this topology -- meaning, the "global" resource settings will
never be looked up for this topology, and any kind/type that is
*not* in this resources map will have the "default" resources from
this mapping applied.
type: object
required:
- config
type: object
Expand Down
59 changes: 59 additions & 0 deletions assets/crd/topology.clabernetes_knes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,65 @@ spec:
- info
- debug
type: string
resources:
additionalProperties:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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
description: Resources is a mapping of nodeName (or "default") to
kubernetes resource requirements -- any value set here overrides
the "global" config resource definitions. If a key "default" is
set, those resource values will be preferred over *all global settings*
for this topology -- meaning, the "global" resource settings will
never be looked up for this topology, and any kind/type that is
*not* in this resources map will have the "default" resources from
this mapping applied.
type: object
topology:
description: Topology is a "normal" kne topology proto file.
type: string
Expand Down
59 changes: 59 additions & 0 deletions charts/clabernetes/crds/topology.clabernetes_containerlabs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,65 @@ spec:
- info
- debug
type: string
resources:
additionalProperties:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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
description: Resources is a mapping of nodeName (or "default") to
kubernetes resource requirements -- any value set here overrides
the "global" config resource definitions. If a key "default" is
set, those resource values will be preferred over *all global settings*
for this topology -- meaning, the "global" resource settings will
never be looked up for this topology, and any kind/type that is
*not* in this resources map will have the "default" resources from
this mapping applied.
type: object
required:
- config
type: object
Expand Down
59 changes: 59 additions & 0 deletions charts/clabernetes/crds/topology.clabernetes_knes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,65 @@ spec:
- info
- debug
type: string
resources:
additionalProperties:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n 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
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
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
description: Resources is a mapping of nodeName (or "default") to
kubernetes resource requirements -- any value set here overrides
the "global" config resource definitions. If a key "default" is
set, those resource values will be preferred over *all global settings*
for this topology -- meaning, the "global" resource settings will
never be looked up for this topology, and any kind/type that is
*not* in this resources map will have the "default" resources from
this mapping applied.
type: object
topology:
description: Topology is a "normal" kne topology proto file.
type: string
Expand Down
8 changes: 8 additions & 0 deletions charts/clabernetes/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,11 @@ spec:
limits:
{{ toYaml .Values.manager.resources.limits | indent 14 }}
{{- end }}
ports:
- name: readiness-port
containerPort: 8080
readinessProbe:
httpGet:
path: /ready
port: readiness-port
successThreshold: 1
15 changes: 13 additions & 2 deletions charts/clabernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,19 @@ launcher:
logLevel: info

# default resources is a mapping of containerlab kind/type -> k8s resources/requests to apply to
# the launcher pod(s)
defaultResources: {}
# the launcher pod(s); note that the "default" keyword under the parent "defaultResources" key
# specifies the default/fallthrough resources -- this expects a normal looking k8s requests/limits
# block. the "byContainerlabKind" key holds a map[string]map[string]k8sresource mapping -- the
# outer keys are the containerlab *kind* and the inner keys *type* -- you can specify a "default"
# key in the types level as well to just have default resources for a given kind.
# for reference fields should be formatted like "normal" k8s resources:
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#example-1
defaultResources:
default:
requests:
memory: 512Mi
cpu: 200m
byContainerlabKind: {}

#
# clicker
Expand Down
Loading

0 comments on commit 0c23269

Please sign in to comment.