- ks init app
- cd ksapp
- ks registry add helm-stable https://kubernetes-charts.storage.googleapis.com
- ks pkg add helm-stable/redis
- ks generate helm-stable-redis redis
To get a list of the default values for a Helm Chart, you can use ks inspect values stable/redis. This will will return the values in YAML format. To override these values, use ks param set <component name> values.<value name> <new value>
- To update the count of redis slaves, run
ks param set redis values.cluster.slaveCount 3 - To add a pull secret, run
ks param set redis values.image.pullSecrets '["ourSecret"]'
You can view values with override values using ks param list and ks show default to review the configuration.
ksonnet uses params to allow users to have knobs to adjust their configurations. There are currently four types of parameters:
- component -
ks param set component name valueThese are the defaults. - component global (don't ever use this)
- environment -
ks param set component name value --env defaultThese override component parameters in an environment - environment global -
ks param set name value --env defaultThese are applied to every object created an environment
Param values can be one of the following:
- literal: string, float, int e.g.
1 - array: e.g.
[1,2,3,4] - object: e.g.
{"project": "engineering"}note enclose arrays and objects in single quotes to avoid the shell trying to interpret them.
ksonnet has the ability to apply configurations to every object in an environment. This can be used to annotate object ownership in a cluster.
ks param set metadata.labels '{"project": "engineering"}' --env default sets a project label on all created objects. You can view these options with ks env list default --env default
This feature is not fully baked. It does work with components that return arrays (as the redis example above does. This will be fixed by 0.12 release.
With ksonnet, you can apply any object transform allowed by Jsonnet. For instance, you could add a sidecar to all Deployments. To make this happen, we'll need a way to target objects created by Helm. Helm will always return a n array of Kubernetes objects, so we can build a API that can update this array. For instance.
// import ksonnet API as an extVar so we can change it as needed
local ksonnet = std.extVar("__ksonnet/api");
// an API that can add sidecars to deployments
local sidecarAPI = import("foo/bar/sidecar.jsonnet");
// helm renders our objects
local objects = std.prune(std.native(...));
// our custom update function to create a new, updated object
local update(obj) = obj + sidecarAPI
// this will return objects with the updated object
objects + ksonnet.withObject("extensions/v1beta1", "Deployment", "redis-slave", update)