跳到內容

內建特徵型別

此文件提供內建的「特徵(Traits)」參考資訊。

Container

容器工作負載的基礎特徵。

Schema

名稱型別必填預設值說明
type”container”V特徵型別名稱。
imagestringV容器映像名稱。
imagePullPolicystring容器映像下載的原則。“Always”, “Never”, “IfNotPresent”
imagePullSecrets[]string
cmd[]string
args[]string
ports[]Port
env[]Env
volumeMounts[]VolumeMount
livenessProbeLivenessProbe
readinessProbeReadinessProbe
serviceAccountNamestring

Port

名稱型別必填預設值說明
portintv
namestring
protocolstring

Env

NameTypeRequiredDefaultDescription
namestringv
valuestring
valueFromValueFrom

value或valueFrom 其中一個必須為必填

ValueFrom

NameTypeRequiredDefaultDescription
secretKeyRefSecretKeyRef

SecretKeyRef

NameTypeRequiredDefaultDescription
namestringvsecret name
keystringvsecret value

VolumeMount

名稱型別必填預設值說明
emptyDirEmptyDir
hostPathHostPath
pvcPVC
secretSecret

EmptyDir

名稱型別必填預設值說明
namestringv
mountPathstringv
subPathstring
mediumstring""“Memory” or “”

HostPath

名稱型別必填預設值說明
namestringv
mountPathstringv
subPathstring
pathstringvHost filesystem path.

PVC

名稱型別必填預設值說明
namestringv
mountPathstringv
subPathstring
claimNamestringv

Secret

名稱型別必填預設值說明
namestringv
subPathstring
mountPathstringv
secretNamestringv

HttpGet

名稱型別必填預設值說明
pathstringv
portintv
hoststring
schemestring
httpHeaders[]HttpHeader

HttpHeader

名稱型別必填預設值說明
namestringv
valuestringv

TcpSocket

名稱型別必填預設值說明
ipstringv
hostnames[]stringv

LivenessProbe

名稱型別必填預設值說明
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

ReadinessProbe

名稱型別必填預設值說明
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

StartupProbe

名稱型別必填預設值說明
execExec
httpGetHttpGet
tcpSocketTcpSocket
initialDelaySecondsint10
timeoutSecondsint1
successThresholdint1
failureThresholdint3

Exec

名稱型別必填預設值說明
command[]stringv

Sidecars

宣告容器化工作負載的伴隨邊車容器。

Schema

名稱型別必填預設值說明
type”sidecars”V特徵型別名稱。
sidecar[]SidecarV邊車容器資料。

Sidecar

名稱型別必填預設值說明
imagestringV容器映像名稱。
cmd[]string進入點命令名稱。
args[]string命令參數。
env[]Env環境變數。
volumesstring要與主容器共享的非永續暫時目錄。
livenessProbeLivenessProbe
readlinessProbeReadinessProbe

Volume

名稱型別必填預設值說明
namestringVVolume 名稱,會以此產生一個 emptyDir。
pathstringV綁定的路徑。
mainPathstring主容器的綁定路徑,如果沒有給的話跟 ‘path’ 相同。

Scaler

手動調整元件實例(Pod)數量。

Schema

名稱型別必填預設值說明
type”scaler”V特徵型別名稱。
replicaintV

Resources

描述容器等工作負載使用的資源限制。

Schema

名稱型別必填預設值說明
type”resources”V特徵型別名稱。
cpudouble1定義元件的 CPU requests 以及 limits 值。
memorystring2048 Mi定義元件的記憶體 requests 以及 limits。

Limits

名稱型別必填預設值說明
cpudouble同 Resources.cpuCPU limit for the component.
memorystring同 Resources.memoryMemory limits for the component.

Properties

通用 Key-value 屬性表,常作為應用元件設定值,例如:在 K8s 叢集產生一個 ConfigMap 物件。

Schema

名稱型別必填預設值說明
type”properties”V特徵型別名稱。
entriesmapping[string] stringkey-value 表。

Ingress-Route

