ballerina/kubernetes module

Type Definitions

Type Values Description
ImagePullPolicy Never | IfNotPresent | Always

Image pull policy type field for kubernetes deployment and jobs.

IstioPortProtocol TLS | TCP | MONGO | HTTPS | HTTP2 | HTTP | GRPC

Types of protocols of a port.

IstioTLSOptionMode SIMPLE | PASSTHROUGH | MUTUAL

TLS mode enforced by the proxy.

ResourceQuotaScope Terminating | NotTerminating | NotBestEffort | BestEffort

Scopes for kubernetes resource quotas

RestartPolicy OnFailure | Never | Always

Restart policy type field for kubernetes jobs.

ServiceType NodePort | LoadBalancer | ClusterIP

Service type field for kubernetes services.

SessionAffinity None | ClientIP

Session affinity field for kubernetes services.

Annotations

Name Attachement Points Data Type Description
ConfigMap service ConfigMapMount

@kubernetes:ConfigMap annotation to configure config maps.

Deployment service, function, listener DeploymentConfiguration

@kubernetes:Deployment annotation to configure deplyoment yaml.

HPA service PodAutoscalerConfig

@kubernetes:HPA annotation to configure horizontal pod autoscaler yaml.

Ingress service, listener IngressConfiguration

@kubernetes:Ingress annotation to configure ingress yaml.

IstioGateway service, listener IstioGatewayConfig

@kubernetes:IstioGateway annotation to generate istio gateways.

IstioVirtualService service, listener IstioVirtualServiceConfig

@kubernetes:IstioVirtualService annotation to generate istio virtual service.

Job function JobConfig

@kubernetes:Job annotation to configure kubernetes jobs.

PersistentVolumeClaim service PersistentVolumeClaims

@kubernetes:PersistentVolumeClaim annotation to configure Persistent Volume Claims.

ResourceQuota service, function, listener ResourceQuotas

@kubernetes:ResourcesQuotas annotation to configure Resource Quotas.

Secret service SecretMount

@kubernetes:Secret annotation to configure secrets.

Service service, listener ServiceConfiguration

@kubernetes:Service annotation to configure service yaml.

Records Summary

Record Description
ConfigMap Kubernetes Config Map volume mount.
ConfigMapKeyRef Value from config map key.
ConfigMapKeyValue Value for config map key.
ConfigMapMount Secret volume mount configurations for kubernetes.
CorsPolicyConfig Configuration for CORS policy.
DeploymentConfiguration Kubernetes deployment configuration.
DestinationConfig Configuration to a network addressable service.
DestinationWeightConfig Configuration for weight for destination to traffic route.
FieldRef Value from field.
FieldValue Value for a field.
FileConfig External file type for docker.
HTTPFaultInjectionAbortConfig Configuration to abort request prematurely.
HTTPFaultInjectionConfig Configuration to specify faults to inject while forwarding.
HTTPFaultInjectionDelayConfig Configuration for delaying a request.
HTTPMatchRequestConfig Configuration for a matching requests.
HTTPRedirectRewriteConfig Configuration to rewrite or redirect requests.
HTTPRetryConfig Configuration for retrying http requests.
HTTPRouteConfig Configurations for conditions and actions for routing HTTP.
IngressConfiguration Kubernetes ingress configuration.
IstioGatewayConfig Istio gateway annotation configuration.
IstioPortConfig Port of a service.
IstioServerConfig Istio gateway server configuration to describe the properties of the proxy on a given load balancer.
IstioTLSOptionConfig Istio gateway server tls option configurations.
IstioVirtualServiceConfig Virtual service configuration for @kubernetes:IstioVirtualService annotation.
JobConfig Kubernetes job configuration.
L4MatchAttributesConfig Configuration for L4 connection match attributes.
Metadata Metadata for artifacts
PersistentVolumeClaimConfig Kubernetes Persistent Volume Claim.
PersistentVolumeClaims Persistent Volume Claims configurations for kubernetes.
PodAutoscalerConfig Kubernetes Horizontal Pod Autoscaler configuration
PortSelectorConfig Configuration for a port selector.
ResourceFieldRef Value from resource field.
ResourceFieldValue Value for resource field.
ResourceQuotaConfig Kubernetes Resource Quota
ResourceQuotas Resource Quota configuration for kubernetes.
Secret Kubernetes secret volume mount.
SecretKeyRef Value from secret key.
SecretKeyValue Value for a secret key.
SecretMount Secret volume mount configurations for kubernetes.
ServiceConfiguration Kubernetes service configuration.
StringMatch Configuration for a string match.
TCPRouteConfig Configuration for routing TCP traffic.
TLSMatchAttributesConfig Configuration to match TLS attributes.
TLSRouteConfig Configuration for conditions and actions for routing TLS/HTTPS traffic.

