Comments (3)
Hey @jyepesr1
could you add some steps to reproduce this issue, maybe sharing your inventory-specification of the relevant file.
Note that there were several issues regarding the kube-prometheus-stack with pyYaml.
Is it just the empty alert: {}
property, or is there anything else, that changed?
from kapitan.
Hi @MatteoVoges, The most relevant issue at least with kube-prometheus-stack is this empty map, we haven't tested other components since we had to roll back to v0.30.0, we are using the following configuration:
chart_name: kube-prometheus-stack
chart_version: 34-9-0-kp-0-9
- name: helm3-template-prometheus
input_type: kadet
output_path: ${prometheus:manifests_output_location}
input_paths:
- kadet_functions/helm3_template
input_params:
chart_location: shared/${prometheus:chart_name}/${prometheus:chart_version}
clean_manifests: false
helm_values_files:
- ${prometheus:helm_values_files_location}/common.yml
- ${prometheus:helm_values_files_location}/grafana.yml
helm_values: ${prometheus:helm_values}
helm_params:
- --namespace ${prometheus:namespace}
- --name-template ${prometheus:chart_name}
- --api-versions 1.22.0
- --include-crds
- name: remove-prometheus-rules
input_type: kadet
output_path: .
input_paths:
- kadet_functions/remove_prometheus_rules
input_params:
alerting_rules_to_remove:
- KubePersistentVolumeFillingUp # noisy alert that we will change in the future
- TargetDown # Too broad of an alert. We don't control all pods in the cluster
chart_compiled_dir: ${prometheus:manifests_output_location}/${prometheus:chart_name}
We realized the issue is happening in the Kadet function we use to delete some Prometheus rules. This script works as expected as I mentioned in the 0.30.0, but in this new version produces this output. Not sure if is related as you mentioned to the PyYaml version. This is the script content
import os
from kapitan.inputs import kadet
import yaml
import sys
curr_dir = os.path.dirname(__file__)
sys.path.append(os.path.abspath(os.path.join(curr_dir, "..", "common")))
import common
inventory = kadet.inventory()
def is_prometheus_rule(resource):
if resource.root.kind == "PrometheusRule":
return True
return False
def remove_alerting_rule_if_present(resource, alerting_rules):
for g_idx, group in enumerate(resource.root.spec.groups):
for r_idx, rule in enumerate(group.rules):
if rule.alert in alerting_rules:
resource.root.spec.groups[g_idx].rules.pop(r_idx)
return resource
def main(input_params):
if "chart_compiled_dir" in input_params:
chart_compiled_dir = input_params.get("chart_compiled_dir")
else:
raise ValueError("'chart_compiled_dir' key not found in 'input_params'")
if "alerting_rules_to_remove" in input_params:
alerting_rules_to_remove = input_params.get("alerting_rules_to_remove")
else:
raise ValueError(
"'alerting_rules_to_remove' key not found in 'alerting_rules_to_remove'"
)
# get path where files have been compiled on this run
inventory.parameters.kapitan.vars.target
compile_path = input_params.get("compile_path")
all_objects = {}
prometheus_sub_chart = os.path.join(chart_compiled_dir, "templates", "prometheus")
manifest_files = common.get_compiled_manifest_files_for_component(
compile_path, prometheus_sub_chart
)
for file in manifest_files:
file_name_kadet_format = common.format_file_name_for_kadet(compile_path, file)
with open(file) as fp:
yaml_stream = yaml.safe_load_all(fp)
objects_for_file = []
for obj in yaml_stream:
o = kadet.BaseObj.from_dict(obj)
# ensure yaml object is valid k8s resource
# cleans up any cruft from helm template
if common.kadet_object_has_kind(o) is not True:
continue
if is_prometheus_rule(o):
o = remove_alerting_rule_if_present(o, alerting_rules_to_remove)
objects_for_file.append(o)
all_objects.update({file_name_kadet_format: objects_for_file})
fp.close()
output = kadet.BaseObj()
for file_name, obj in all_objects.items():
# TODO: output the object with the naming style we want
# kind = obj.root.kind
# name = obj.root.metadata.name
output.root[file_name] = obj
return output
from kapitan.
Related Issues (20)
- deps: jsonnet version are unaligned and outdated
- Build multi-arch docker image
- Update documentation for current build solution
- kapitan fails with importerror HOT 1
- Issue with documentation HOT 2
- Docker image cannot fetch helm charts
- distutils.dir_util.copy_tree will be deprecated soon
- Drop support for Python 3.7
- bug: reclass-config.yml not working as intended
- Kapitan Maintainership Request: Nexenio's Dedication to the Project's Success
- Kapitan fails to compile with compose_node_name: true
- Generator contract - how to write my own generator HOT 2
- Simplify input type Helm HOT 1
- More control over input type Helm output_path HOT 2
- Simplify kapitan/inputs/base.py HOT 2
- Provide an alternative backend for the inventory
- Refactoring documentation HOT 7
- bug: poetry cannot install gojsonnet HOT 2
- kapitan lint incorrectly reports no usage for classes with variables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kapitan.