mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-20 08:13:23 +00:00
* StatefulSet Draft Signed-off-by: jguionnet <jguionnet@guidewire.com> * First running version Signed-off-by: jguionnet <jguionnet@guidewire.com> * Add generated component definition Signed-off-by: jguionnet <jguionnet@guidewire.com> * Adding an statefulset example inline with the component doc Signed-off-by: jguionnet <jguionnet@guidewire.com> * Adjustment to an example defining a simplistic statefulset and trait Signed-off-by: jguionnet <jguionnet@guidewire.com> * Fix PR Review comments Signed-off-by: jguionnet <jguionnet@guidewire.com> * After running make reviewable and more ... Signed-off-by: jguionnet <jguionnet@guidewire.com> --------- Signed-off-by: jguionnet <jguionnet@guidewire.com>
2.4 KiB
2.4 KiB
The Kubevela platform out of the box provides supported and complete StatefulSet component and Storage trait. This example is just provided for education.
Please check also the online documentation:
Yet another example defining a custom component and custom trait
- define a stateful component with StatefulSet as output
$ vela def apply stateful.cue
ComponentDefinition test-stateful created in namespace vela-system.
- define a custom trait with patch volume
$ vela def apply volume-trait.cue
TraitDefinition storageclass created in namespace vela-system.
- You can validate it by:
$ vela def vet volume-trait.cue
Validation succeed.
- try dry run your app:
vela dry-run -f app.yaml
# Application(website) -- Component(custom-component)
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations: {}
labels:
app.oam.dev/appRevision: ""
app.oam.dev/component: custom-component
app.oam.dev/name: website
app.oam.dev/namespace: default
app.oam.dev/resourceType: WORKLOAD
workload.oam.dev/type: test-stateful
name: custom-component
namespace: default
spec:
minReadySeconds: 10
replicas: 1
selector:
matchLabels:
app: custom-component
serviceName: custom-component
template:
metadata:
labels:
app: custom-component
spec:
containers:
- image: nginx:latest
name: nginx
ports:
- containerPort: 80
name: web
volumeMounts:
- mountPath: /usr/share/nginx/html
name: test
terminationGracePeriodSeconds: 10
volumeClaimTemplates:
- metadata:
name: test
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: cbs
---
apiVersion: v1
kind: Service
metadata:
annotations: {}
labels:
app: custom-component
app.oam.dev/appRevision: ""
app.oam.dev/component: custom-component
app.oam.dev/name: website
app.oam.dev/namespace: default
app.oam.dev/resourceType: TRAIT
trait.oam.dev/resource: web
trait.oam.dev/type: AuxiliaryWorkload
name: custom-component
namespace: default
spec:
clusterIP: None
ports:
- name: web
port: 80
selector:
app: custom-component