Schema#
The initial step in integrating a device with SDC involves importing the device's schema. SDC is equipped to handle YANG schemas, provided all necessary model files and their respective dependencies are available in a git repository. This process is facilitated through the Schema CustomResource, detailed here.
The Schema CustomResource is configured using three main parameter groups:
- Source of Schema: Determined by
repoURL
,kind
, andref
parameters. - Schema Identification: Specified using
provider
andversion
parameters. - Schema Parsing Method: Configured through
models
,includes
, andexcludes
parameters.
Source of Schema: Repository Configuration#
To successfully retrieve the schema, it is essential for users to provide four key parameters: repoURL
, kind
, ref
and credentials
. These parameters jointly establish the methodology for schema acquisition:
repoURL
: This parameter is pivotal as it specifies the repository's URL where the schema is located.kind
: It determines the nature of the reference point within the repository, offering options between a "tag" or a "branch".ref
: This parameter is closely linked to kind and pinpoints the exact tag or branch name within the repository.credentials
: This parameter is point to a secret name in the same namespace as theschema
CR. It is required if your repository requires authentication e.g. a private repo.proxy
: This determines the proxy parameters to use if the git repo is behind a proxy
Following the identification of schema directories and files for download, the dirs
attribute plays a crucial role. It allows users to map each source directory to a corresponding local storage location. Essentially, dirs is an array comprising pairs of src
(source directory) and dst
(destination path). This setup facilitates the organization of downloaded schema files, ensuring they are stored in designated local directories for easy access and management.
If the dirs attribute is not set, it defaults to $pwd
for both src
and dst
.
Some vendors publish their primary YANG files in a central repository; however, included files may reside in separate repositories. To address this, the repository definition in the Schema Custom Resource Definition (CRD) allows for the specification of multiple repositories. This setup ensures that all components contributing to the schema are accessible and properly linked, even if they are stored across different locations.
Repository authentication#
If your schema repository requires authentication a secret of type kubernetes.io/basic-auth
is referenced in the schema CR. An Example of such secret is provided below.
username/password
Please fill out your own username and password/token
namespace
The secret MUST use the same namespace as the schema CR that is referencing it.
apiVersion: v1
kind: Secret
metadata:
name: personal-access-token
data:
username: <base64-encoded-username>
password: <base64-encoded-password>
type: kubernetes.io/basic-auth
Schema Identification: Naming Conventions#
The schema is uniquely identified through provider
and version
.
provider
: Contains details about the schema issuer, typically including vendor and chassis type.version
: Represents the specific version of the schema.
Schema Parsing Method: Handling YANG Models#
YANG schemas are comprised of several implemented models, some of which may have dependencies on other models. The `Schema`` CustomResource accommodates this complexity with specific parameters:
models
: Defines paths to files or directories containing the models implemented by the schema.includes
: Specifies paths to models that are imported as dependencies by the implemented models.excludes
: An optional list of regular expression parameters. It filters out specific models during the loading process based on matching criteria.
By carefully setting these parameters, users can seamlessly onboard devices into the SDC framework, ensuring that the schemas are accurately loaded and parsed.
Examples#
SR Linux v23.10.1#
The below CR defines an SR Linux Schema
version 23.10.1.
The YANG files will be retrieved from the github repo https://github.com/nokia/srlinux-yang-models
tag v23.10.1
. The remote directory srlinux-yang-models
at the roo level of the git repository will be mapped to $pwd
(dst: .
) in the local file system
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: srl.nokia.sdcio.dev-23.10.1
namespace: default
spec:
provider: srl.nokia.sdcio.dev
version: 23.10.1
repositories:
- repoURL: https://github.com/nokia/srlinux-yang-models
kind: tag
ref: v23.10.1
dirs:
- src: srlinux-yang-models
dst: .
schema:
models:
- srl_nokia/models
includes:
- ietf
- openconfig/extensions
- openconfig/openconfig-extensions.yang
excludes:
- .*tools.*
To apply the CR, store the above content in a file (e.g: srlinux_23.10.1_schema.yaml
) and run the command:
After applying the previous CR to a kubernetes cluster, the Schema
can be viewed with the commands:
Sample outputs:
$ kubectl get schemas.inv.sdcio.dev
NAME READY PROVIDER VERSION URL REF
srl.nokia.sdcio.dev-23.10.1 True srl.nokia.sdcio.dev 23.10.1 https://github.com/nokia/srlinux-yang-models v23.10.1
$ kubectl get schemas srl.nokia.sdcio.dev-23.10.1 -o yaml
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"inv.sdcio.dev/v1alpha1","kind":"Schema","metadata":{"annotations":{},"name":"srl.nokia.sdcio.dev-23.10.1","namespace":"default"},"spec":{"provider":"srl.nokia.sdcio.dev","repositories":[{"dirs":[{"dst":".","src":"srlinux-yang-models"}],"kind":"tag","ref":"v23.10.1","repoURL":"https://github.com/nokia/srlinux-yang-models","schema":{"excludes":[".*tools.*"],"includes":["ietf","openconfig/extensions","openconfig/openconfig-extensions.yang"],"models":["srl_nokia/models"]}}],"version":"23.10.1"}}
creationTimestamp: "2024-10-31T17:04:34Z"
finalizers:
- schema.inv.sdcio.dev/finalizer
generation: 2
name: srl.nokia.sdcio.dev-23.10.1
namespace: default
resourceVersion: "250684"
uid: beb741df-9273-43a5-bd92-dcd0293905b4
spec:
provider: srl.nokia.sdcio.dev
repositories:
- dirs:
- dst: .
src: srlinux-yang-models
kind: tag
proxy: {}
ref: v23.10.1
repoURL: https://github.com/nokia/srlinux-yang-models
schema:
excludes:
- .*tools.*
includes:
- ietf
- openconfig/extensions
- openconfig/openconfig-extensions.yang
models:
- srl_nokia/models
version: 23.10.1
status:
conditions:
- lastTransitionTime: "2024-10-31T17:04:36Z"
message: ""
reason: Ready
status: "True"
type: Ready
SROS 23.10.2#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: sros.nokia.sdcio.dev-23.10.1
namespace: default
spec:
provider: sros.nokia.sdcio.dev
version: 23.10.2
repositories:
- repoURL: https://github.com/nokia/7x50_YangModels
kind: tag
ref: sros_23.10.r2
dirs:
- src: YANG
dst: .
schema:
models:
- nokia-combined
includes:
- ietf
- nokia-sros-yang-extensions.yang
excludes: []
Juniper MX 23.2R1#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: mx.juniper.23.2r1
namespace: default
spec:
provider: mx.juniper.sdcio.dev
version: 23.2R1
repositories:
- repoURL: https://github.com/Juniper/yang
kind: branch
ref: master
dirs:
- src: 23.2/23.2R1/junos/conf
dst: junos
- src: 23.2/23.2R1/common
dst: common
schema:
models:
- junos
includes:
- common
Juniper QFX 23.2R1#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: qfx.juniper.23.2r1
namespace: default
spec:
provider: qfx.juniper.sdcio.dev
version: 23.2R1
repositories:
- repoURL: https://github.com/Juniper/yang
kind: branch
ref: master
dirs:
- src: 23.2/23.2R1/junos-qfx/conf
dst: junos
- src: 23.2/23.2R1/common
dst: common
schema:
models:
- junos
includes:
- common
Juniper EX 23.2R1#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: ex.juniper.23.2r1
namespace: default
spec:
provider: ex.juniper.sdcio.dev
version: 23.2R1
repositories:
- repoURL: https://github.com/Juniper/yang
kind: branch
ref: master
dirs:
- src: 23.2/23.2R1/junos-ex/conf
dst: junos
- src: 23.2/23.2R1/common
dst: common
schema:
models:
- junos
includes:
- common
Juniper NFX 23.2R1#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: nfx.juniper.23.2r1
namespace: default
spec:
provider: nfx.juniper.sdcio.dev
version: 23.2R1
repositories:
- repoURL: https://github.com/Juniper/yang
kind: branch
ref: master
dirs:
- src: 23.2/23.2R1/junos-nfx/conf
dst: junos
- src: 23.2/23.2R1/common
dst: common
schema:
models:
- junos
includes:
- common
Arista EOS 4.31.2.F#
apiVersion: inv.sdcio.dev/v1alpha1
kind: Schema
metadata:
name: eos.arista.4.31.2.f
namespace: default
spec:
provider: eos.arista.sdcio.dev
version: 4.31.2.F
repositories:
- repoURL: https://github.com/aristanetworks/yang
kind: branch
ref: master
dirs:
- src: EOS-4.31.2F
dst: .
schema:
models:
- release/openconfig/models
includes:
- openconfig/public/release/models
- iana/iana-if-type@2023-01-26.yang
- ietf/ietf-inet-types.yang
- ietf/ietf-interfaces.yang
- ietf/ietf-yang-types.yang
excludes:
- .*notsupported.*
- repoURL: https://github.com/YangModels/yang
kind: branch
ref: main
dirs:
- src: standard/ietf/RFC
dst: ietf
- src: standard/iana
dst: iana
schema:
models:
- iana/iana-if-type@2023-01-26.yang
- ietf/ietf-inet-types.yang
- ietf/ietf-interfaces.yang
- ietf/ietf-yang-types.yang