|
9 | 9 | "fmt"
|
10 | 10 | "regexp"
|
11 | 11 | "sort"
|
| 12 | + "strings" |
12 | 13 |
|
13 | 14 | autoscalev2beta2 "k8s.io/api/autoscaling/v2beta2"
|
14 | 15 | networkingv1 "k8s.io/api/networking/v1"
|
@@ -1138,6 +1139,21 @@ func getVolume(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, nodeSpecUniq
|
1138 | 1139 | return volumesHolder
|
1139 | 1140 | }
|
1140 | 1141 |
|
| 1142 | +func getCommand(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []string { |
| 1143 | + if m.Spec.StartScript != "" && m.Spec.EntryArg != "" { |
| 1144 | + return []string{m.Spec.StartScript} |
| 1145 | + } |
| 1146 | + return []string{firstNonEmptyStr(m.Spec.StartScript, "bin/run-druid.sh"), nodeSpec.NodeType} |
| 1147 | +} |
| 1148 | + |
| 1149 | +func getEntryArg(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []string { |
| 1150 | + if m.Spec.EntryArg != "" { |
| 1151 | + bashCommands := strings.Join([]string{m.Spec.EntryArg, "&&", firstNonEmptyStr(m.Spec.DruidScript, "bin/run-druid.sh"), nodeSpec.NodeType}, " ") |
| 1152 | + return []string{"-c", bashCommands} |
| 1153 | + } |
| 1154 | + return nil |
| 1155 | +} |
| 1156 | + |
1141 | 1157 | func getEnv(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, configMapSHA string) []v1.EnvVar {
|
1142 | 1158 | envHolder := firstNonNilValue(nodeSpec.Env, m.Spec.Env).([]v1.EnvVar)
|
1143 | 1159 | // enables to do the trick to force redeployment in case of configmap changes.
|
@@ -1308,7 +1324,8 @@ func makePodSpec(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, nodeSpecUn
|
1308 | 1324 | v1.Container{
|
1309 | 1325 | Image: firstNonEmptyStr(nodeSpec.Image, m.Spec.Image),
|
1310 | 1326 | Name: fmt.Sprintf("%s", nodeSpecUniqueStr),
|
1311 |
| - Command: []string{firstNonEmptyStr(m.Spec.StartScript, "bin/run-druid.sh"), nodeSpec.NodeType}, |
| 1327 | + Command: getCommand(nodeSpec, m), |
| 1328 | + Args: getEntryArg(nodeSpec, m), |
1312 | 1329 | ImagePullPolicy: v1.PullPolicy(firstNonEmptyStr(string(nodeSpec.ImagePullPolicy), string(m.Spec.ImagePullPolicy))),
|
1313 | 1330 | Ports: nodeSpec.Ports,
|
1314 | 1331 | Resources: nodeSpec.Resources,
|
|
0 commit comments