Skip to content

Commit

Permalink
propagate kubernetes custom annotations to the loadbalancer
Browse files Browse the repository at this point in the history
  • Loading branch information
fozziethebeat committed Jul 19, 2024
1 parent c0246ab commit 428ee5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ sky/clouds/service_catalog/data_fetchers/*.csv
.vscode/
.idea/
.env

# For editor files
*.swp
3 changes: 3 additions & 0 deletions sky/provision/kubernetes/network_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ 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,
service_name=service_name,
ports=ports,
selector_key=selector_key,
selector_value=selector_value,
annotations=annotations,
)
content = yaml.safe_load(cont)
return content
Expand Down
4 changes: 4 additions & 0 deletions sky/templates/kubernetes-loadbalancer.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 428ee5f

Please sign in to comment.