Component
Component
describes your workload.
For example, the following component configuration sets up a hello-world workload running the kalmhq/echoserver
image, the workload has one replica and exposes the 8001 port for receiving requests.
apiVersion: core.kalm.dev/v1alpha1
kind: Component
metadata:
name: hello-world
namespace: default
spec:
replicas: 1
workloadType: server
image: kalmhq/echoserver
ports:
- containerPort: 8001
protocol: http
servicePort: 8001
Component
Field | Type | Description | Required |
---|---|---|---|
labels | map[string]string | labels will add to pods | False |
annotations | map[string]string | annotations will add to pods | False |
env | EnvVar[] | List of environment variables to set in the container | False |
image | string | Docker image name | True |
replicas | *int32 | the number of desired pods, default to 1 | False |
nodeSelectorLabels | map[string]string | if set, pod will only be scheduled onto the node with given labels | False |
preferNotCoLocated | bool | if set, will avoid putting pods of this component in the same node | False |
startAfterComponents | string[] | will start this component after the components specified | False |
command | string | run command for pod | False |
enableHeadlessService | bool | if set, will start a headless service for the component | False |
ports | Port[] | information on the component's service ports | False |
workloadType | WorkloadType | type of the component workload, default to: server | False |
schedule | string | REQUIRED if WorkloadType is cronjob , the schedule of cronjob, e.g. * * * * * | False |
livenessProbe | *v1.Probe | describes a health check to be performed against a container to determine whether it is alive to receive traffic. | False |
readinessProbe | *v1.Probe | similar as LivenessProbe, but used to determine if the container is ready to receive traffic | False |
resourceRequirements | *v1.ResourceRequirements | describes the compute resource requirements | False |
terminationGracePeriodSeconds | *int64 | duration in seconds the pod needs to terminate gracefully. | False |
dnsPolicy | v1.DNSPolicy | how a pod's DNS will be configured. | False |
restartPolicy | v1.RestartPolicy | how the container should be restarted. | False |
restartStrategy | appsv1.DeploymentStrategyType | The deployment strategy to use to replace existing pods with new ones. | False |
volumes | Volume[] | temporary or persistent volumes for the pods | False |
runnerPermission | *RunnerPermission | setup RBAC permission for the running pods | False |
preInjectedFiles | PreInjectFile[] | convenient way to mount files into containers | False |
EnvVar
Field | Type | Description | Required |
---|---|---|---|
name | string | Name of the environment variable. | True |
value | string | Source for the environment variable's value. | False |
type | EnvVarType | different types of EnvVar have different ways of parsing EnvVar.Value | False |
prefix | string | prefix of env name | False |
suffix | string | suffix of env name | False |
EnvVarType
Name | Description |
---|---|
static | environment variable's value is simply EnvVar.Value |
linked | EnvVar.Value in format of: serviceName/servicePortName, environment variable's value will resove to: serviceName.currentNamespace:_servicePort, useful if you wanna reference other component's service in same application. |
fieldref | EnvVar.Value is pod FieldSelector, environment variable's value will resove to the value of pod field. |
builtin | possible EnvVar values are: EnvVarBuiltinHost , EnvVarBuiltinPodName and EnvVarBuiltinNamespace . - EnvVarBuiltinHost : environment variable's value will resolve to spec.nodeName of the pod- EnvVarBuiltinPodName : metadata.name of the pod- EnvVarBuiltinNamespace : metadata.namespace of the pod |
Port
Field | Type | Description | Required |
---|---|---|---|
containerPort | uint32 | container port | True |
servicePort | uint32 | service port, if absent, will set as same as ContainerPort | False |
protocol | PortProtocol | protocol of the service | False |
PortProtocol
Name | Description |
---|---|
http | HTTP |
https | HTTPS |
http2 | HTTP2 |
grpc | GRPC |
grpc-web | GRPCWEB |
tcp | TCP |
udp | UDP |
unknown | Unknown |
WorkloadType
Name | Description |
---|---|
server | component run as deployment |
cronjob | component run as CronJob |
daemonset | component run as DaemonSet |
statefulset | component run as StatefulSet |
Volume
Field | Type | Description | Required |
---|---|---|---|
path | string | Path within the container at which the volume should be mounted. | True |
hostPath | string | Required when VolumeType is: VolumeTypeHostPath,Path of the directory on the host. | False |
size | resource.Quantity | size of the volume | False |
type | VolumeType | type of storage used as volume | False |
storageClassName | *string | Name of the StorageClass required by the claim, used for VolumeTypePersistentVolumeClaim and VolumeTypePersistentVolumeClaimTemplate | False |
pvToMatch | string | for VolumeTypePersistentVolumeClaim, re-use volume which has the same same as set by PVToMatch | False |
pvc | string | for VolumeTypePersistentVolumeClaim and VolumeTypePersistentVolumeClaimTemplate, re-use exist PVC. | Flase |
VolumeType
Name | Description |
---|---|
emptyDirMemory | use memory as storage |
emptyDir | use disk as storage |
pvc | use PVC as storage |
pvcTemplate | use VolumeCliamTemplate as storage for StatefulSet |
hostpath | use host path as storage |
RunnerPermission
Field | Type | Description | Required |
---|---|---|---|
roleType | string | if is clusterRole , will bind ClusterRole to the serviceAccount of the pod, otherwise, will bind Role | False |
rules | rbacV1.PolicyRule[] | the PolicyRules for the binding ClusterRole or Role | False |
PreInjectFile
Field | Type | Description | Required |
---|---|---|---|
content | string | content of the file | True |
base64 | bool | To support binary content, it allows set base64 encoded data into Content field and set this flag to true . Binary data will be restored instead of plain string in Content . | False |
mountPath | string | the mount path of the file | True |
readonly | bool | if true , the file will be readonly, default to false | False |
runnable | bool | if true , the file can be executed, default to false | False |