Merge pull request #33 from kvaster/peers-namespace

Always use dns names with namespace
This commit is contained in:
Chris Lu 2021-04-23 17:31:39 -07:00 committed by GitHub
commit 6bde7140d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -15,8 +15,8 @@ import (
func buildFilerStartupScript(m *seaweedv1.Seaweed) string { func buildFilerStartupScript(m *seaweedv1.Seaweed) string {
commands := []string{"weed", "filer"} commands := []string{"weed", "filer"}
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.%s", m.Name, m.Namespace))
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.Namespace, m.Spec.Filer.Replicas)))
commands = append(commands, fmt.Sprintf("-master=%s", getMasterPeersString(m))) commands = append(commands, fmt.Sprintf("-master=%s", getMasterPeersString(m)))
commands = append(commands, "-s3") commands = append(commands, "-s3")

View File

@ -16,7 +16,7 @@ func buildVolumeServerStartupScript(m *seaweedv1.Seaweed, dirs []string) string
commands := []string{"weed", "volume"} commands := []string{"weed", "volume"}
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,%s", m.Name, m.Namespace))
if m.Spec.HostSuffix != nil && *m.Spec.HostSuffix != "" { if m.Spec.HostSuffix != nil && *m.Spec.HostSuffix != "" {
commands = append(commands, fmt.Sprintf("-publicUrl=$(POD_NAME).%s", *m.Spec.HostSuffix)) commands = append(commands, fmt.Sprintf("-publicUrl=$(POD_NAME).%s", *m.Spec.HostSuffix))
} }

View File

@ -11,7 +11,7 @@ import (
const ( const (
masterPeerAddressPattern = "%s-master-%d.%s-master-peer.%s: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.%s:8888"
) )
var ( var (
@ -50,16 +50,16 @@ func ReconcileResult(err error) (bool, ctrl.Result, error) {
return false, ctrl.Result{}, nil return false, ctrl.Result{}, nil
} }
func getFilerAddresses(name string, replicas int32) []string { func getFilerAddresses(name string, namespace 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(filerPeerAddressPattern, name, i, name)) peersAddresses = append(peersAddresses, fmt.Sprintf(filerPeerAddressPattern, name, i, name, namespace))
} }
return peersAddresses return peersAddresses
} }
func getFilerPeersString(name string, replicas int32) string { func getFilerPeersString(name string, namespace string, replicas int32) string {
return strings.Join(getFilerAddresses(name, replicas), ",") return strings.Join(getFilerAddresses(name, namespace, replicas), ",")
} }
func getMasterAddresses(namespace string, name string, replicas int32) []string { func getMasterAddresses(namespace string, name string, replicas int32) []string {