Skip to content

Instantly share code, notes, and snippets.

@ggolin
Created July 24, 2020 21:09
Show Gist options
  • Save ggolin/e326cdaee8687ae5f4825d12ea3eaad7 to your computer and use it in GitHub Desktop.
Save ggolin/e326cdaee8687ae5f4825d12ea3eaad7 to your computer and use it in GitHub Desktop.
#@ load("@ytt:data", "data")
#@ load("consts.star", "version", "comment")
#@ def cpus(n):
#@ return str(n)+"m"
#@ end
#@ def memorys(n):
#@ return "{}Mi".format(n)
#@ end
#! request_50m_per_factor — generates a resources request
#! given a scaling factor such that the limits are twice
#! the initial request.
#@ def request_50m_per_factor(factor):
#@ initial = { "cpu": 50*factor, "memory": 50*factor }
requests:
cpu: #@ cpus(initial["cpu"])
memory: #@ memorys(initial["memory"])
limits:
cpu: #@ cpus(2*initial["cpu"])
memory: #@ memorys(2*initial["memory"])
#@ end
#@ def labels(forSelecting=False):
app.kubernetes.io/component: controller
app.kubernetes.io/name: #@ data.values.app_name
#@ if not forSelecting:
app.kubernetes.io/version: #@ version
#@ end
#@ end
#@ def foo(secrets):
#@ for/end secret in secrets:
- name: #@ secret
secretRef:
name: #@ secret
#@ end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment