Skip to content

Commit 739c1c8

Browse files
committed
Enable use of clab k8s-kind
1 parent 63e83f8 commit 739c1c8

File tree

1 file changed

+51
-18
lines changed
  • netsim/templates/provider/clab

1 file changed

+51
-18
lines changed

netsim/templates/provider/clab/clab.j2

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,39 @@ topology:
1616
nodes:
1717
{% for name,n in nodes.items() if not (n.unmanaged|default(False)) %}
1818
{% set clab = n.clab|default({}) %}
19+
{% set kind = clab.kind | default(n.device) %}
20+
{% if kind == 'k8s-control-plane' %}
21+
{% set cluster_name = name.rsplit('-control-plane', 1)[0] %}
22+
{{ cluster_name }}:
23+
kind: k8s-kind
24+
{% if clab.image %}
25+
image: {{ clab.image }}
26+
{% endif %}
27+
startup-config: {{ cluster_name }}-config.yml
28+
extras:
29+
k8s_kind:
30+
deploy:
31+
wait: 0s
32+
{{ name }}:
33+
kind: ext-container
34+
{% for cset in defaults.providers.clab.node_config_attributes if clab[cset] is defined %}
35+
{% if clab[cset] is string %}
36+
{{ cset }}: '{{ clab[cset] }}'
37+
{% else %}
38+
{{ cset }}: {{ clab[cset] }}
39+
{% endif %}
40+
{% endfor %}
41+
{% elif kind == 'k8s-worker' %}
42+
{{ name }}:
43+
kind: ext-container
44+
{% for cset in defaults.providers.clab.node_config_attributes if clab[cset] is defined %}
45+
{% if clab[cset] is string %}
46+
{{ cset }}: '{{ clab[cset] }}'
47+
{% else %}
48+
{{ cset }}: {{ clab[cset] }}
49+
{% endif %}
50+
{% endfor %}
51+
{% else %}
1952
{{ name }}:
2053
{% if 'network-mode' in clab %}
2154
network-mode: {{ clab['network-mode'] }}
@@ -28,37 +61,37 @@ topology:
2861
mgmt-ipv6: {{ n.mgmt.ipv6 }}
2962
{% endif %}
3063
{% endif %}
31-
{% set kind = clab.kind | default(n.device) %}
3264
kind: {{ kind }}
33-
{% if kind == 'linux' and 'restart-policy' not in clab %}
65+
{% if kind == 'linux' and 'restart-policy' not in clab %}
3466
restart-policy: 'no'
35-
{% endif %}
36-
{% for cset in defaults.providers.clab.node_config_attributes if clab[cset] is defined %}
37-
{% if clab[cset] is string %}
67+
{% endif %}
68+
{% for cset in defaults.providers.clab.node_config_attributes if clab[cset] is defined %}
69+
{% if clab[cset] is string %}
3870
{{ cset }}: '{{ clab[cset] }}'
39-
{% else %}
71+
{% else %}
4072
{{ cset }}: {{ clab[cset] }}
41-
{% endif %}
42-
{% endfor %}
73+
{% endif %}
74+
{% endfor %}
4375
image: {{ clab.image|default(n.box) }}
4476
runtime: {{ clab.runtime|default(defaults.providers.clab.runtime) }}
45-
{% if groups is defined %}
77+
{% if groups is defined %}
4678
group: {% for g in groups if n.name in groups[g].members %}{{'' if loop.first else ','}}{{g}}{% endfor %}
4779

48-
{% endif %}
49-
{% if 'srl-agents' in clab %}
80+
{% endif %}
81+
{% if 'srl-agents' in clab %}
5082
extras:
5183
srl-agents: {{ clab['srl-agents'] }}
52-
{% endif %}
53-
{% if 'binds' in clab %}
84+
{% endif %}
85+
{% if 'binds' in clab %}
5486
binds:
55-
{% for bind_item in clab.binds %}
87+
{% for bind_item in clab.binds %}
5688
- {{ bind_item }}
57-
{% endfor %}
58-
{% endif %}
59-
{% if 'startup-config' in clab %}
60-
{% set cfg = clab['startup-config'] %}
89+
{% endfor %}
90+
{% endif %}
91+
{% if 'startup-config' in clab %}
92+
{% set cfg = clab['startup-config'] %}
6193
startup-config: {{ ("|\n" + cfg) | indent(8) if '\n' in cfg else cfg }}
94+
{% endif %}
6295
{% endif %}
6396
{% endfor %}
6497

0 commit comments

Comments
 (0)