add namespace to master peers list
This commit is contained in:
parent
3ecd205e8e
commit
b0f01a5e1a
|
@ -17,7 +17,7 @@ func buildFilerStartupScript(m *seaweedv1.Seaweed) string {
|
||||||
commands = append(commands, fmt.Sprintf("-port=%d", seaweedv1.FilerHTTPPort))
|
commands = append(commands, fmt.Sprintf("-port=%d", seaweedv1.FilerHTTPPort))
|
||||||
commands = append(commands, fmt.Sprintf("-ip=$(POD_NAME).%s-filer-peer", m.Name))
|
commands = append(commands, fmt.Sprintf("-ip=$(POD_NAME).%s-filer-peer", m.Name))
|
||||||
commands = append(commands, fmt.Sprintf("-peers=%s", getFilerPeersString(m.Name, m.Spec.Filer.Replicas)))
|
commands = append(commands, fmt.Sprintf("-peers=%s", getFilerPeersString(m.Name, m.Spec.Filer.Replicas)))
|
||||||
commands = append(commands, fmt.Sprintf("-master=%s", getMasterPeersString(m.Name, m.Spec.Master.Replicas)))
|
commands = append(commands, fmt.Sprintf("-master=%s", getMasterPeersString(m)))
|
||||||
commands = append(commands, "-s3")
|
commands = append(commands, "-s3")
|
||||||
|
|
||||||
return strings.Join(commands, " ")
|
return strings.Join(commands, " ")
|
||||||
|
|
|
@ -32,7 +32,7 @@ func buildMasterStartupScript(m *seaweedv1.Seaweed) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
command = append(command, fmt.Sprintf("-ip=$(POD_NAME).%s-master-peer", m.Name))
|
command = append(command, fmt.Sprintf("-ip=$(POD_NAME).%s-master-peer", m.Name))
|
||||||
command = append(command, fmt.Sprintf("-peers=%s", getMasterPeersString(m.Name, spec.Replicas)))
|
command = append(command, fmt.Sprintf("-peers=%s", getMasterPeersString(m)))
|
||||||
return strings.Join(command, " ")
|
return strings.Join(command, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func buildVolumeServerStartupScript(m *seaweedv1.Seaweed, dirs []string) string
|
||||||
commands = append(commands, fmt.Sprintf("-port=%d", seaweedv1.VolumeHTTPPort))
|
commands = append(commands, fmt.Sprintf("-port=%d", seaweedv1.VolumeHTTPPort))
|
||||||
commands = append(commands, "-max=0")
|
commands = append(commands, "-max=0")
|
||||||
commands = append(commands, fmt.Sprintf("-ip=$(POD_NAME).%s-volume-peer", m.Name))
|
commands = append(commands, fmt.Sprintf("-ip=$(POD_NAME).%s-volume-peer", m.Name))
|
||||||
commands = append(commands, fmt.Sprintf("-mserver=%s", getMasterPeersString(m.Name, m.Spec.Master.Replicas)))
|
commands = append(commands, fmt.Sprintf("-mserver=%s", getMasterPeersString(m)))
|
||||||
commands = append(commands, fmt.Sprintf("-dir=%s", strings.Join(dirs, ",")))
|
commands = append(commands, fmt.Sprintf("-dir=%s", strings.Join(dirs, ",")))
|
||||||
|
|
||||||
return strings.Join(commands, " ")
|
return strings.Join(commands, " ")
|
||||||
|
|
|
@ -4,12 +4,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
masterPeerAddressPattern = "%s-master-%d.%s-master-peer:9333"
|
masterPeerAddressPattern = "%s-master-%d.%s-master-peer.%s:9333"
|
||||||
filerPeerAddressPattern = "%s-filer-%d.%s-filer-peer:8888"
|
filerPeerAddressPattern = "%s-filer-%d.%s-filer-peer:8888"
|
||||||
masterPeerAddressWithNamespacePattern = "%s-master-%d.%s-master-peer.%s:9333"
|
masterPeerAddressWithNamespacePattern = "%s-master-%d.%s-master-peer.%s:9333"
|
||||||
filerServiceAddressWithNamespacePattern = "%s-filer.%s:8888"
|
filerServiceAddressWithNamespacePattern = "%s-filer.%s:8888"
|
||||||
|
@ -64,16 +65,16 @@ func getFilerPeersString(name string, replicas int32) string {
|
||||||
return strings.Join(getFilerAddresses(name, replicas), ",")
|
return strings.Join(getFilerAddresses(name, replicas), ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMasterAddresses(name string, replicas int32) []string {
|
func getMasterAddresses(namespace string, name string, replicas int32) []string {
|
||||||
peersAddresses := make([]string, 0, replicas)
|
peersAddresses := make([]string, 0, replicas)
|
||||||
for i := int32(0); i < replicas; i++ {
|
for i := int32(0); i < replicas; i++ {
|
||||||
peersAddresses = append(peersAddresses, fmt.Sprintf(masterPeerAddressPattern, name, i, name))
|
peersAddresses = append(peersAddresses, fmt.Sprintf(masterPeerAddressPattern, name, i, name, namespace))
|
||||||
}
|
}
|
||||||
return peersAddresses
|
return peersAddresses
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMasterPeersString(name string, replicas int32) string {
|
func getMasterPeersString(m *seaweedv1.Seaweed) string {
|
||||||
return strings.Join(getMasterAddresses(name, replicas), ",")
|
return strings.Join(getMasterAddresses(m.Namespace, m.Name, m.Spec.Master.Replicas), ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMasterAddressesWithNamespace(name, namespace string, replicas int32) []string {
|
func getMasterAddressesWithNamespace(name, namespace string, replicas int32) []string {
|
||||||
|
|
Loading…
Reference in New Issue