Last active
September 26, 2017 00:05
-
-
Save evanlucas/2d6307b945486d219f814ab7e13afcbc to your computer and use it in GitHub Desktop.
k8s template examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{/* | |
Renders all urls as env variables. This is done so adding new | |
service-to-service talk doesn't require a template change | |
so Values.urls.member_service_url will be rendered as MEMBER_SERVICE_URL | |
env var. :p | |
*/}} | |
{{- define "env.urls" -}} | |
{{- range $key, $val := .Values.urls -}} | |
{{ $env_name := $key | upper }} | |
- name: {{ $env_name }} | |
value: {{ $val | quote }} | |
{{- end -}} | |
{{- end -}} | |
{{/* | |
Get the filename of the current template | |
*/}} | |
{{- define "filename" }} | |
{{- .Template.Name | base | replace ".yaml" "" -}} | |
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
urls: | |
member_service_url: http://member-service:9000 | |
visitor_service_url: http://visitor-service:9000 | |
biscuits_service_url: http://biscuits-service:9000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use it, just
{{- include "env.urls" . }}
inside theenv
block of your deployment's container template