diff --git a/api/bases/swift.openstack.org_swifts.yaml b/api/bases/swift.openstack.org_swifts.yaml index 75bd4a64..6cc5638c 100644 --- a/api/bases/swift.openstack.org_swifts.yaml +++ b/api/bases/swift.openstack.org_swifts.yaml @@ -344,6 +344,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + containerSharderEnabled: + default: false + description: If the container sharder daemon is enabled. + type: boolean memcachedServers: default: "" description: List of memcached servers. diff --git a/api/bases/swift.openstack.org_swiftstorages.yaml b/api/bases/swift.openstack.org_swiftstorages.yaml index 95e9a479..47509b53 100644 --- a/api/bases/swift.openstack.org_swiftstorages.yaml +++ b/api/bases/swift.openstack.org_swiftstorages.yaml @@ -60,6 +60,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + containerSharderEnabled: + default: false + description: If the container sharder daemon is enabled. + type: boolean memcachedServers: default: "" description: List of memcached servers. diff --git a/api/v1beta1/swiftstorage_types.go b/api/v1beta1/swiftstorage_types.go index 086161fd..253c9b82 100644 --- a/api/v1beta1/swiftstorage_types.go +++ b/api/v1beta1/swiftstorage_types.go @@ -70,6 +70,11 @@ type SwiftStorageSpec struct { // +kubebuilder:default="" // List of memcached servers. MemcachedServers string `json:"memcachedServers"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // If the container sharder daemon is enabled. + ContainerSharderEnabled bool `json:"containerSharderEnabled"` } // SwiftStorageStatus defines the observed state of SwiftStorage diff --git a/config/crd/bases/swift.openstack.org_swifts.yaml b/config/crd/bases/swift.openstack.org_swifts.yaml index 75bd4a64..6cc5638c 100644 --- a/config/crd/bases/swift.openstack.org_swifts.yaml +++ b/config/crd/bases/swift.openstack.org_swifts.yaml @@ -344,6 +344,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + containerSharderEnabled: + default: false + description: If the container sharder daemon is enabled. + type: boolean memcachedServers: default: "" description: List of memcached servers. diff --git a/config/crd/bases/swift.openstack.org_swiftstorages.yaml b/config/crd/bases/swift.openstack.org_swiftstorages.yaml index 95e9a479..47509b53 100644 --- a/config/crd/bases/swift.openstack.org_swiftstorages.yaml +++ b/config/crd/bases/swift.openstack.org_swiftstorages.yaml @@ -60,6 +60,10 @@ spec: containerImageProxy: description: Image URL for Swift proxy service type: string + containerSharderEnabled: + default: false + description: If the container sharder daemon is enabled. + type: boolean memcachedServers: default: "" description: List of memcached servers. diff --git a/controllers/swift_controller.go b/controllers/swift_controller.go index 430708d0..430f893b 100644 --- a/controllers/swift_controller.go +++ b/controllers/swift_controller.go @@ -395,6 +395,7 @@ func (r *SwiftReconciler) storageCreateOrUpdate(ctx context.Context, instance *s SwiftConfSecret: instance.Spec.SwiftConfSecret, NetworkAttachments: instance.Spec.SwiftStorage.NetworkAttachments, MemcachedServers: memcachedServers, + ContainerSharderEnabled: instance.Spec.SwiftStorage.ContainerSharderEnabled, } deployment := &swiftv1.SwiftStorage{ diff --git a/pkg/swiftstorage/statefulset.go b/pkg/swiftstorage/statefulset.go index e2831612..d8987caa 100644 --- a/pkg/swiftstorage/statefulset.go +++ b/pkg/swiftstorage/statefulset.go @@ -38,7 +38,7 @@ func getPorts(port int32, name string) []corev1.ContainerPort { func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Container { securityContext := swift.GetSecurityContext() - return []corev1.Container{ + containers := []corev1.Container{ { Name: "ring-sync", Image: swiftstorage.Spec.ContainerImageProxy, @@ -164,6 +164,19 @@ func getStorageContainers(swiftstorage *swiftv1beta1.SwiftStorage) []corev1.Cont Command: []string{"/usr/bin/rsync", "--daemon", "--no-detach", "--config=/etc/swift/rsyncd.conf", "--log-file=/dev/stdout"}, }, } + + if swiftstorage.Spec.ContainerSharderEnabled { + containers = append(containers, corev1.Container{ + Name: "container-sharder", + Image: swiftstorage.Spec.ContainerImageContainer, + ImagePullPolicy: corev1.PullIfNotPresent, + SecurityContext: &securityContext, + VolumeMounts: getStorageVolumeMounts(), + Command: []string{"/usr/bin/swift-container-sharder", "/etc/swift/container-server.conf", "-v"}, + }) + } + + return containers } func StatefulSet( diff --git a/templates/swiftstorage/config/container-server.conf b/templates/swiftstorage/config/container-server.conf index b5b75d4e..c537068e 100644 --- a/templates/swiftstorage/config/container-server.conf +++ b/templates/swiftstorage/config/container-server.conf @@ -21,5 +21,7 @@ use = egg:swift#recon [container-sync] +[container-sharder] + [filter:xprofile] use = egg:swift#xprofile diff --git a/templates/swiftstorage/config/internal-client.conf b/templates/swiftstorage/config/internal-client.conf new file mode 100644 index 00000000..185b23e9 --- /dev/null +++ b/templates/swiftstorage/config/internal-client.conf @@ -0,0 +1,20 @@ +[DEFAULT] + +[pipeline:main] +pipeline = catch_errors proxy-logging cache symlink proxy-server + +[app:proxy-server] +use = egg:swift#proxy +account_autocreate = true + +[filter:symlink] +use = egg:swift#symlink + +[filter:cache] +use = egg:swift#memcache + +[filter:proxy-logging] +use = egg:swift#proxy_logging + +[filter:catch_errors] +use = egg:swift#catch_errors