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 Apr 1, 2024
1 parent 8bff52b commit 367ca4d
Show file tree
Hide file tree
Showing 12 changed files with 11,729 additions and 4,304 deletions.
9,431 changes: 6,589 additions & 2,842 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.

4,683 changes: 3,222 additions & 1,461 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.

16 changes: 16 additions & 0 deletions 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
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 @@ -300,6 +300,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 @@ -522,6 +526,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 @@ -707,6 +715,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 @@ -408,6 +408,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 @@ -630,6 +634,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 @@ -815,6 +823,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 367ca4d

Please sign in to comment.