Constants

Name Data Type Value Description
IMAGE_PULL_POLICY_IF_NOT_PRESENT string IfNotPresent
IMAGE_PULL_POLICY_ALWAYS string Always
IMAGE_PULL_POLICY_NEVER string Never
SESSION_AFFINITY_NONE string None
SESSION_AFFINITY_CLIENT_IP string ClientIP
SERVICE_TYPE_NORD_PORT string NodePort
SERVICE_TYPE_CLUSTER_IP string ClusterIP
SERVICE_TYPE_LOAD_BALANCER string LoadBalancer
RESTART_POLICY_ON_FAILURE string OnFailure
RESTART_POLICY_ALWAYS string Always
RESTART_POLICY_NEVER string Never

public type ConfigMap record

Kubernetes Config Map volume mount.

Field Name Data Type Default Value Description
mountPath string

Mount path

readOnly boolean true

Is mount read only

data string[]

Paths to data files

public type ConfigMapKeyRef record

Value from config map key.

Field Name Data Type Default Value Description
configMapKeyRef kubernetes:ConfigMapKeyValue

Reference for config map key.

public type ConfigMapKeyValue record

Value for config map key.

Field Name Data Type Default Value Description
name string

name of the config.

key string

key of the config.

public type ConfigMapMount record

Secret volume mount configurations for kubernetes.

Field Name Data Type Default Value Description
ballerinaConf string

path to ballerina configuration file

configMaps kubernetes:ConfigMap[]

Array of ConfigMap

public type CorsPolicyConfig record

Configuration for CORS policy.

Field Name Data Type Default Value Description
allowOrigin string[]

The list of origins that are allowed to perform CORS requests.

allowMethods string[]

List of HTTP methods allowed to access the resource.

allowHeaders string[]

List of HTTP headers that can be used when requesting the resource.

exposeHeaders string[]

A white list of HTTP headers that the browsers are allowed to access.

maxAge string

Specifies how long the the results of a preflight request can be cached.

allowCredentials boolean

Indicates whether the caller is allowed to send the actual request (not the preflight) using credentials.

public type DeploymentConfiguration record

Kubernetes deployment configuration.

Field Name Data Type Default Value Description
podAnnotations map

Map of annotations for pods

replicas int

Number of replicas

enableLiveness boolean

Enable/Disable liveness probe

livenessPort int

Port to check the liveness

initialDelaySeconds int

Initial delay in seconds before performing the first probe

periodSeconds int

Liveness probe interval

imagePullPolicy IfNotPresent|Always|Never IMAGE_PULL_POLICY_IF_NOT_PRESENT

Kubernetes image pull policy

image string

Docker image with tag

env map|kubernetes:FieldRef|kubernetes:SecretKeyRef|kubernetes:ResourceFieldRef|kubernetes:ConfigMapKeyRef>

Environment varialbe map for containers

buildImage boolean

Docker image to be build or not

dockerHost string

Docker host IP and docker PORT. (e.g minikube IP and docker PORT)

username string

Username for docker registry

password string

Password for docker registry

baseImage string

Base image for docker image building

push boolean

Push to remote registry

dockerCertPath string

