Skip to content

Commit 067ba70

Browse files
committed
examples: add yaml for standalone and cluster modes
1 parent ced10c1 commit 067ba70

13 files changed

Lines changed: 64 additions & 18 deletions

apis/v1/types.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ type ApplicationSpec struct {
4343

4444
// ComponentRef references a Component within an Application
4545
type ComponentRef struct {
46-
Name string `yaml:"name"` // Component name
47-
VirtualMachineSpec string `yaml:"virtualMachineSpec"` // Reusable VM spec name
48-
Replicas int `yaml:"replicas"` // Number of VM replicas
46+
Name string `yaml:"name"` // Component name
47+
VirtualMachineSpec string `yaml:"virtualMachineSpec"` // Reusable VM spec name
48+
Replicas int `yaml:"replicas"` // Number of VM replicas
49+
HealthChecks []HealthCheck `yaml:"healthChecks,omitempty" gorm:"serializer:json"`
50+
}
51+
52+
// HealthCheck defines a simple health check configuration for VMs
53+
type HealthCheck struct {
54+
Type string `yaml:"type"` // e.g. ping, http
55+
Interval string `yaml:"interval,omitempty"` // e.g. 10s
56+
Timeout string `yaml:"timeout,omitempty"` // e.g. 5s
57+
Path string `yaml:"path,omitempty"` // HTTP path for http checks
58+
Port int `yaml:"port,omitempty"` // Optional port for TCP/HTTP checks
4959
}
5060

5161
// Component represents a set of VMs for a specific role (e.g. frontend/backend)
@@ -67,6 +77,7 @@ type ComponentSpec struct {
6777
VirtualMachineSpec string `yaml:"virtualMachineSpec"` // Reusable VM spec name
6878
Replicas int `yaml:"replicas"` // Number of VM replicas
6979
Overrides ComponentOverrides `yaml:"overrides,omitempty" gorm:"serializer:json"`
80+
HealthChecks []HealthCheck `yaml:"healthChecks,omitempty" gorm:"serializer:json"`
7081
}
7182

7283
// ComponentOverrides allows limited, safe overrides to a reused VM spec
@@ -91,15 +102,16 @@ type VirtualMachine struct {
91102

92103
// VirtualMachineSpec defines reusable VM configuration (template/offering/network)
93104
type VirtualMachineSpec struct {
94-
ProjectID string `yaml:"projectId"` // CloudStack project ID
95-
Template string `yaml:"template"` // VM template name/ID
96-
ServiceOffering string `yaml:"serviceOffering"` // VM service offering (size)
97-
NetworkIDs []string `yaml:"networkIds" gorm:"serializer:json"` // Attached networks
98-
SSHKeys []string `yaml:"sshKeys" gorm:"serializer:json"` // SSH keys for access
99-
SecurityGroups []string `yaml:"securityGroups" gorm:"serializer:json"` // Firewall groups
100-
AffinityGroups []string `yaml:"affinityGroups" gorm:"serializer:json"` // Host/VM affinity rules
101-
UserDataRefs []string `yaml:"userDataRefs,omitempty" gorm:"serializer:json"` // Optional references to UserData resources
102-
Volumes []VolumeSpec `yaml:"volumes,omitempty" gorm:"serializer:json"` // Desired or observed attached volumes
105+
ProjectID string `yaml:"projectId"` // CloudStack project ID
106+
Template string `yaml:"template"` // VM template name/ID
107+
ServiceOffering string `yaml:"serviceOffering"` // VM service offering (size)
108+
NetworkIDs []string `yaml:"networkIds" gorm:"serializer:json"` // Attached networks
109+
SSHKeys []string `yaml:"sshKeys" gorm:"serializer:json"` // SSH keys for access
110+
SecurityGroups []string `yaml:"securityGroups" gorm:"serializer:json"` // Firewall groups
111+
AffinityGroups []string `yaml:"affinityGroups" gorm:"serializer:json"` // Host/VM affinity rules
112+
UserDataRefs []string `yaml:"userDataRefs,omitempty" gorm:"serializer:json"` // Optional references to UserData resources
113+
Volumes []VolumeSpec `yaml:"volumes,omitempty" gorm:"serializer:json"` // Desired or observed attached volumes
114+
HealthChecks []HealthCheck `yaml:"healthChecks,omitempty" gorm:"serializer:json"`
103115
}
104116

105117
// VirtualMachineSpecResource is the persisted wrapper for reusable VM specs

examples/cluster/application.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: cloudstackctl/v1
2+
kind: Application
3+
metadata:
4+
name: example-app
5+
spec:
6+
components:
7+
- name: frontend
8+
replicas: 2
9+
- name: backend
10+
replicas: 1

examples/cluster/component.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: cloudstackctl/v1
2+
kind: Component
3+
metadata:
4+
name: frontend
5+
spec:
6+
vmSpec:
7+
name: frontend-vmspec
8+
template: my-template
9+
serviceOffering: small
10+
count: 2
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: cloudstackctl/v1
2+
kind: VirtualMachine
3+
metadata:
4+
name: example-vm-cluster
5+
spec:
6+
virtualMachineSpec: frontend-vmspec
7+
projectId: ""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: cloudstackctl/v1
2+
kind: VirtualMachineSpec
3+
metadata:
4+
name: frontend-vmspec
5+
spec:
6+
template: my-template
7+
serviceOffering: small
8+
networkIDs:
9+
- example-network
10+
sshKeys:
11+
- my-key

0 commit comments

Comments
 (0)