Skip to content

Commit

Permalink
cluster: allow to mount volumes in agent container (#299)
Browse files Browse the repository at this point in the history
Fixes #299
  • Loading branch information
zimnx committed Dec 29, 2020
1 parent 07950cd commit 19c0ab7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 7 deletions.
Expand Up @@ -143,6 +143,34 @@ spec:
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
agentVolumeMounts:
description: AgentVolumeMounts to be added to Agent container.
items:
description: VolumeMount describes a mounting of a Volume within a container.
properties:
mountPath:
description: Path within the container at which the volume should be mounted. Must not contain ':'.
type: string
mountPropagation:
description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
type: boolean
subPath:
description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
type: string
subPathExpr:
description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
members:
description: Members is the number of Scylla instances in this rack.
format: int32
Expand Down Expand Up @@ -582,7 +610,7 @@ spec:
type: object
type: array
volumes:
description: Volumes added to Scylla container.
description: Volumes added to Scylla Pod.
items:
description: Volume represents a named volume in a pod that may be accessed by any container in the pod.
properties:
Expand Down
30 changes: 29 additions & 1 deletion examples/common/operator.yaml
Expand Up @@ -158,6 +158,34 @@ spec:
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
agentVolumeMounts:
description: AgentVolumeMounts to be added to Agent container.
items:
description: VolumeMount describes a mounting of a Volume within a container.
properties:
mountPath:
description: Path within the container at which the volume should be mounted. Must not contain ':'.
type: string
mountPropagation:
description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
type: boolean
subPath:
description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
type: string
subPathExpr:
description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
members:
description: Members is the number of Scylla instances in this rack.
format: int32
Expand Down Expand Up @@ -597,7 +625,7 @@ spec:
type: object
type: array
volumes:
description: Volumes added to Scylla container.
description: Volumes added to Scylla Pod.
items:
description: Volume represents a named volume in a pod that may be accessed by any container in the pod.
properties:
Expand Down
2 changes: 1 addition & 1 deletion examples/generic/cluster.yaml
Expand Up @@ -104,6 +104,6 @@ spec:
- name: coredumpfs
hostPath:
path: /tmp/coredumps
volumeMounts:
agentVolumeMounts:
- mountPath: /tmp/coredumps
name: coredumpfs
8 changes: 5 additions & 3 deletions pkg/api/v1alpha1/cluster_types.go
Expand Up @@ -196,10 +196,12 @@ type RackSpec struct {
Resources corev1.ResourceRequirements `json:"resources"`
// AgentResources which Agent container will use.
AgentResources corev1.ResourceRequirements `json:"agentResources,omitempty"`
// Volumes added to Scylla container.
Volumes []corev1.Volume `json:"volumes,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name" protobuf:"bytes,1,rep,name=volumes"`
// Volumes added to Scylla Pod.
Volumes []corev1.Volume `json:"volumes,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`
// VolumeMounts to be added to Scylla container.
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty" patchStrategy:"merge" patchMergeKey:"mountPath" protobuf:"bytes,9,rep,name=volumeMounts"`
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty" patchStrategy:"merge" patchMergeKey:"mountPath"`
// AgentVolumeMounts to be added to Agent container.
AgentVolumeMounts []corev1.VolumeMount `json:"agentVolumeMounts,omitempty" patchStrategy:"merge" patchMergeKey:"mountPath"`
// Scylla config map name to customize scylla.yaml
ScyllaConfig string `json:"scyllaConfig"`
// Scylla config map name to customize scylla manager agent
Expand Down
7 changes: 7 additions & 0 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 7 additions & 1 deletion pkg/controllers/cluster/resource/resource.go
Expand Up @@ -437,7 +437,7 @@ func sysctlInitContainer(sysctls []string) *corev1.Container {
}

func agentContainer(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) corev1.Container {
return corev1.Container{
cnt := corev1.Container{
Name: "scylla-manager-agent",
Image: agentImageForCluster(c),
ImagePullPolicy: "IfNotPresent",
Expand Down Expand Up @@ -466,6 +466,12 @@ func agentContainer(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster)
},
Resources: r.AgentResources,
}

for _, vm := range r.AgentVolumeMounts {
cnt.VolumeMounts = append(cnt.VolumeMounts, *vm.DeepCopy())
}

return cnt
}

func ImageForCluster(c *scyllav1alpha1.ScyllaCluster) string {
Expand Down

0 comments on commit 19c0ab7

Please sign in to comment.