Skip to content

Commit

Permalink
[Enhancement] Support sidecars
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <yandongxiao@starrocks.com>
  • Loading branch information
yandongxiao committed Mar 7, 2024
1 parent 65f0bba commit b31d9a8
Show file tree
Hide file tree
Showing 12 changed files with 12,524 additions and 5,099 deletions.
11,763 changes: 7,755 additions & 4,008 deletions config/crd/bases/starrocks.com_starrocksclusters.yaml

Large diffs are not rendered by default.

1,249 changes: 1,249 additions & 0 deletions config/crd/bases/starrocks.com_starrockswarehouses.yaml

Large diffs are not rendered by default.

3,939 changes: 2,850 additions & 1,089 deletions deploy/starrocks.com_starrocksclusters.yaml

Large diffs are not rendered by default.

587 changes: 587 additions & 0 deletions deploy/starrocks.com_starrockswarehouses.yaml

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,22 @@ Set this value longer than the expected cleanup time for your process.
Defaults to 120 seconds.</p>
</td>
</tr>
<tr>
<td>
<code>sidecars</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#container-v1-core">
[]Kubernetes core/v1.Container
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
You can use this field to launch helper containers that provide additional functionality to the main container.
See <a href="https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container">https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container</a> for more details.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="starrocks.com/v1.StarRocksComponentStatus">StarRocksComponentStatus
Expand Down Expand Up @@ -2133,5 +2149,5 @@ AutoScalingPolicy
<hr/>
<p><em>
Generated with <code>gen-crd-api-reference-docs</code>
on git commit <code>cd02ea3</code>.
on git commit <code>425cd01</code>.
</em></p>
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ spec:
lifecycle:
{{- toYaml .Values.starrocksFESpec.lifecycle | nindent 6 }}
{{- end }}
{{- if .Values.starrocksFESpec.sidecars }}
sidecars:
{{- toYaml .Values.starrocksFESpec.sidecars | nindent 6 }}
{{- end }}
{{- if .Values.starrocksFESpec.secrets }}
secrets:
{{- range .Values.starrocksFESpec.secrets }}
Expand Down Expand Up @@ -366,6 +370,10 @@ spec:
lifecycle:
{{- toYaml .Values.starrocksBeSpec.lifecycle | nindent 6 }}
{{- end }}
{{- if .Values.starrocksBeSpec.sidecars }}
sidecars:
{{- toYaml .Values.starrocksBeSpec.sidecars | nindent 6 }}
{{- end }}
{{- if .Values.starrocksBeSpec.secrets }}
secrets:
{{- range .Values.starrocksBeSpec.secrets }}
Expand Down Expand Up @@ -532,6 +540,10 @@ spec:
lifecycle:
{{- toYaml .Values.starrocksCnSpec.lifecycle | nindent 6 }}
{{- end }}
{{- if .Values.starrocksCnSpec.sidecars }}
sidecars:
{{- toYaml .Values.starrocksCnSpec.sidecars | nindent 6 }}
{{- end }}
{{- if and .Values.starrocksCluster.enabledCn .Values.starrocksCnSpec.autoScalingPolicy }}
autoScalingPolicy:
{{- toYaml .Values.starrocksCnSpec.autoScalingPolicy | nindent 6 }}
Expand Down
12 changes: 12 additions & 0 deletions helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ starrocksFESpec:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# spec for compute node, compute node provide compute function.
starrocksCnSpec:
Expand Down Expand Up @@ -514,6 +518,10 @@ starrocksCnSpec:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# spec for component be, provide storage and compute function.
starrocksBeSpec:
Expand Down Expand Up @@ -697,6 +705,10 @@ starrocksBeSpec:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# create secrets if necessary.
secrets: []
Expand Down
12 changes: 12 additions & 0 deletions helm-charts/charts/kube-starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ starrocks:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# spec for compute node, compute node provide compute function.
starrocksCnSpec:
Expand Down Expand Up @@ -611,6 +615,10 @@ starrocks:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# spec for component be, provide storage and compute function.
starrocksBeSpec:
Expand Down Expand Up @@ -794,6 +802,10 @@ starrocks:
# - /bin/sh
# - -c
# - echo "Hello, world!"
# Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
# You can use this field to launch helper containers that provide additional functionality to the main container.
# See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars.
sidecars: []

# create secrets if necessary.
secrets: []
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/starrocks/v1/component_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ type StarRocksComponentSpec struct {
// Defaults to 120 seconds.
// +optional
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`

// Sidecars is an optional list of containers that are run in the same pod as the starrocks component.
// You can use this field to launch helper containers that provide additional functionality to the main container.
// See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container.
// +optional
Sidecars []corev1.Container `json:"sidecars,omitempty"`
}

// StarRocksComponentStatus represents the status of a starrocks component.
Expand Down Expand Up @@ -134,3 +140,7 @@ func (spec *StarRocksComponentSpec) GetTerminationGracePeriodSeconds() *int64 {
func (spec *StarRocksComponentSpec) GetCapabilities() *corev1.Capabilities {
return spec.Capabilities
}

func (spec *StarRocksComponentSpec) GetSidecars() []corev1.Container {
return spec.Sidecars
}
8 changes: 8 additions & 0 deletions pkg/apis/starrocks/v1/starrockscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type SpecInterface interface {
GetRunAsNonRoot() (*int64, *int64)
GetTerminationGracePeriodSeconds() *int64
GetCapabilities() *corev1.Capabilities
GetSidecars() []corev1.Container
}

var _ SpecInterface = &StarRocksFeSpec{}
Expand Down Expand Up @@ -195,9 +196,16 @@ func (spec *StarRocksFeProxySpec) GetTerminationGracePeriodSeconds() *int64 {
return nil
}

// GetCapabilities
// fe proxy does not have field Capabilities
func (spec *StarRocksFeProxySpec) GetCapabilities() *corev1.Capabilities { return nil }

// GetSidecars
// fe proxy does not have field Sidecars
func (spec *StarRocksFeProxySpec) GetSidecars() []corev1.Container {
return nil
}

// Phase is defined under status, e.g.
// 1. StarRocksClusterStatus.Phase represents the phase of starrocks cluster.
// 2. StarRocksWarehouseStatus.Phase represents the phase of starrocks warehouse.
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/starrocks/v1/zz_generated.deepcopy.go

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

6 changes: 5 additions & 1 deletion pkg/k8sutils/templates/pod/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ func Ports(spec v1.SpecInterface, config map[string]interface{}) []corev1.Contai
}

func Spec(spec v1.SpecInterface, container corev1.Container, volumes []corev1.Volume) corev1.PodSpec {
containers := []corev1.Container{container}
if len(spec.GetSidecars()) > 0 {
containers = append(containers, spec.GetSidecars()...)
}
podSpec := corev1.PodSpec{
Containers: []corev1.Container{container},
Containers: containers,
Volumes: volumes,
ServiceAccountName: spec.GetServiceAccount(),
TerminationGracePeriodSeconds: spec.GetTerminationGracePeriodSeconds(),
Expand Down

0 comments on commit b31d9a8

Please sign in to comment.