Helmion
Project description
Helmion
Helmion is a python library to download and customize Helm charts.
- Website: https://github.com/RangelReale/helmion
- Repository: https://github.com/RangelReale/helmion.git
- Documentation: https://helmion.readthedocs.org/
- PyPI: https://pypi.python.org/pypi/helmion
Example: chart
import pprint
from jsonpatchext.mutators import InitItemMutator
from helmion.chart import Request, Splitter, ProcessorChain
from helmion.config import BoolFilter
from helmion.processor import DefaultProcessor, FilterRemoveHelmData, FilterCRDs
req = Request(repository='https://helm.traefik.io/traefik', chart='traefik', version='9.10.1',
releasename='helmion-traefik', namespace='router', values={
'service': {
'type': 'ClusterIP',
}
})
reqfilter = DefaultProcessor(add_namespace=True, namespaced_filter=BoolFilter.ALL, hook_filter=BoolFilter.ALL, jsonpatches=[
{
'conditions': [[
{'op': 'check', 'path': '/kind', 'cmp': 'equals', 'value': 'Service'}
], [
{'op': 'check', 'path': '/kind', 'cmp': 'equals', 'value': 'ServiceAccount'}
], [
{'op': 'check', 'path': '/kind', 'cmp': 'equals', 'value': 'ClusterRoleBinding'}
]],
'patch': [
# Traefik Helm chart generates a null annotation field, must initialize it to a dict before merging.
{'op': 'mutate', 'path': '/metadata', 'mut': 'custom', 'mutator': InitItemMutator('annotations'), 'value': lambda: {}},
{
'op': 'merge', 'path': '/metadata', 'value': {
'annotations': {
'helmion.github.io/processed-by': 'helmion',
}
},
}
],
}
])
res = req.generate(ProcessorChain(
reqfilter,
FilterRemoveHelmData(only_exlcusive=False, remove_hooks=False)
))
for d in res.data:
pprint.pprint(d)
# Split charts by CRD
print('')
print('Split charts by CRDs')
print('====================')
reqsplitter = Splitter(categories={
'crds': FilterCRDs(),
'default': FilterCRDs(invert_filter=True),
})
mres = res.split(reqsplitter)
for category, category_chart in mres.items():
print('')
print('*** {} ***'.format(category))
for d in category_chart.data:
pprint.pprint(d)
# Split Service charts
print('')
print('Split Service and ServiceAccount charts')
print('=======================================')
reqsplitter = Splitter(categories={
'deployment': None,
'serviceaccount': None,
}, categoryfunc=lambda x: 'deployment' if x['kind'] == 'Deployment' else 'serviceaccount' if x['kind'] == 'ServiceAccount' else False)
mres = res.split(reqsplitter)
for category, category_chart in mres.items():
print('')
print('*** {} ***'.format(category))
for d in category_chart.data:
pprint.pprint(d)
Output:
{'apiVersion': 'apiextensions.k8s.io/v1beta1',
'kind': 'CustomResourceDefinition',
'metadata': {'name': 'ingressroutes.traefik.containo.us',
'namespace': 'router'},
'spec': {'group': 'traefik.containo.us',
'names': {'kind': 'IngressRoute',
'plural': 'ingressroutes',
'singular': 'ingressroute'},
'scope': 'Namespaced',
'version': 'v1alpha1'}}
{'apiVersion': 'apiextensions.k8s.io/v1beta1',
'kind': 'CustomResourceDefinition',
'metadata': {'name': 'ingressroutetcps.traefik.containo.us',
'namespace': 'router'},
'spec': {'group': 'traefik.containo.us',
'names': {'kind': 'IngressRouteTCP',
'plural': 'ingressroutetcps',
'singular': 'ingressroutetcp'},
'scope': 'Namespaced',
'version': 'v1alpha1'}}
<...more...>
Split charts by CRDs
====================
*** crds ***
{'apiVersion': 'apiextensions.k8s.io/v1beta1',
'kind': 'CustomResourceDefinition',
'metadata': {'name': 'ingressroutes.traefik.containo.us',
'namespace': 'router'},
'spec': {'group': 'traefik.containo.us',
'names': {'kind': 'IngressRoute',
'plural': 'ingressroutes',
'singular': 'ingressroute'},
'scope': 'Namespaced',
'version': 'v1alpha1'}}
{'apiVersion': 'apiextensions.k8s.io/v1beta1',
'kind': 'CustomResourceDefinition',
'metadata': {'name': 'ingressroutetcps.traefik.containo.us',
'namespace': 'router'},
'spec': {'group': 'traefik.containo.us',
'names': {'kind': 'IngressRouteTCP',
'plural': 'ingressroutetcps',
'singular': 'ingressroutetcp'},
'scope': 'Namespaced',
'version': 'v1alpha1'}}
<...more...>
*** default ***
{'apiVersion': 'v1',
'kind': 'ServiceAccount',
'metadata': {'annotations': {'helmion.github.io/processed-by': 'helmion'},
'labels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'},
'name': 'helmion-traefik',
'namespace': 'router'}}
{'apiVersion': 'rbac.authorization.k8s.io/v1',
'kind': 'ClusterRole',
'metadata': {'labels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'},
'name': 'helmion-traefik',
'namespace': 'router'},
'rules': [{'apiGroups': [''],
'resources': ['services', 'endpoints', 'secrets'],
'verbs': ['get', 'list', 'watch']},
{'apiGroups': ['extensions', 'networking.k8s.io'],
'resources': ['ingresses', 'ingressclasses'],
'verbs': ['get', 'list', 'watch']},
{'apiGroups': ['extensions', 'networking.k8s.io'],
'resources': ['ingresses/status'],
'verbs': ['update']},
{'apiGroups': ['traefik.containo.us'],
'resources': ['ingressroutes',
'ingressroutetcps',
'ingressrouteudps',
'middlewares',
'tlsoptions',
'tlsstores',
'traefikservices'],
'verbs': ['get', 'list', 'watch']}]}
<...more...>
Split Service and ServiceAccount charts
=======================================
*** deployment ***
{'apiVersion': 'apps/v1',
'kind': 'Deployment',
'metadata': {'labels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'},
'name': 'helmion-traefik',
'namespace': 'router'},
'spec': {'replicas': 1,
'selector': {'matchLabels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'}},
'strategy': {'rollingUpdate': {'maxSurge': 1, 'maxUnavailable': 1},
'type': 'RollingUpdate'},
'template': {'metadata': {'labels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'}},
'spec': {'containers': [{'args': ['--global.checknewversion',
'--global.sendanonymoususage',
'--entryPoints.traefik.address=:9000/tcp',
'--entryPoints.web.address=:8000/tcp',
'--entryPoints.websecure.address=:8443/tcp',
'--api.dashboard=true',
'--ping=true',
'--providers.kubernetescrd',
'--providers.kubernetesingress'],
'image': 'traefik:2.3.1',
'imagePullPolicy': 'IfNotPresent',
'livenessProbe': {'failureThreshold': 3,
'httpGet': {'path': '/ping',
'port': 9000},
'initialDelaySeconds': 10,
'periodSeconds': 10,
'successThreshold': 1,
'timeoutSeconds': 2},
'name': 'helmion-traefik',
'ports': [{'containerPort': 9000,
'name': 'traefik',
'protocol': 'TCP'},
{'containerPort': 8000,
'name': 'web',
'protocol': 'TCP'},
{'containerPort': 8443,
'name': 'websecure',
'protocol': 'TCP'}],
'readinessProbe': {'failureThreshold': 1,
'httpGet': {'path': '/ping',
'port': 9000},
'initialDelaySeconds': 10,
'periodSeconds': 10,
'successThreshold': 1,
'timeoutSeconds': 2},
'resources': None,
'securityContext': {'capabilities': {'drop': ['ALL']},
'readOnlyRootFilesystem': True,
'runAsGroup': 65532,
'runAsNonRoot': True,
'runAsUser': 65532},
'volumeMounts': [{'mountPath': '/data',
'name': 'data'},
{'mountPath': '/tmp',
'name': 'tmp'}]}],
'hostNetwork': False,
'securityContext': {'fsGroup': 65532},
'serviceAccountName': 'helmion-traefik',
'terminationGracePeriodSeconds': 60,
'volumes': [{'emptyDir': {}, 'name': 'data'},
{'emptyDir': {}, 'name': 'tmp'}]}}}}
*** serviceaccount ***
{'apiVersion': 'v1',
'kind': 'ServiceAccount',
'metadata': {'annotations': {'helmion.github.io/processed-by': 'helmion'},
'labels': {'app.kubernetes.io/instance': 'helmion-traefik',
'app.kubernetes.io/name': 'traefik'},
'name': 'helmion-traefik',
'namespace': 'router'}}
Example: info
import pprint
from helmion.info import RepositoryInfo
repoinfo = RepositoryInfo('https://helm.traefik.io/traefik')
print('Repository charts')
print('=================')
for ci in repoinfo.entries.values():
print('Chart: {}'.format(ci.name))
if ci.latest is not None:
print('Description: {}'.format(ci.latest.description))
print('Latest: {}'.format(ci.latest.version))
for r in ci.versions:
print('\trelease: {}'.format(r.version))
print('')
print('Chart values file')
print('===================')
# pprint.pprint(repoinfo.chartVersion('traefik', '9.10.1').getValuesFile())
print(repoinfo.chartVersion('traefik', '9.10.1').readArchiveFiles().archiveFiles['values.yaml'])
print('')
print('Chart file contents')
print('===================')
with repoinfo.chartVersion('traefik', '9.10.1').fileOpen() as tar_file:
for fname in tar_file.getnames():
print("- {}".format(fname))
Output:
Repository charts
=================
Chart: traefik
Description: A Traefik based Kubernetes ingress controller
Latest: 9.10.1
release: 9.10.1
release: 9.10.0
release: 9.9.0
release: 9.8.4
release: 9.8.3
release: 9.8.2
release: 9.8.1
<...more...>
Chart values file
===================
# Default values for Traefik
image:
name: traefik
# defaults to appVersion
tag: ""
pullPolicy: IfNotPresent
#
# Configure the deployment
#
deployment:
enabled: true
# Number of pods of the deployment
replicas: 1
# Additional deployment annotations (e.g. for jaeger-operator sidecar injection)
annotations: {}
# Additional pod annotations (e.g. for mesh injection or prometheus scraping)
podAnnotations: {}
<...more...>
Chart file contents
===================
- traefik/Chart.yaml
- traefik/values.yaml
- traefik/templates/_helpers.tpl
- traefik/templates/dashboard-hook-ingressroute.yaml
- traefik/templates/deployment.yaml
- traefik/templates/hpa.yaml
<...more...>
Credits
based on
Based on MichaelVL/kubernetes-deploy-tools.
Author
Rangel Reale (rangelreale@gmail.com)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
helmion-0.8.0.tar.gz
(18.2 kB
view details)
Built Distribution
helmion-0.8.0-py3-none-any.whl
(17.3 kB
view details)
File details
Details for the file helmion-0.8.0.tar.gz
.
File metadata
- Download URL: helmion-0.8.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eee90c2d3f42a14797e650abaedb766df62728e86d2e31dd084816baa7ae9a23 |
|
MD5 | 8c9402de5127b422b95eff6b83e6a386 |
|
BLAKE2b-256 | 693e9848596d560a3c92855052a594412cd913e7c1635da90c670a992bc848c9 |
File details
Details for the file helmion-0.8.0-py3-none-any.whl
.
File metadata
- Download URL: helmion-0.8.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 855dcac044c42a6ce07ffc0f710e735c91e6a37416205a637e706098eb229a76 |
|
MD5 | 55a41a1df9acc2b74a108ec294a39d26 |
|
BLAKE2b-256 | 855aba0decb8a121eb3eec40cf47a8dd5d751ebb6c49e1a43e4d276a37c2755a |