Skip to content

Commit

Permalink
Add k8s master table yang model (#12331)
Browse files Browse the repository at this point in the history
* Add k8s master table yang model

Signed-off-by: Yun Li <yunli1@microsoft.com>
  • Loading branch information
lixiaoyuner authored Oct 17, 2022
1 parent 094646c commit 51eac0b
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Table of Contents
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
* [FLEX_COUNTER_TABLE](#flex_counter_table)
* [KDUMP](#kdump)
* [Kubernetes Master](#kubernetes-master)
* [L2 Neighbors](#l2-neighbors)
* [Loopback Interface](#loopback-interface)
* [LOSSLESS_TRAFFIC_PATTERN](#LOSSLESS_TRAFFIC_PATTERN)
Expand Down Expand Up @@ -936,6 +937,27 @@ instance is supported in SONiC.
```

### Kubernetes Master

Kubernetes Master related configurations are stored in
**KUBERNETES_MASTER** table. These configurations are used mainly
for CTRMGR service. CTRMGR service will interactive with
kubernetes master according to these configurations.

```
{
"KUBERNETES_MASTER": {
"SERVER": {
"disable": "False",
"insecure": "True",
"ip": "k8s.apiserver.com",
"port": "6443"
}
}
}
```

### L2 Neighbors

The L2 neighbor and connection information can be configured in
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def run(self):
'./yang-models/sonic-system-defaults.yang',
'./yang-models/sonic-interface.yang',
'./yang-models/sonic-kdump.yang',
'./yang-models/sonic-kubernetes_master.yang',
'./yang-models/sonic-loopback-interface.yang',
'./yang-models/sonic-lossless-traffic-pattern.yang',
'./yang-models/sonic-mgmt_interface.yang',
Expand Down Expand Up @@ -185,6 +186,7 @@ def run(self):
'./cvlyang-models/sonic-system-defaults.yang',
'./cvlyang-models/sonic-interface.yang',
'./cvlyang-models/sonic-kdump.yang',
'./cvlyang-models/sonic-kubernetes_master.yang',
'./cvlyang-models/sonic-loopback-interface.yang',
'./cvlyang-models/sonic-mgmt_interface.yang',
'./cvlyang-models/sonic-mgmt_port.yang',
Expand Down
8 changes: 8 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,14 @@
"nexthop": "10.184.229.212",
"nexthop-vrf": "default"
}
},
"KUBERNETES_MASTER": {
"SERVER": {
"disable": "True",
"insecure": "False",
"ip": "kubernetes.apiserver.com",
"port": "6443"
}
}
},
"SAMPLE_CONFIG_DB_UNKNOWN": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"KUBERNETES_MASTER_WITH_CORRECT_VALUES_IP": {
"desc": "CONFIG KUBERNETES_MASTER TABLE WITH ALL THE CORRECT VALUES"
},
"KUBERNETES_MASTER_WITH_CORRECT_VALUES_DNS": {
"desc": "CONFIG KUBERNETES_MASTER TABLE WITH ALL THE CORRECT VALUES"
},
"KUBERNETES_MASTER_WITH_INVALID_BOOLEAN_TYPE" : {
"desc": "Referring invalid kubernetes_master boolean types.",
"eStrKey": "Pattern",
"eStr": ["false|true|False|True"]
},
"KUBERNETES_MASTER_INVALID_PORT": {
"desc": "Configure invalid PORT in kubernetes_master.",
"eStrKey": "InvalidValue"
},
"KUBERNETES_MASTER_INVALID_IP" : {
"desc": "Configure invalid IP in kubernetes_master.",
"eStrKey": "InvalidValue",
"eStr": ["ip"]
},
"KUBERNETES_MASTER_INVALID_DNS" : {
"desc": "Configure invalid DNS in kubernetes_master.",
"eStrKey": "InvalidValue",
"eStr": ["ip"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"KUBERNETES_MASTER_WITH_CORRECT_VALUES_IP": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "192.168.122.11",
"port": "6443",
"disable": "False",
"insecure": "True"
}
}
}
},
"KUBERNETES_MASTER_WITH_CORRECT_VALUES_DNS": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "k8s.apiserver.com",
"port": "6443",
"disable": "False",
"insecure": "True"
}
}
}
},
"KUBERNETES_MASTER_WITH_INVALID_BOOLEAN_TYPE": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "192.168.122.11",
"port": "6443",
"disable": "FAlse",
"insecure": "True"
}
}
}
},
"KUBERNETES_MASTER_INVALID_PORT": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "192.168.122.11",
"port": "65536",
"disable": "False",
"insecure": "True"
}
}
}
},
"KUBERNETES_MASTER_INVALID_IP": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "2001:aa:aa:aa",
"port": "6443",
"disable": "False",
"insecure": "True"
}
}
}
},
"KUBERNETES_MASTER_INVALID_DNS": {
"sonic-kubernetes_master:sonic-kubernetes_master": {
"sonic-kubernetes_master:KUBERNETES_MASTER": {
"sonic-kubernetes_master:SERVER": {
"ip": "k8s@.apiserver.com",
"port": "6443",
"disable": "False",
"insecure": "True"
}
}
}
}
}
62 changes: 62 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-kubernetes_master.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module sonic-kubernetes_master {

yang-version 1.1;

namespace "http://github.com/Azure/sonic-kubernetes_master";
prefix kubernetes_master;

import ietf-inet-types {
prefix inet;
}

import sonic-types {
prefix stypes;
}

description "KUBERNETES_MASTER YANG Module for SONiC OS";

revision 2022-10-09 {
description "First Revision";
}

container sonic-kubernetes_master {

container KUBERNETES_MASTER {

description "KUBERNETES_MASTER part of config_db.json";

container SERVER {

leaf ip {
description "Kubernetes api server endpoint(an IP address or a DNS
domain name.)";
type inet:host;
}

leaf port {
description "Kubernetes api server port";
type inet:port-number;
default 6443;
}

leaf disable {
description "This configuration identicates whether disable kubernetes";
type stypes:boolean_type;
default "false";
}

leaf insecure {
description "This configuration identicates it will download kubernetes
CA by http other than https";
type stypes:boolean_type;
default "true";
}

}
/* end of container SERVER */
}
/* end of container KUBERNETES_MASTER */
}
/* end of top level container */
}
/* end of module sonic-kubernetes_master */

0 comments on commit 51eac0b

Please sign in to comment.