diff --git a/.gitignore b/.gitignore index efa74dd744b..31b37d1eab0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ sky/clouds/service_catalog/data_fetchers/*.csv .vscode/ .idea/ .env + +# For editor files +*.swp diff --git a/sky/provision/kubernetes/network_utils.py b/sky/provision/kubernetes/network_utils.py index 844f84a04f5..b2de231005c 100644 --- a/sky/provision/kubernetes/network_utils.py +++ b/sky/provision/kubernetes/network_utils.py @@ -75,6 +75,8 @@ def fill_loadbalancer_template(namespace: str, service_name: str, with open(template_path, 'r', encoding='utf-8') as fin: template = fin.read() + annotations = skypilot_config.get_nested( + ('kubernetes', 'custom_metadata', 'annotations'), {}) j2_template = jinja2.Template(template) cont = j2_template.render( namespace=namespace, @@ -82,6 +84,7 @@ def fill_loadbalancer_template(namespace: str, service_name: str, ports=ports, selector_key=selector_key, selector_value=selector_value, + annotations=annotations, ) content = yaml.safe_load(cont) return content diff --git a/sky/templates/kubernetes-loadbalancer.yml.j2 b/sky/templates/kubernetes-loadbalancer.yml.j2 index 08d8b0cc64c..256f36236d4 100644 --- a/sky/templates/kubernetes-loadbalancer.yml.j2 +++ b/sky/templates/kubernetes-loadbalancer.yml.j2 @@ -5,6 +5,10 @@ service_spec: name: {{ service_name }} labels: parent: skypilot + annotations: + {%- for key, value in annotations.items() %} + {{ key }}: {{ value|tojson }} + {%- endfor %} spec: type: LoadBalancer selector: