Skip to content

Built-in Trait Types

This document provides reference information for built-in trait types.

Container

Acts as the base trait for containerized workload components.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: application-local-webservice
namespace: default-env
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: first-component
target: default
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- port: 3000
name: "testpatch"
protocol: "TCP"
env:
- name: testenv
value: e1

Schema

NameTypeRequiredDefaultDescription
type”container”VType name.
imagestringVContainer image
imagePullPolicystring”Always”, “Never”, “IfNotPresent”
imagePullSecrets[]string
cmd[]string
args[]string
ports[]Port
env[]Env
volumeMounts[]VolumeMount
livenessProbeLivenessProbe
readinessProbeReadinessProbe
serviceAccountNamestring

Port

NameTypeRequiredDefaultDescription
portintv
namestring
protocolstring

Env

NameTypeRequiredDefaultDescription
namestringv
valuestring
valueFromValueFrom

value or valueFrom one of these must be required

ValueFrom

NameTypeRequiredDefaultDescription
secretKeyRefSecretKeyRef

SecretKeyRef

NameTypeRequiredDefaultDescription
namestringvsecret name
keystringvsecret value

VolumeMount

NameTypeRequiredDefaultDescription
emptyDirEmptyDir
hostPathHostPath
pvcPVC
secretSecret

EmptyDir

NameTypeRequiredDefaultDescription
namestringv
mountPathstringv
subPathstring
mediumstring""“Memory” or “”

HostPath

NameTypeRequiredDefaultDescription
namestringv
mountPathstringv
subPathstring
pathstringvHost filesystem path.

PVC

NameTypeRequiredDefaultDescription
namestringv
mountPathstringv
subPathstring
claimNamestringv

Secret

NameTypeRequiredDefaultDescription
namestringv
subPathstring
mountPathstringv
secretNamestringv

HttpGet

NameTypeRequiredDefaultDescription
pathstringv
portintv
hoststring
schemestring
httpHeaders[]HttpHeader

HttpHeader

NameTypeRequiredDefaultDescription
namestringv
valuestringv

TcpSocket

NameTypeRequiredDefaultDescription
ipstringv
hostnames[]stringv

LivenessProbe

NameTypeRequiredDefaultDescription
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

ReadinessProbe

NameTypeRequiredDefaultDescription
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

StartupProbe

NameTypeRequiredDefaultDescription
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

Exec

NameTypeRequiredDefaultDescription
command[]stringv

Sidecars

The trait for declaring sidecars for containerized worloads.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: nginx-sidecar
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: first-component
target: default
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: sidecar
sidecar:
- image: busybox
command: ['sh', '-c', 'sleep 3600']

Schema

NameTypeRequiredDefaultDescription
type”sidecars”VType name
sidecar[]SidecarVSidecar definition.

Sidecar

NameTypeRequiredDefaultDescription
imagestringVContainer image name.
cmd[]stringEntry Command.
args[]stringCommand line arguments.
env[]EnvEnvironment variables.
volumesstringNon-persistent volume shared with the main container.
livenessProbeLivenessProbe
readlinessProbeReadinessProbe

Volume

NameTypeRequiredDefaultDescription
namestringVName for the underlying emptyDir。
pathstringVThe path to mount the volume.
mainPathstringTHe mount path in the main container. Same as path is not given.

Scaler

Manually specifying relica count of workload components.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: nginx-scaler-webservice
namespace: default-env
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: mycomponent
target: default
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: scaler
replicas: 3

Schema

NameTypeRequiredDefaultDescription
type”scaler”VType name.
replicaintV

Resources

For declaring resource limits of attched components.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: nginx-resource-webservice
namespace: default-env
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: mycomponent
target: default
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: resources
memory: "128Mi"
cpu: 1.2
limits:
cpu: 1.4
memory: "158Mi"

Schema

NameTypeRequiredDefaultDescription
type”resources”VType name.
cpudouble1CPU requests and limits for the component.
memorystring2048MiMemory requests and limits for the component.
limitsLimitsSpecify resource limits.

Limits

NameTypeRequiredDefaultDescription
cpudoublesame as Resources.cpuCPU limit for the component.
memorystringsame as Resources.memoryMemory limits for the component.

Properties

Generic key-value tables which are used as the data source for application configrations. For example, for creating a ConfigMap in target K8s cluster.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: nginx-property-webservice
namespace: default-env
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: mycomponent
target: default
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
volumeMounts:
- configMap:
name: mmmm
configName: myvolume
mountPath: /config
items:
- key: mykey
path: mykey
- key: docs
path: newdocs
- type: properties
entries:
mykey: myvalue
docs: document value
name: myvolume

Schema

NameTypeRequiredDefaultDescription
type”properties”VType name.
entriesmapping[string] stringkey-value map.

Ingress-Route

For declaring external HTTP endpoints.

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: example
spec:
components:
- name: web-server
type: webservice
properties:
image: nginx
port: 8000
traits:
- type: ingressRoute
paths:
“/”: 8000

Schema

NameTypeRequiredDefaultDescription
type”ingressRoute”VType name.
hostnamestringMatched hostname.
pathsmap[string] intvpath to port number mappings
pathTypestringPrefixPath matching algorithm. “Prefix”, “Exact”, “ImplementationSpecific”
ingressClassNamestringIngress class name

Connections

Specifying the bindings from client to supplier components.

Example

apiVersion: po.rapd.app/v1
kind: Application
metadata:
name: my-wp
spec:
version: "1.0"
revisionHistory: 3
components:
- type: webservice.container
name: wordpress
target: bind-gcp
traits:
- type: container
image: wordpress
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: ingress-route
paths:
"/": 80
pathType: Prefix
- type: connections
connections:
- supplierName: my-wp-wordpress-mysql
envRefs:
- secretKey: username
envName: WORDPRESS_DB_USER
- secretKey: password
envName: WORDPRESS_DB_PASSWORD
- secretKey: host
envName: WORDPRESS_DB_HOST
- secretKey: db
envName: WORDPRESS_DB_NAME
- type: database.mysql
name: wordpress-mysql
target: bind-mysql-gcp

Schema

NameTypeRequiredDefaultDescription
type”connections”VType name.
connections[]ConnectionVConnection data.

Connection

NameTypeRequiredDefaultDescription
supplierNamestringVName of the target component.
envRefsEnvRefBind connection data to environment variables.
volumeVolumeMount connection data to a filesystem path.

EnvRef

NameTypeRequiredDefaultDescription
secretKeystringVThe key to the connection secret.
envNamestringVenvironment variable name.

Volume

NameTypeRequiredDefaultDescription
mountPathstringVMount location.
subPathstringV

Rollout-Rolling

Rolling Update Deployment Strategy: This strategy allows both old and new versions to coexist during the deployment process. Different users may simultaneously access the old and new versions. The replicas of the old version gradually get removed, while an equal number of new version replicas are created until all old version replicas have been replacedㄡ

Compatible Component Types

The trait may be applied to webservice components.

Example

apiVersion: po.rapd.app/v1
kind: Application
metadata:
name: example
spec:
components:
- name: web-server
type: webservice
properties:
image: nginx
port: 8000
traits:
- type: “rollout-rolling”
maxSurge: 20%
maxUnavailable: 10%

Schema

NameTypeRequiredDefaultDescription
type”rollout-rolling”VType name
maxSurgestring20%amount of pods more than the desired number of Pods.this fields can be an absolute number or the percentage ( ex: 2 or 10% )
maxUnavailablestring20%amount of pods that can be unavailable during the update process. In number of percentage format ( ex: 2 or 10% )
  • Total deployment time: Ceil( 100/stepWeight ) * interval seconds
  • Total rollout steps:Ceil( 100/stepWeight )

Rollout-Recreate

The recreate deployment strategy is the simplest approach used in cloud-native application deployment. Here’s how it works:

  1. Initial Deployment:
  • Version 1 of the application is deployed.
  • All pods running version 1 are active.
  1. Deployment Process:
  • The deployment process begins.
  • All pods running version 1 are deleted.
  • Immediately after, version 2 of the application is deployed.
  1. Drawbacks:
  • The main drawback of recreate deployments is the small window of downtime during which the old version is removed and the new version is instantiated1.

In summary, recreate deployments provide a straightforward way to transition from one version to another, but they come with a brief interruption in service.

Example

apiVersion: po.rapd.app/v1
kind: Application
metadata:
name: example
spec:
components:
- name: web-server
type: webservice
properties:
image: nginx
port: 8000
traits:
- type: “rollout-recreate”

Schema

NameTypeRequiredDefaultDescription
type”rollout-recreate”VType name.

Rollout-Canary

When using the K8s Gateway API to implement underlying traffic splitting services, ensure that the K8s Gateway API resources are installed. This strategy deploys both new and old versions concurrently, gradually directing user traffic toward the replicas of the new version. If everything goes smoothly, this process will continue until all traffic exclusively uses the new version. In case of any issues, it’s possible to redirect all traffic back to the original version.

Example

apiVersion: po.rapd.app/v1
kind: Application
metadata:
name: example
spec:
components:
- name: web-server
type: webservice
properties:
image: nginx
port: 8000
traits:
- type: “rollout-canary”
interval: 30
stepPercentage: 50

Schema

NameTypeRequiredDefaultDescription
type”rollout-canary”VType name
intervalint10Adjust traffic every interval seconds.
stepPercentageint20percentage of traffice routed to new version during the update process.
  • Total time: Ceil( 100/stepPercentage ) * interval 秒
  • Totsl rollout steps:Ceil( 100/stepPercentage )

Rollout-BlueGreen

Blue-green deployment strategy.

Example

apiVersion: po.rapd.app/v1
kind: Application
metadata:
name: example
spec:
components:
- name: web-server
type: webservice
properties:
image: nginx
port: 8000
traits:
- type: “rollout-blue-green”
NameTypeRequiredDefaultDescription
type”rollout-blue-green”VName of the trait type