讓 Webservice 元件可以對外開放存取端口。不能跟 HttpRoute 共用。

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: ingress-route-example
spec:
components:
- type: webservice.container
name: example
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: ingressRoute
paths:
“/”: 8000

Schema

名稱型別必填預設值說明
type”ingressRoute”V特徵型別名稱。稱。
hostnamestring匹配主機名稱。
pathsmap[string] intv路徑到 port 的對照表。
pathTypestringPrefix路徑比對的演算法。 “Prefix”, “Exact”, “ImplementationSpecific”
ingressClassNamestring指定 Ingress class 名稱。

Connections

用於動態綁定服務所需的機敏資料。

Schema

名稱型別必填預設值說明
type”connections”V特徵型別名稱。稱。
connections[]ConnectionV連線資訊。

Connection

名稱型別必填預設值說明
supplierNamestringV提供服務的元件名稱。
envRefsEnvRef指定特定連線資訊為應用的環境變數
volumeVolume將連線資訊以檔案方式掛載到應用裡

EnvRef

名稱型別必填預設值說明
secretKeystringV對應到Secret data的鍵值。
envNamestringV環境變數名稱。

Volume

名稱型別必填預設值說明
mountPathstringV掛載目錄位置。
subPathstringV

Rollout-Rolling

Rolling update 部署策略。 此策略在部署過程中,新舊版本並存,不同使用者可能同時存取到新舊版本。舊版本的元件副本會慢慢被刪除,同樣數量的新版本會被建立直到所有舊版本的副本都被置換為止。

Compatible Component Types

適用於 Webservice 類型元件。

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: rollout-rolling-example
spec:
components:
- type: webservice.container
name: example
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: “rollout-rolling”
maxSurge: 20%
maxUnavailable: 10%

Schema

名稱型別必填預設值說明
type”rollout-rolling”V特徵型別名稱。稱。
maxSurgestring20%最大超出容忍量,當新舊版本共存時,最大容忍多少 Pod 可超出的數量,可為數字或是百分比 ( ex: 2 or 10% )
maxUnavailablestring20%最大不可用容忍量,可為數字或是百分比 ( ex: 2 or 10% )
  • 總部署時間: Ceil( 100/stepWeight ) * interval 秒
  • 總部署 rollout steps:Ceil( 100/stepWeight )

Rollout-Recreate

此特徵描述 Recreate 部署策略。對於 Cluster Type 為 Kubenetets 的 Cluster 來說,此部署策略會先將舊版本的 Deployment 刪除後才開始建立新的 Deployment。

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: rollout-recreate-example
spec:
components:
- type: webservice.container
name: example
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: “rollout-recreate”

Schema

名稱型別必填預設值說明
type”rollout-recreate”V特徵型別名稱。稱。

Rollout-Canary

使用 K8s Gateway Api 作為底層實作分流的服務,應確認 K8s Gateway API 資源已安裝。此策略部署新版本與舊版本並存,但使用者的流量會逐漸地導到新版本的副本。如果沒有問題,此過程會持續直到所有流量都使用新版本為止。如果出現問題,可以將全部流量導回原先版本。

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: rollout-canary-example
spec:
components:
- type: webservice.container
name: example
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: “rollout-canary”
interval: 30
stepPercentage: 50

Schema

名稱型別必填預設值說明
type”rollout-canary”V特徵型別名稱。稱。
intervalint10每N秒後會進行下一次的 rollout deployment。
stepPercentageint20每次 Rollout Deployment 時會將多少%的流量轉移到新版本服務中。
  • 總部署時間: Ceil( 100/stepPercentage ) * interval 秒
  • 總部署 rollout steps:Ceil( 100/stepPercentage )

Rollout-BlueGreen

用於描述元件的藍綠部署策略。

Example

apiVersion: po.rapd.app/v1beta1
kind: Application
metadata:
name: rollout-blue-green-example
spec:
components:
- type: webservice.container
name: example
traits:
- type: container
image: nginx
ports:
- port: 80
name: "http"
protocol: "TCP"
- type: “rollout-blue-green”
名稱型別必填預設值說明
type”rollout-blue-green”V特徵型別名稱。稱。