admin管理员组文章数量:1123142
I am trying to deploy helm chart via tanka and as I have understood - tanka does helm template and then works with the generated outputs.
The issue with this is that all the chart tests are being rendered as well and then tk diff/apply
fails.
Is there a way to ignore them?
Example:
local tanka = import 'github/grafana/jsonnet-libs/tanka-util/main.libsonnet';
local helm = tanka.helm.new(std.thisFile);
{
myChart: helm.template('chart', '../../charts/mychart', {
namespace: 'mychart',
values: {
...
},
}),
}
I am trying to deploy helm chart via tanka and as I have understood - tanka does helm template and then works with the generated outputs.
The issue with this is that all the chart tests are being rendered as well and then tk diff/apply
fails.
Is there a way to ignore them?
Example:
local tanka = import 'github.com/grafana/jsonnet-libs/tanka-util/main.libsonnet';
local helm = tanka.helm.new(std.thisFile);
{
myChart: helm.template('chart', '../../charts/mychart', {
namespace: 'mychart',
values: {
...
},
}),
}
Share
Improve this question
asked 6 hours ago
Lukas IgnatavičiusLukas Ignatavičius
3,6152 gold badges27 silver badges30 bronze badges
1
- github.com/grafana/tanka/issues/550 this is GitHub issue about the same topic – Lukas Ignatavičius Commented 6 hours ago
2 Answers
Reset to default 0I was able to write a helper function to deal with this:
local excludeChartTests(resources) =
{
[item.key]: item.value
for item in std.objectKeysValues(resources)
if !(std.type(item.value) == 'object' &&
std.objectHas(item.value, 'metadata') &&
std.objectHas(item.value.metadata, 'annotations') &&
std.objectHas(item.value.metadata.annotations, 'helm.sh/hook') &&
item.value.metadata.annotations['helm.sh/hook'] == 'test')
};
Usage example:
local tanka = import 'github.com/grafana/jsonnet-libs/tanka-util/main.libsonnet';
local helm = tanka.helm.new(std.thisFile);
local excludeChartTests(resources) =
{
[item.key]: item.value
for item in std.objectKeysValues(resources)
if !(std.type(item.value) == 'object' &&
std.objectHas(item.value, 'metadata') &&
std.objectHas(item.value.metadata, 'annotations') &&
std.objectHas(item.value.metadata.annotations, 'helm.sh/hook') &&
item.value.metadata.annotations['helm.sh/hook'] == 'test')
};
{
myChart: excludeChartTests(helm.template('chart', '../../charts/mychart', {
namespace: 'mychart',
values: {
...
},
})),
}
You can filter them out in your Jsonnet code by applying a filter to exclude any resource with this annotation. Here's how you can modify your Jsonnet code:
local tanka = import 'github.com/grafana/jsonnet-libs/tanka-util/main.libsonnet';
local helm = tanka.helm.new(std.thisFile);
{
myChart: helm.template('chart', '../../charts/mychart', {
namespace: 'mychart',
values: {
...
},
}).filter(function(resource)
resource.metadata.annotations['helm.sh/hook'] != 'test'
),
}
本文标签: kubernetesHow to skip helm tests deployment in Grafana TankaStack Overflow
版权声明:本文标题:kubernetes - How to skip helm tests deployment in Grafana Tanka - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736550647a1944507.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论