Skip to content

Commit

Permalink
Change enrichments from implicit annotations to explicit decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
fnikol committed Dec 7, 2021
1 parent 9bb919c commit 25a87a4
Show file tree
Hide file tree
Showing 64 changed files with 33,908 additions and 22,004 deletions.
61 changes: 34 additions & 27 deletions api/v1alpha1/service_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Agents are sidecar services will be deployed in the same Pod as the Service container.
type Agents struct {
// Telemetry is a list of references to monitoring packages.
// +optional
Telemetry []string `json:"telemetry,omitempty"`
}

// NIC specifies the capabilities of the emulated network interface.
type NIC struct {
Rate string `json:"rate,omitempty"`
Expand Down Expand Up @@ -63,43 +56,57 @@ type Resources struct {

// ServiceSpec defines the desired state of Service.
type ServiceSpec struct {
// Requirements points to Kinds and their respective configurations required for the Service operation.
// For example, this field can be used to create PVCs dedicated to this service.
// +optional
Requirements map[string]string `json:"requirements,omitempty"`
Requirements *Requirements `json:"requirements,omitempty"`

// FromTemplate populates the service fields from a template. This is used for backward compatibility
// with Cluster with just one instance. This field cannot be used in conjunction with other fields.
// +optional
FromTemplate *GenerateFromTemplate `json:"fromTemplate,omitempty"`
Decorators *Decorators `json:"decorators,omitempty"`

// List of sidecar agents
// +kubebuilder:validation:Optional
// +optional
Agents *Agents `json:"agents,omitempty"`
corev1.PodSpec `json:",inline,omitempty"`
}

// Container is the container running the application
Container corev1.Container `json:"container,omitempty"`
type Requirements struct {
// +optional
PVC *PVC `json:"persistentVolumeClaim,omitempty"`
}

type Placement struct {
Domain []string `json:"domain,omitempty"`
}

type PVC struct {
Name string `json:"name"`
Spec corev1.PersistentVolumeClaimSpec `json:"spec,omitempty"`
}

// Decorators takes in a PodSpec, add some functionality and returns it.
type Decorators struct {
// Resources specifies limitations as to how the container will access host resources.
// +optional
Resources *Resources `json:"resources,omitempty"`

// List of volumes that can be mounted by containers belonging to the pod.
// Telemetry is a list of referenced agents responsible to monitor the Service.
// Agents are sidecar services will be deployed in the same Pod as the Service container.
// +optional
Volumes []corev1.Volume `json:"volumes,omitempty"`
Telemetry []string `json:"telemetry,omitempty"`

// Domain specifies the location where Service will be placed.
// Requirements points to Kinds and their respective configurations required for the Service operation.
// For example, this field can be used to create PVCs dedicated to this service.
// +optional
Domain []string `json:"domain,omitempty"`
// Requirements map[string]string `json:"requirements,omitempty"`

// Pod is used as the base for building the container
// +optional
Advanced `json:",inline"`
}
// Container is the container running the application
// Container corev1.Container `json:"container,omitempty"`

type Advanced struct {
// Domain specifies the location where Service will be placed.
// +optional
HostNetwork bool `json:"hostNetwork,omitempty"`
Placement *Placement `json:"placement,omitempty"`

// Dashboard is dashboard payload that will be installed in Grafana.
// This option is only applicable to Agents.
Dashboards metav1.LabelSelector `json:"dashboards,omitempty"`
}

// ServiceStatus defines the observed state of Service.
Expand Down
11 changes: 0 additions & 11 deletions api/v1alpha1/template_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ type Inputs struct {
Parameters map[string]string `json:"parameters,omitempty"`
}

type MonitorSpec struct {
// Agent is the sidecar that will be deployed in the same pod as the app
Agent ServiceSpec `json:"agent,omitempty"`

// Dashboard is dashboard payload that will be installed in Grafana.
Dashboards metav1.LabelSelector `json:"dashboards,omitempty"`
}

// TemplateSpec defines the desired state of Template
type TemplateSpec struct {
// Inputs are dynamic fields that populate the spec.
Expand All @@ -47,9 +39,6 @@ type TemplateSpec struct {
type EmbedSpecs struct {
// +optional
Service *ServiceSpec `json:"service,omitempty"`

// +optional
Monitor *MonitorSpec `json:"monitor,omitempty"`
}

// TemplateStatus defines the observed state of Template
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/workflow_crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type WaitSpec struct {

type EmbedActions struct {
// +optional
Service *ServiceSpec `json:"service,omitempty"`
Service *GenerateFromTemplate `json:"service,omitempty"`

// +optional
Cluster *ClusterSpec `json:"cluster,omitempty"`
Expand Down
168 changes: 86 additions & 82 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spec:
- action: Service
name: master
service:
fromTemplate:

templateRef: redis.single.master

# This action is same as before, with two additions.
Expand All @@ -56,7 +56,7 @@ spec:
name: slave
depends: { running: [ master ] }
service:
fromTemplate:

templateRef: redis.single.slave
inputs:
- { master: .service.master.any }
Expand All @@ -66,7 +66,7 @@ spec:
name: sentinel
depends: { running: [ master, slave ] }
service:
fromTemplate:

templateRef: redis.single.sentinel
inputs:
- { master: .service.master.any }
Expand Down
Loading

0 comments on commit 25a87a4

Please sign in to comment.