Last active
April 6, 2017 11:57
-
-
Save ant31/b5867d152d5188915c4bf91fea826ffa to your computer and use it in GitHub Desktop.
jsonnet
This file contains 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
local kpm = import "kpm.libjsonnet"; | |
function( | |
params={} | |
) | |
# Overall file feels very like a basic json / yaml | |
# the wrapper function enforce a unique way to write manifests | |
# and provide many abstraction that user doesn't see | |
kpm.package({ | |
# Metadata section for indexing | |
package: { | |
name: "coreos/etcd", | |
expander: "jinja2", | |
author: "Antoine Legrand", | |
version: "3.0.6-1", | |
description: "etcd", | |
license: "MIT", | |
}, | |
# Default templated values | |
# Very 'yaml' like but can compose variables | |
variables: { | |
tag: "v3.0.6" | |
image: "quay.io/coreos/etcd:%s" % self.tag, # intuitive, yaml can't provide that | |
cluster_token: "etcd-cluster-1", | |
], | |
}, | |
# list files to deploy (it's only templating based) | |
resources: | |
[ | |
{ file: "etcd-member-dp.yaml", | |
name: "etcd", | |
shards: 3, | |
} | |
# shards:3 is an example of how hidding jsonnet power/complexity | |
# without it the corresponding code is : | |
[ { file: "etcd-member-%s.yaml" % pod_id, | |
name: "etcd-%s" % pod_id} for pod_id in [1,2,3]}] | |
# which would requires user to know about array comprehension | |
}, | |
], | |
}, params); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment