-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(prune): find old resources * fix: respect labels in unit test * feat(prune): faster querying Queries the required data a lot faster, by using kubectl more efficiently (one call vs a call for each kind). Can be possibly improved even further by running in parallel. * refactor(kubernetes): client.get() * feat: functional prune command Adds a `tk prune` command, that does what it promises. Prune is functionally complete now. * feat(prune): intelligently ignore objects * feat(prune): feature flag * doc: Garbage collection + Config reference * test: injectLabels
- Loading branch information
Showing
21 changed files
with
476 additions
and
101 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ func main() { | |
applyCmd(), | ||
showCmd(), | ||
diffCmd(), | ||
pruneCmd(), | ||
) | ||
|
||
rootCmd.AddCommand( | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
name: "Configuration Reference" | ||
route: "/config" | ||
--- | ||
|
||
# Configuration Reference | ||
|
||
Tanka's behavior can be customized per Environment using a file called `spec.json` | ||
|
||
## File format | ||
|
||
```json | ||
{ | ||
// Config format revision. Currently only "v1alpha1" | ||
"apiVersion": "v1alpha1", | ||
// Always "Environment". Reserved for future use | ||
"kind": "Environment", | ||
|
||
// Descriptive fields | ||
"metadata": { | ||
// Name of the Environment. Automatically set to the relative | ||
// path from the project root | ||
"name": "<string>", | ||
|
||
// Arbitrary key:value string pairs. Not parsed by Tanka | ||
"labels": { "<string>": "<string>" } | ||
}, | ||
|
||
// Properties influencing Tanka's behavior | ||
"spec": { | ||
// The Kubernetes cluster to use. | ||
// Must be the full URL, e.g. https://cluster.fqdn:6443 | ||
"apiServer": "<url>", | ||
|
||
// Default namespace for objects that don't explicitely specify one | ||
"namespace": "<string>" | default = "default", | ||
|
||
// diffStrategy to use. Automatically chosen by default based on | ||
// the availability of "kubectl diff". | ||
// - native: uses "kubectl diff". Recommended | ||
// - subset: fallback for k8s versions below 1.13.0 | ||
"diffStrategy": "[native, subset]" | default = "auto", | ||
|
||
// Whether to add a "tanka.dev/environment" label to each created resource. | ||
// Required for garbage collection ("tk prune"). | ||
"injectLabels": <boolean> | default = false | ||
} | ||
} | ||
``` | ||
|
||
## Jsonnet access | ||
|
||
It is possible to access above data from Jsonnet: | ||
|
||
```jsonnet | ||
local tk = import "tk.libsonnet"; | ||
{ | ||
// The cluster IP | ||
cluster: tk.env.spec.apiServer, | ||
// The labels of your Environment | ||
labels: tk.env.metadata.labels, | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: "Garbage collection" | ||
route: "/garbage-collection" | ||
--- | ||
|
||
# Garbage collection | ||
|
||
Tanka can automatically delete resources from your cluster once you remove them | ||
from Jsonnet. | ||
|
||
> **Note:** This feature is **experimental**. Please report problems at https://github.com/grafana/tanka/issues. | ||
To accomplish this, it appends the `tanka.dev/environment: <name>` label to each created | ||
resource. This is used to identify those which are missing from the local state in the | ||
future. | ||
|
||
Because the label causes a `diff` for every single object in your cluster and | ||
not everybody wants this, it needs to be explicitly enabled. To do so, add the | ||
following field to your `spec.json`: | ||
|
||
```diff | ||
{ | ||
"spec": { | ||
+ "injectLabels": true, | ||
} | ||
} | ||
``` | ||
|
||
Once added, run a `tk apply`, make sure the label is actually added and confirm | ||
by typing `yes`. | ||
|
||
From now on, you can use `tk prune` to remove old resources from your cluster. |
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
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
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
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
Oops, something went wrong.