Docker certificate path

copyFiles kubernetes:FileConfig[]

Array of External files for docker image

singleYAML boolean true

Generate a single yaml file with all kubernetes artifacts (services,deployment,ingress,)

dependsOn string[]

Services this deployment depends on

imagePullSecrets string[]

Image pull secrets

public type DestinationConfig record

Configuration to a network addressable service.

Field Name Data Type Default Value Description
host string

Host of a service.

subset string

Subset within the service.

port kubernetes:PortSelectorConfig

The port on the host that is being addressed.

public type DestinationWeightConfig record

Configuration for weight for destination to traffic route.

Field Name Data Type Default Value Description
destination kubernetes:DestinationConfig

Destination to forward to.

weight int

Weight for the destination.

public type FieldRef record

Value from field.

Field Name Data Type Default Value Description
fieldRef kubernetes:FieldValue

Reference for a field.

public type FieldValue record

Value for a field.

Field Name Data Type Default Value Description
fieldPath string

Path of the field

public type FileConfig record

External file type for docker.

Field Name Data Type Default Value Description
source string

source path of the file (in your machine)

target string

target path (inside container)

public type HTTPFaultInjectionAbortConfig record

Configuration to abort request prematurely.

Field Name Data Type Default Value Description
percent int

Percentage of requests to abort.

httpStatus int

Http status when aborted.

public type HTTPFaultInjectionConfig record

Configuration to specify faults to inject while forwarding.

Field Name Data Type Default Value Description
delay kubernetes:HTTPFaultInjectionDelayConfig

Delay before forwarding.

abort kubernetes:HTTPFaultInjectionAbortConfig

Abort http request.

public type HTTPFaultInjectionDelayConfig record

Configuration for delaying a request.

Field Name Data Type Default Value Description
percent int

Percentage of requests to delay.

fixedDelay string

Delay for the request.

public type HTTPMatchRequestConfig record

Configuration for a matching requests.

Field Name Data Type Default Value Description
uri kubernetes:StringMatch

URI to match values.

scheme kubernetes:StringMatch

URI Scheme values.

method kubernetes:StringMatch

HTTP Method values.

authority kubernetes:StringMatch

HTTP Authority values.

headers map

HTTP headers to match.

port int

Port on the host that is being addressed.

sourceLabels map

One or more labels that constrain the applicability of a rule to workloads with the given labels.

gateways string[]

Names of gateways the rules should be applied to.

public type HTTPRedirectRewriteConfig record

Configuration to rewrite or redirect requests.

Field Name Data Type Default Value Description
uri string

Rewrite the path portion of the URI with this value.

authority string

Rewrite authority header.

public type HTTPRetryConfig record

Configuration for retrying http requests.

Field Name Data Type Default Value Description
attempts int

Number of retries.

perTryTimeout string

Timeout per attempt.

public type HTTPRouteConfig record

Configurations for conditions and actions for routing HTTP.

Field Name Data Type Default Value Description
match kubernetes:HTTPMatchRequestConfig[]

Conditions to match.

route kubernetes:DestinationWeightConfig[]

Route destination.

redirect kubernetes:HTTPRedirectRewriteConfig

Rule for redirecting.

rewrite kubernetes:HTTPRedirectRewriteConfig

Rewrite URI and headers.

timeout string

Timeout for requests.

retries kubernetes:HTTPRetryConfig

Retry policy.

fault kubernetes:HTTPFaultInjectionConfig

Fault injection policy.

mirror kubernetes:DestinationConfig

Mirror traffic to another destination.

corsPolicy kubernetes:CorsPolicyConfig

CORS policies.

appendHeaders map

Additional header to add before forwarding/directing.

public type IngressConfiguration record

Kubernetes ingress configuration.

Field Name Data Type Default Value Description
listenerName string

Name of the listener ingress attached

hostname string

Host name of the ingress

path string

Resource path

targetPath string

Target path for url rewrite

ingressClass string

Ingress class

enableTLS boolean

Enable/Disable ingress TLS

public type IstioGatewayConfig record

Istio gateway annotation configuration.

Field Name Data Type Default Value Description
selector map

Specific set of pods/VMs on which this gateway configuration should be applied.

servers kubernetes:IstioServerConfig[]

List of servers to pass.

public type IstioPortConfig record

Port of a service.

Field Name Data Type Default Value Description
number int

The port number.

protocol HTTP|HTTPS|GRPC|HTTP2|MONGO|TCP|TLS

The protocol exposed by the port.

name string

Label for the port.

public type IstioServerConfig record

Istio gateway server configuration to describe the properties of the proxy on a given load balancer.

Field Name Data Type Default Value Description
port kubernetes:IstioPortConfig

The port of the proxy.

hosts string[]

List of hosts exposed by the gateway.

tls kubernetes:IstioTLSOptionConfig

TLS options.

public type IstioTLSOptionConfig record

Istio gateway server tls option configurations.

Field Name Data Type Default Value Description
httpsRedirect boolean false

If set to true, the load balancer will send a 301 redirect for all http connections, asking the clients to use HTTPS.

mode PASSTHROUGH|SIMPLE|MUTUAL

Indicates whether connections to this port should be secured using TLS. The value of this field determines how TLS is enforced.

serverCertificate string

REQUIRED if mode is SIMPLE or MUTUAL. The path to the file holding the server-side TLS certificate to use.

privateKey string

REQUIRED if mode is SIMPLE or MUTUAL. The path to the file holding the server���s private key.

caCertificates string

REQUIRED if mode is MUTUAL. The path to a file containing certificate authority certificates to use in verifying a presented client side certificate.

subjectAltNames string[]

A list of alternate names to verify the subject identity in the certificate presented by the client.

public type IstioVirtualServiceConfig record

Virtual service configuration for @kubernetes:IstioVirtualService annotation.

Field Name Data Type Default Value Description
hosts string[]

Destination which traffic should be sent.

gateways string[]

Names of the gateways which the service should listen to.

http kubernetes:HTTPRouteConfig[]

Route rules for HTTP traffic.

tls kubernetes:TLSRouteConfig[]

Route rules for TLS and HTTPS traffic.

tcp kubernetes:TCPRouteConfig[]

Route rules for TCP traffic.

public type JobConfig record

Kubernetes job configuration.

Field Name Data Type Default Value Description
restartPolicy OnFailure|Always|Never RESTART_POLICY_NEVER

Restart policy

backoffLimit string

Backoff limit

activeDeadlineSeconds string

Active deadline seconds

schedule string

Schedule for cron jobs

env map|kubernetes:FieldRef|kubernetes:SecretKeyRef|kubernetes:ResourceFieldRef|kubernetes:ConfigMapKeyRef>

Environment varialbes for container

imagePullPolicy IfNotPresent|Always|Never IMAGE_PULL_POLICY_IF_NOT_PRESENT

Policy for pulling an image

image string

Docker image with tag

buildImage boolean true

Docker image to be build or not

dockerHost string

Docker host IP and docker PORT. (e.g minikube IP and docker PORT)

username string

Username for docker registry

password string

Password for docker registry

baseImage string

Base image for docker image building

push boolean false

Push to remote registry

dockerCertPath string

Docker cert path

copyFiles kubernetes:FileConfig[]

Array of External files for docker image

imagePullSecrets string[]

Image pull secrets

singleYAML boolean true

Generate a single yaml file with all kubernetes artifacts (services,deployment,ingress,)

public type L4MatchAttributesConfig record

Configuration for L4 connection match attributes.

Field Name Data Type Default Value Description
destinationSubnets string[]

IP address of destination.

port int

Port on the host that is being addressed.

sourceLabels map

One or more labels that constrain the applicability of a rule to workloads with the given labels.

gateways string[]

Names of gateways the rules should be applied to.

public type Metadata record

Metadata for artifacts

Field Name Data Type Default Value Description
name string

Name of the resource

