Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s master table yang model #12331

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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 @@ -181,6 +182,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 @@ -2026,6 +2026,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,17 @@
{
"KUBERNETES_MASTER_WITH_CORRECT_VALUES": {
"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."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"KUBERNETES_MASTER_WITH_CORRECT_VALUES": {
"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_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": 10,
"port": "6443",
"disable": "False",
"insecure": "True"
}
}
}
}
}
60 changes: 60 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,60 @@
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";
type string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use IPAddress type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be IPAddress type and DNS domain type, currently use inet:host to cover both of them.

}

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

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be false too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently sonic join logic is to download k8a default ca.crt and combine it with local ame certificate, we get the kubeconfig credential. The default ca.crt is stored in k8s configmap, we download it from apiserver endpoint, and sonic impossibly have the default ca.crt, but if sonic want to establish secure connection with apiserver, sonic needs k8s default ca.crt. So, the downloading k8s default ca request can only be insecure currently. So, I set the default value "true".

}

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