Skip to content

util

The util package contains ease of use functions to simplify working with kubernetes and jsonnet

Index

Fields

fn ingressFor

ingressFor(service, host='', path='/', port='service.spec.ports[0].port')

ingressFor constructs a ingress object, compatible with the automatic translation to openshift routes. It expects a value for the hostname and defaults to '/' for the path.

fn routeFor

routeFor(service, host='', path='/', port='service.spec.ports[0].port')

routeFor constructs a openshift route to the specified service. It expects a value for the hostname and defaults to '/' for the path.

fn serviceFor

serviceFor(deployment, ignored_labels, nameFormat='%(port)s')

serviceFor constructs a service for the specified deployment.

Selector labels are taken from the pod spec but can be ignored using the ignored_labels parameter.

The ports of the service will have the same name as in the container spec to avoid confusion. This can be changed with the nameFormat parameter.

fn weightedRouteFor

weightedRouteFor(name, host='', port='', services, path='/')

weightedRouteFor constructs a openshift route to the specified services. It expects a value for the name, hostname, port, services and defaults to '/' for the path. services expects an array consisting of objects with the keys name (name of the service) and weight.

obj certmanager

certman holds functions related to cert-manager (cert-manager.io)

obj certmanager.issuer

fn certmanager.issuer.new

new(emain, ingressClassName='nginx', production=true, clusterwide=true, name='letsencrypt-production || letsencrypt-staging')

constructs a cert-manager issuer resource for letsencrypt with sensible default.

obj java

java holds my functions related to java based applications

obj java.container

fn java.container.new

new(name, image, port=8080, actuatorPort='port+8080', env={})

constructs a container with reccomended settings for Java/Spring Boot applications. Includes liveness- and readiness probes, activates the kubernetes spring profile and sets sensible resource defaults.

obj java.deployment

fn java.deployment.new

new(name, image, replicas=1, env={}, containerMixin={}, runtime='spring-boot', component='backend')

constructs a deployment using the java container. If you need more control, construct this deployment yourself.

containerMixin can be used to modify the application container. For example:

deployment.new(/*...*/,
  containerMixin=k.core.v1.container.livenessProbe.withInitialDelaySeconds(60))
increases the initial delay seconds of the default liveness probe.

The runtime and component parameters are used to prefill recommended labels

obj java.livenessProbe

fn java.livenessProbe.new

new(port=8080, initialDelaySeconds=30)

new constructs a fresh liveness probe, checking if the tcp port 8080 is open

obj java.readinessProbe

fn java.readinessProbe.new

new(port=18080, path='/actuator/health')

new constructs a fresh readiness probe, checking if the application is up. The port and path of the actuator endpoint can be changed using the parameters.

obj openshiftOAuth

openshiftOAuth contains utilities to proxy an application using the OpenShift OAuth Proxy

obj openshiftOAuth.container

fn openshiftOAuth.container.new

new(upstream, serviceAccount)

constructs a container proxying connections to the upstream parameter.

obj openshiftOAuth.deployment

fn openshiftOAuth.deployment.withProxy

withProxy(upstream, serviceAccount)

add a proxy sidecar to the container. This also sets the service account used by the pod. The ServiceAccount needs to have the correct redirect reference for the route. See openshiftOAuth.serviceAccount.new for an easy way to create a compliant service account

obj openshiftOAuth.serviceAccount

fn openshiftOAuth.serviceAccount.new

new(name, route)

constructs a serviceaccount annotated with a oauth-redirectreference pointing to the route parameter