namespace string

Kubernetes namespace to be used

labels map

Map of labels for the resource

annotations map

Map of annotations for resource

public type PersistentVolumeClaimConfig record

Kubernetes Persistent Volume Claim.

Field Name Data Type Default Value Description
mountPath string

Mount Path

accessMode string

Access mode

volumeClaimSize string

Size of the volume claim

readOnly boolean

Is mount read only

public type PersistentVolumeClaims record

Persistent Volume Claims configurations for kubernetes.

Field Name Data Type Default Value Description
volumeClaims kubernetes:PersistentVolumeClaimConfig[]

Array of PersistentVolumeClaimConfig

public type PodAutoscalerConfig record

Kubernetes Horizontal Pod Autoscaler configuration

Field Name Data Type Default Value Description
minReplicas int

Minimum number of replicas

maxReplicas int

Maximum number of replicas

cpuPercentage int

CPU percentage to start scaling

public type PortSelectorConfig record

Configuration for a port selector.

Field Name Data Type Default Value Description
number int

The number of the port.

public type ResourceFieldRef record

Value from resource field.

Field Name Data Type Default Value Description
resourceFieldRef kubernetes:ResourceFieldValue

Reference for resource field.

public type ResourceFieldValue record

Value for resource field.

Field Name Data Type Default Value Description
containerName string

Name of the container.

resource string

Resource field

public type ResourceQuotaConfig record

Kubernetes Resource Quota

Field Name Data Type Default Value Description
hard map

Quotas for the resources

scopes Terminating|NotTerminating|BestEffort|NotBestEffort[] []

Scopes of the quota

public type ResourceQuotas record

Resource Quota configuration for kubernetes.

Field Name Data Type Default Value Description
resourceQuotas kubernetes:ResourceQuotaConfig[]

Array of ResourceQuotaConfig

public type Secret record

Kubernetes secret volume mount.

Field Name Data Type Default Value Description
mountPath string

Mount path

readOnly boolean true

Is mount read only

data string[]

Paths to data files as an array

public type SecretKeyRef record

Value from secret key.

Field Name Data Type Default Value Description
secretKeyRef kubernetes:SecretKeyValue

Reference for secret key.

public type SecretKeyValue record

Value for a secret key.

Field Name Data Type Default Value Description
name string

Name of the secret.

key string

Key of the secret.

public type SecretMount record

Secret volume mount configurations for kubernetes.

Field Name Data Type Default Value Description
secrets kubernetes:Secret[]

Array of Secret

public type ServiceConfiguration record

Kubernetes service configuration.

Field Name Data Type Default Value Description
port int

Service port

sessionAffinity None|ClientIP SESSION_AFFINITY_NONE

Session affinity for pods

serviceType NodePort|ClusterIP|LoadBalancer SERVICE_TYPE_CLUSTER_IP

Service type of the service

public type StringMatch record

Configuration for a string match.

Field Name Data Type Default Value Description
exact string

Exact match string.

prefix string

Prefix to match string.

regex string

Regex to match string.

public type TCPRouteConfig record

Configuration for routing TCP traffic.

Field Name Data Type Default Value Description
match kubernetes:L4MatchAttributesConfig[]

Match conditions.

route kubernetes:DestinationWeightConfig[]

Destination to route to.

public type TLSMatchAttributesConfig record

Configuration to match TLS attributes.

Field Name Data Type Default Value Description
sniHosts string[]

Server name indicator to match.

destinationSubnets string[]

IP address of the destination.

port int

Port on the host that is being addressed.

sourceLabels map

One or more labels that constrain the applicability of a rule to workloads with the given labels.

gateways string[]

Names of gateways the rules should be applied to.

public type TLSRouteConfig record

Configuration for conditions and actions for routing TLS/HTTPS traffic.

Field Name Data Type Default Value Description
match kubernetes:TLSMatchAttributesConfig[]

Match conditions to satisfy.

route kubernetes:DestinationWeightConfig[]

Destination to route.