diff --git a/api/v1alpha1/xlinecluster_types.go b/api/v1alpha1/xlinecluster_types.go index dcdeb629..d3eeaa21 100644 --- a/api/v1alpha1/xlinecluster_types.go +++ b/api/v1alpha1/xlinecluster_types.go @@ -51,65 +51,65 @@ type XlineClusterList struct { } type XlineArgs struct { - JaegerOffline bool `json:"jaeger-offline,omitempty"` - JaegerOnline bool `json:"jaeger-online,omitempty"` - JaegerLevel bool `json:"jaeger-level,omitempty"` - ClientUseBackoff bool `json:"client-use-backoff,omitempty"` - AuthPrivateKey *string `json:"auth-private-key,omitempty"` - AuthPublicKey *string `json:"auth-public-key,omitempty"` - JaegerOutputDir *string `json:"jaeger-output-dir,omitempty"` - LogFile *string `json:"log-file,omitempty"` - LogRotate *string `json:"log-rotate,omitempty"` - - // +kubebuilder:validation:Enum=off;info;error;warn;trace;debug - LogLevel *string `json:"log-level,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - HeartbeatInterval *string `json:"heartbeat-interval,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - ServerWaitSyncedTimeout *string `json:"server-wait-synced-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - RetryTimeout *string `json:"retry-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - RpcTimeout *string `json:"rpc-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - BatchTimeout *string `json:"batch-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - ClientWaitSyncedTimeout *string `json:"client-wait-synced-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - ClientProposeTimeout *string `json:"client-propose-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - ClientInitialRetryTimeout *string `json:"client-initial-retry-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - ClientMaxRetryTimeout *string `json:"client-max-retry-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - GcInterval *string `json:"gc-interval,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - RangeRetryTimeout *string `json:"range-retry-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - CompactTimeout *string `json:"compact-timeout,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - SyncVictimsInterval *string `json:"sync-victims-interval,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - WatchProgressNotifyInterval *string `json:"watch-progress-notify-interval,omitempty"` - CurpDir *string `json:"curp-dir,omitempty"` - // +kubebuilder:validation:Pattern=\d+(us|ms|s|m|h|d) - CompactSleepInterval *string `json:"compact-sleep-interval,omitempty"` - // +kubebuilder:validation:Pattern=\d+(B|MB|GB) - BatchMaxSize *string `json:"batch-max-size,omitempty"` + JaegerOffline bool `json:"JaegerOffline,omitempty"` + JaegerOnline bool `json:"JaegerOnline,omitempty"` + ClientUseBackoff bool `json:"ClientUseBackoff,omitempty"` + JaegerLevel *string `json:"JaegerLevel,omitempty"` + JaegerOutputDir *string `json:"JaegerOutputDir,omitempty"` + LogFile *string `json:"LogFile,omitempty"` + + // +kubebuilder:validation:Enum=never;hourly;daily + LogRotate *string `json:"LogRotate,omitempty"` + + // +kubebuilder:validation:Enum=trace;debug;info;warn;error + LogLevel *string `json:"LogLevel,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms) + HeartbeatInterval *string `json:"HeartbeatInterval,omitempty"` + // +kubebuilder:validation:Pattern=\d+(ms|s) + ServerWaitSyncedTimeout *string `json:"ServerWaitSyncedTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(ms|s) + RetryTimeout *string `json:"RetryTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + RpcTimeout *string `json:"RpcTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + BatchTimeout *string `json:"BatchTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + ClientWaitSyncedTimeout *string `json:"ClientWaitSyncedTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + ClientProposeTimeout *string `json:"ClientProposeTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + ClientInitialRetryTimeout *string `json:"ClientInitialRetryTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + ClientMaxRetryTimeout *string `json:"ClientMaxRetryTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + GcInterval *string `json:"GcInterval,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + RangeRetryTimeout *string `json:"RangeRetryTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + CompactTimeout *string `json:"CompactTimeout,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + SyncVictimsInterval *string `json:"SyncVictimsInterval,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + WatchProgressNotifyInterval *string `json:"WatchProgressNotifyInterval,omitempty"` + CurpDir *string `json:"CurpDir,omitempty"` + // +kubebuilder:validation:Pattern=\d+(us|ms|s) + CompactSleepInterval *string `json:"CompactSleepInterval,omitempty"` + // +kubebuilder:validation:Pattern=\d+(KB|MB|kb|mb) + BatchMaxSize *string `json:"BatchMaxSize,omitempty"` // +kubebuilder:validation:Minimum=1 - RetryCount int `json:"retry-count,omitempty"` + RetryCount int `json:"RetryCount,omitempty"` // +kubebuilder:validation:Minimum=1 - FollowerTimeoutTicks int `json:"follower-timeout-ticks,omitempty"` + FollowerTimeoutTicks int `json:"FollowerTimeoutTicks,omitempty"` // +kubebuilder:validation:Minimum=1 - CandidateTimeoutTicks int `json:"candidate-timeout-ticks,omitempty"` + CandidateTimeoutTicks int `json:"CandidateTimeoutTicks,omitempty"` // +kubebuilder:validation:Minimum=1 - LogEntriesCap int `json:"log-entries-cap,omitempty"` + LogEntriesCap int `json:"LogEntriesCap,omitempty"` // +kubebuilder:validation:Minimum=1 - CmdWorkers int `json:"cmd-workers,omitempty"` + CmdWorkers int `json:"CmdWorkers,omitempty"` // +kubebuilder:validation:Minimum=1 - CompactBatchSize int `json:"compact-batch-size,omitempty"` + CompactBatchSize int `json:"CompactBatchSize,omitempty"` // +kubebuilder:validation:Minimum=1 - Quota int `json:"quota,omitempty"` + Quota int `json:"Quota,omitempty"` } // ######################################## @@ -124,7 +124,7 @@ type XlineClusterSpec struct { /// Xline container bootstrap arguments /// Set additional arguments except [`--name`, `--members`, `--storage-engine`, `--data-dir`] - BootstrapArgs XlineArgs `json:"bootstrapArgs,omitempty"` + BootstrapArgs XlineArgs `json:"config,omitempty"` // ImagePullPolicy of Xline cluster Pods // +optional @@ -184,6 +184,7 @@ type XlineClusterStatus struct { type XlineClusterOprStage string const ( + StageXlineScriptCM XlineClusterOprStage = "Xline/ScriptCM" StageXlineService XlineClusterOprStage = "Xline/Service" StageXlineStatefulSet XlineClusterOprStage = "Xline/Statefulset" StageComplete XlineClusterOprStage = "complete" diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 7252e8c1..51bbe27b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -44,13 +44,8 @@ func (in *NamespacedName) DeepCopy() *NamespacedName { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *XlineArgs) DeepCopyInto(out *XlineArgs) { *out = *in - if in.AuthPrivateKey != nil { - in, out := &in.AuthPrivateKey, &out.AuthPrivateKey - *out = new(string) - **out = **in - } - if in.AuthPublicKey != nil { - in, out := &in.AuthPublicKey, &out.AuthPublicKey + if in.JaegerLevel != nil { + in, out := &in.JaegerLevel, &out.JaegerLevel *out = new(string) **out = **in } diff --git a/config/crd/bases/xline.io.datenlord.com_xlineclusters.yaml b/config/crd/bases/xline.io.datenlord.com_xlineclusters.yaml index c80a4320..a831d254 100644 --- a/config/crd/bases/xline.io.datenlord.com_xlineclusters.yaml +++ b/config/crd/bases/xline.io.datenlord.com_xlineclusters.yaml @@ -52,129 +52,128 @@ spec: - priKey - pubKey type: object - bootstrapArgs: + claims: + description: "Claims lists the names of resources, defined in spec.resourceClaims, + that are used by this container. \n This is an alpha field and requires + enabling the DynamicResourceAllocation feature gate. \n This field + is immutable. It can only be set for containers." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims + of the Pod where this field is used. It makes that resource + available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + config: description: / Xline container bootstrap arguments / Set additional arguments except [`--name`, `--members`, `--storage-engine`, `--data-dir`] properties: - auth-private-key: + BatchMaxSize: + pattern: \d+(KB|MB|kb|mb) type: string - auth-public-key: + BatchTimeout: + pattern: \d+(us|ms|s) type: string - batch-max-size: - pattern: \d+(B|MB|GB) - type: string - batch-timeout: - pattern: \d+(us|ms|s|m|h|d) - type: string - candidate-timeout-ticks: + CandidateTimeoutTicks: minimum: 1 type: integer - client-initial-retry-timeout: - pattern: \d+(us|ms|s|m|h|d) + ClientInitialRetryTimeout: + pattern: \d+(us|ms|s) type: string - client-max-retry-timeout: - pattern: \d+(us|ms|s|m|h|d) + ClientMaxRetryTimeout: + pattern: \d+(us|ms|s) type: string - client-propose-timeout: - pattern: \d+(us|ms|s|m|h|d) + ClientProposeTimeout: + pattern: \d+(us|ms|s) type: string - client-use-backoff: + ClientUseBackoff: type: boolean - client-wait-synced-timeout: - pattern: \d+(us|ms|s|m|h|d) + ClientWaitSyncedTimeout: + pattern: \d+(us|ms|s) type: string - cmd-workers: + CmdWorkers: minimum: 1 type: integer - compact-batch-size: + CompactBatchSize: minimum: 1 type: integer - compact-sleep-interval: - pattern: \d+(us|ms|s|m|h|d) + CompactSleepInterval: + pattern: \d+(us|ms|s) type: string - compact-timeout: - pattern: \d+(us|ms|s|m|h|d) + CompactTimeout: + pattern: \d+(us|ms|s) type: string - curp-dir: + CurpDir: type: string - follower-timeout-ticks: + FollowerTimeoutTicks: minimum: 1 type: integer - gc-interval: - pattern: \d+(us|ms|s|m|h|d) + GcInterval: + pattern: \d+(us|ms|s) type: string - heartbeat-interval: - pattern: \d+(us|ms|s|m|h|d) + HeartbeatInterval: + pattern: \d+(us|ms) type: string - jaeger-level: - type: boolean - jaeger-offline: + JaegerLevel: + type: string + JaegerOffline: type: boolean - jaeger-online: + JaegerOnline: type: boolean - jaeger-output-dir: + JaegerOutputDir: type: string - log-entries-cap: + LogEntriesCap: minimum: 1 type: integer - log-file: + LogFile: type: string - log-level: + LogLevel: enum: - - "off" - - info - - error - - warn - trace - debug + - info + - warn + - error type: string - log-rotate: + LogRotate: + enum: + - never + - hourly + - daily type: string - quota: + Quota: minimum: 1 type: integer - range-retry-timeout: - pattern: \d+(us|ms|s|m|h|d) + RangeRetryTimeout: + pattern: \d+(us|ms|s) type: string - retry-count: + RetryCount: minimum: 1 type: integer - retry-timeout: - pattern: \d+(us|ms|s|m|h|d) + RetryTimeout: + pattern: \d+(ms|s) type: string - rpc-timeout: - pattern: \d+(us|ms|s|m|h|d) + RpcTimeout: + pattern: \d+(us|ms|s) type: string - server-wait-synced-timeout: - pattern: \d+(us|ms|s|m|h|d) + ServerWaitSyncedTimeout: + pattern: \d+(ms|s) type: string - sync-victims-interval: - pattern: \d+(us|ms|s|m|h|d) + SyncVictimsInterval: + pattern: \d+(us|ms|s) type: string - watch-progress-notify-interval: - pattern: \d+(us|ms|s|m|h|d) + WatchProgressNotifyInterval: + pattern: \d+(us|ms|s) type: string type: object - claims: - description: "Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. \n This is an alpha field and requires - enabling the DynamicResourceAllocation feature gate. \n This field - is immutable. It can only be set for containers." - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: Name must match the name of one entry in pod.spec.resourceClaims - of the Pod where this field is used. It makes that resource - available inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map image: description: Xline cluster image type: string diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index f408b99c..874b3169 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -16,6 +16,18 @@ rules: - patch - update - watch +- apiGroups: + - "" + resources: + - configmaps + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - "" resources: @@ -24,6 +36,14 @@ rules: - get - list - watch +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - list + - watch - apiGroups: - "" resources: diff --git a/internal/controller/xlinecluster_controller.go b/internal/controller/xlinecluster_controller.go index ec0e26cf..067b7504 100644 --- a/internal/controller/xlinecluster_controller.go +++ b/internal/controller/xlinecluster_controller.go @@ -40,6 +40,8 @@ type XlineClusterReconciler struct { //+kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch +//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch func (r *XlineClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { recCtx := reconciler.NewReconcileContext(r.Client, r.Scheme, ctx) diff --git a/internal/reconciler/cluster_reconciler.go b/internal/reconciler/cluster_reconciler.go index ea0cca03..32ff5e67 100644 --- a/internal/reconciler/cluster_reconciler.go +++ b/internal/reconciler/cluster_reconciler.go @@ -68,12 +68,17 @@ func (r *ClusterStageRecResult) AsXlineClusterRecStatus() xapi.XlineClusterRecSt // reconcile xline cluster resources. func (r *XlineClusterReconciler) recXlineResources() ClusterStageRecResult { - // create a xline service + // create an xline script cm + configMap := tran.MakeScriptCM(r.CR, r.Schema) + if err := r.CreateOrUpdate(configMap, &corev1.ConfigMap{}); err != nil { + return clusterStageFail(xapi.StageXlineScriptCM, err) + } + // create an xline service service := tran.MakeService(r.CR, r.Schema) if err := r.CreateOrUpdate(service, &corev1.Service{}); err != nil { return clusterStageFail(xapi.StageXlineService, err) } - // create a xline statefulset + // create an xline statefulset statefulSet := tran.MakeStatefulSet(r.CR, r.Schema) if err := r.CreateOrUpdate(statefulSet, &appv1.StatefulSet{}); err != nil { return clusterStageFail(xapi.StageXlineStatefulSet, err) diff --git a/internal/transformer/start_script.go b/internal/transformer/start_script.go new file mode 100644 index 00000000..b347d218 --- /dev/null +++ b/internal/transformer/start_script.go @@ -0,0 +1,46 @@ +package transformer + +const ( + DataDir = "/usr/local/xline/data-dir" + XlineStartScript = `#!/bin/bash + +function process_cmd_args() { + local envs=("${!1}") + is_bool=$2 + args="" + for arg_name in "${envs[@]}"; do + if [ -n "${!arg_name}" ]; then + arg=$(echo "-$arg_name" | sed 's/\([A-Z]\)/-\L\1/g') + if [ "$is_bool" = true ]; then + args="${args} ${arg} " + else + args="${args} ${arg} ${!arg_name} " + fi + fi + done + echo $args +} + +bool_envs=("JaegerOffline" "JaegerOnline" "ClientUseBackoff") +number_envs=("RetryCount" "FollowerTimeoutTicks" "CandidateTimeoutTicks" + "LogEntriesCap" "CmdWorkers" "CompactBatchSize" "Quota") +unit_envs=("HeartbeatInterval" "ServerWaitSyncedTimeout" "RetryTimeout" + "RpcTimeout" "BatchTimeout" "ClientWaitSyncedTimeout" + "ClientProposeTimeout" "ClientInitialRetryTimeout" "ClientMaxRetryTimeout" + "GcInterval" "RangeRetryTimeout" "CompactTimeout" "SyncVictimsInterval" + "WatchProgressNotifyInterval" "CompactSleepInterval" "BatchMaxSize") +enum_envs=("JaegerLevel" "LogRotate" "LogLevel") +file_envs=("JaegerOutputDir" "LogFile" "CurpDir" "DataDir" "AuthPrivateKey" "AuthPublicKey") + +cmd="/usr/local/bin/xline --name $HOSTNAME --members $MEMBERS --storage-engine rocksdb --data-dir /usr/local/xline/data-dir" + +cmd="${cmd} \ + $(process_cmd_args bool_envs[@] true) \ + $(process_cmd_args number_envs[@] false) \ + $(process_cmd_args unit_envs[@] false) \ + $(process_cmd_args enum_envs[@] false) \ + $(process_cmd_args file_envs[@] false)" + +exec $cmd +` +) diff --git a/internal/transformer/xlinecluster_resource.go b/internal/transformer/xlinecluster_resource.go index a037ee3c..1f162d64 100644 --- a/internal/transformer/xlinecluster_resource.go +++ b/internal/transformer/xlinecluster_resource.go @@ -16,7 +16,6 @@ import ( const ( XlinePort = 2379 - DataDir = "/usr/local/xline/data-dir" ) func GetXlineInstanceLabels(xlineClusterName types.NamespacedName) map[string]string { @@ -34,36 +33,22 @@ func GetMemberTopology(cr *xapi.XlineCluster) string { return strings.Join(members, ",") } -func GetAuthSecretVolume(auth_sec *xapi.XlineAuthSecret) []corev1.Volume { +func getAuthInfo(auth_sec *xapi.XlineAuthSecret) ([]corev1.Volume, []corev1.VolumeMount, []corev1.EnvVar) { if auth_sec == nil { - return []corev1.Volume{} + return []corev1.Volume{}, []corev1.VolumeMount{}, []corev1.EnvVar{} } return []corev1.Volume{ - {Name: "auth-cred", VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: *auth_sec.Name, - }, - }}, - } -} - -func GetAuthSecretVolumeMount(auth_sec *xapi.XlineAuthSecret) []corev1.VolumeMount { - if auth_sec == nil { - return []corev1.VolumeMount{} - } - return []corev1.VolumeMount{ - {Name: "auth-cred", ReadOnly: true, MountPath: *auth_sec.MountPath}, - } -} - -func GetAuthSecretEnvVars(auth_sec *xapi.XlineAuthSecret) []corev1.EnvVar { - if auth_sec == nil { - return []corev1.EnvVar{} - } - return []corev1.EnvVar{ - {Name: "AUTH_PUBLIC_KEY", Value: fmt.Sprintf("%s/%s", *auth_sec.MountPath, *auth_sec.PubKey)}, - {Name: "AUTH_PRIVATE_KEY", Value: fmt.Sprintf("%s/%s", *auth_sec.MountPath, *auth_sec.PriKey)}, - } + {Name: "auth-cred", VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: *auth_sec.Name, + }, + }}, + }, []corev1.VolumeMount{ + {Name: "auth-cred", ReadOnly: true, MountPath: *auth_sec.MountPath}, + }, []corev1.EnvVar{ + {Name: "AuthPublicKey", Value: fmt.Sprintf("%s/%s", *auth_sec.MountPath, *auth_sec.PubKey)}, + {Name: "AuthPrivateKey", Value: fmt.Sprintf("%s/%s", *auth_sec.MountPath, *auth_sec.PriKey)}, + } } func MakeService(cr *xapi.XlineCluster, scheme *runtime.Scheme) *corev1.Service { @@ -88,32 +73,52 @@ func MakeService(cr *xapi.XlineCluster, scheme *runtime.Scheme) *corev1.Service return service } +func MakeScriptCM(cr *xapi.XlineCluster, scheme *runtime.Scheme) *corev1.ConfigMap { + cm := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("%s-script", cr.Name), + Namespace: cr.Namespace, + Labels: GetXlineInstanceLabels(cr.ObjKey()), + }, + Data: map[string]string{ + "startup-script": XlineStartScript, + }, + } + _ = controllerutil.SetOwnerReference(cr, cm, scheme) + return cm +} + func MakeStatefulSet(cr *xapi.XlineCluster, scheme *runtime.Scheme) *appv1.StatefulSet { crName := types.NamespacedName{Namespace: cr.Namespace, Name: cr.Name} stsLabels := GetXlineInstanceLabels(crName) - initCmd := []string{ - "xline", - "--name", "$(POD_NAME)", - "--members", "$(MEMBERS)", - "--storage-engine", "rocksdb", - "--data-dir", DataDir, - } - initCmd = append(initCmd, cr.Spec.BootArgs()...) - envs := []corev1.EnvVar{ {Name: "MEMBERS", Value: GetMemberTopology(cr)}, - {Name: "POD_NAME", ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", + } + + volumes := []corev1.Volume{ + { + Name: "startup-script", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: fmt.Sprintf("%s-script", cr.Name), + }, + Items: []corev1.KeyToPath{{Key: "startup-script", Path: "xline_start_script.sh"}}, + }, }, - }}, + }, + } + + volumeMounts := []corev1.VolumeMount{ + {Name: "xline-storage", MountPath: DataDir}, + {Name: "startup-script", ReadOnly: true, MountPath: "/usr/local/script"}, } - envs = append(envs, GetAuthSecretEnvVars(cr.Spec.AuthSecrets)...) - volumes := GetAuthSecretVolume(cr.Spec.AuthSecrets) - volumeMounts := GetAuthSecretVolumeMount(cr.Spec.AuthSecrets) - volumeMounts = append(volumeMounts, corev1.VolumeMount{Name: "xline-storage", MountPath: "/usr/local/xline/data-dir"}) + authVol, authVM, authEnvs := getAuthInfo(cr.Spec.AuthSecrets) + volumes = append(volumes, authVol...) + volumeMounts = append(volumeMounts, authVM...) + envs = append(envs, authEnvs...) pvcTemplates := []corev1.PersistentVolumeClaim{ util.NewReadWriteOncePVC("xline-storage", cr.Spec.StorageClassName, cr.Spec.Requests.Storage()), @@ -127,7 +132,7 @@ func MakeStatefulSet(cr *xapi.XlineCluster, scheme *runtime.Scheme) *appv1.State Ports: []corev1.ContainerPort{ {Name: "xline-port", ContainerPort: XlinePort}, }, - Command: initCmd, + Command: []string{"/bin/bash", "/usr/local/script/xline_start_script.sh"}, Env: envs, VolumeMounts: volumeMounts, } diff --git a/tests/e2e/cases/manifests/cluster.yaml b/tests/e2e/cases/manifests/cluster.yaml index 95cb9bef..f1015d01 100644 --- a/tests/e2e/cases/manifests/cluster.yaml +++ b/tests/e2e/cases/manifests/cluster.yaml @@ -14,6 +14,5 @@ spec: mountPath: /tmp/auth-cred pubKey: auth-jwt.pub priKey: auth-jwt.pri - bootstrapArgs: - auth-private-key: /tmp/auth-cred/auth-jwt.pri - auth-public-key: /tmp/auth-cred/auth-jwt.pub + config: + ClientUseBackoff: true