Create local overrides to application configurations
Applications in ksonnet that are version controlled with Git can have local overrides.
Overrides provide a way to modify ksonnet environments locally without changing the settings in version control.
This is useful for testing locally in parallel with working on changes to be shared.
Create a new environment with an
--override flag. The environment will use the current kubeconfig context unless specified otherwise.
A new config file called
app.override.yaml should be available in the root of the ksonnet application. This file automatically added to
.gitignore and will not be tracked by Git.
If an existing environment conflicts with an override, the override take takes priority.
For example, the
default environment name can be overridden with a different server address, k8s version, or namespace.
$ ks init app $ ks env list NAME OVERRIDE KUBERNETES-VERSION NAMESPACE SERVER ==== ======== ================== ========= ====== default v1.10.0 default https://192.168.99.100:8443 $ ks env add default --override --server https://192.168.99.101:8443 --api-spec version:v1.8.0 $ ks env list NAME OVERRIDE KUBERNETES-VERSION NAMESPACE SERVER ==== ======== ================== ========= ====== default * v1.8.0 default https://192.168.99.101:8443
Environments created from an override will be marked with an asterisk. Create an environment override with the shorter
$ ks init app $ ks env add testing -o $ ks env list NAME OVERRIDE KUBERNETES-VERSION NAMESPACE SERVER ==== ======== ================== ========= ====== default v1.10.0 default https://192.168.99.100:8443 testing * v1.10.0 default https://192.168.99.100:8443
app.override.yaml shows it is quite similar to
app.yaml. Adding a registry or environment targets can be done with overrides.
app.override.yaml will capture that information as registry/targets are added or removed.
Adding a registry to an overridden environment will modify the registry reference to
$ ks registry add incubator https://github.com/ksonnet/parts/tree/master/incubator -o
Observe how the registry name, protocol, and URI are added to
The override flag must be passed explicitly in order to remove an environment from an override.
$ ks env rm testing INFO Deleting environment "testing" with metadata at path "$HOME/app/environments/testing" ERROR environment "testing" does not exist $ ks env rm testing -o INFO Deleting environment "testing" with metadata at path "$HOME/app/environments/testing" INFO Successfully removed environment 'testing'
Overrides provide a quick way to leverage existing ksonnet applications in a testing environment while having minimal impact to the application.