Skip to main content

Wrapper around kubernetes-clients/python

Project description

Build Status Code style: black Type checker: mypy Packaging: poetry

Tulips

A small wrapper around https://github.com/kubernetes-client/python which understands Kubernetes charts.

Why

I needed something simple that would read Helm charts and push them to the Kubernetes cluster and be extensible. So something like helm+kubectl with ability to write you own tools around them.

Supported CRDS aka Kubernetes resources

  • Deployment
  • Service
  • Ingress
  • Secret
  • Issuer (cert-manager)
  • PersistentVolumeClaim

Example use

import yaml
from tulips import class_for_resource
from kubernetes import client as k8s
from kubernetes import config


client = config.new_client_from_config('kube.conf')

spec = yaml.load('ingress.yaml')

ingress_cls = class_for_resource(spec['kind'])
ingress = ingress_cls(config.client, namespace='default', spec)
ingress.create()  # Create Ingress resource
ingress.delete()  # Delete Ingress resource

Tulip

Tulip is a sample client that emulates Helm but without tiller.

$ python tulips push --help                                    06/25/18 -  9:49
Usage: tulips push [OPTIONS] CHART

  You can pass chart variables via foo=bar, for example '$ tulip push
  app.yaml foo=bar'

Options:
  --namespace TEXT   Kubernetes namespace
  --release TEXT     Name of the release
  --kubeconfig PATH  Path to kubernetes config
  --help             Show this message and exit.

Example

Let's say that I want to deploy a Secret and Ingress

apiVersion: v1
kind: Secret
metadata:
  name: <%=release=%>-secrets
type: Opaque
data:
  password: <%=@pwd=%>
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: <%=release=%>-web-ingress
  labels:
    app: woocart-<%=release=%>
  annotations:
    nginx.ingress.kubernetes.io/limit-connections: "100"
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: <%=domain=%>
    http:
      paths:
        - path: /
          backend:
            serviceName: <%=release=%>-web
            servicePort: 80

If one runs `tulip --release test push --kubeconf kube.conf app.yaml domain=test.tld'

Spec file is inspected and all <%=variables=%> are replaced with real values. Also special <%=@pwd=%> will generate strong password using passlib library.

TODO

  • Custom container for yaml(eliminates class_for_kind function)

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

tulips-0.1.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

tulips-0.1.4-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file tulips-0.1.4.tar.gz.

File metadata

  • Download URL: tulips-0.1.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tulips-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ef99e91d5bfa4b3379ea7fc2a7b7a45732f9456617935514f65248b0f0f26bb9
MD5 04e236db63061cf8f6b7affef6f16be5
BLAKE2b-256 d01a71d2fde5f1b0e248c89a1dc73844e65704fd8e99adf6063a03d0102a9852

See more details on using hashes here.

File details

Details for the file tulips-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for tulips-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2bd8106cc850db8afbf67dacff5d6cafa262ca375b88acad95b205a15c4b9827
MD5 3cb6e6ce572172e8dcc787bb02f16827
BLAKE2b-256 948d3f24af3d494851e59c90b3f67ee60c4b1324c1ecc57dd5592388af1779d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page