mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/kube-vip/kube-vip.git
synced 2026-09-20 08:03:47 +08:00
Simplification of configuration
This removes the duplication of peers and has a seperate entry for remote and local peers
This commit is contained in:
@@ -94,7 +94,8 @@ var kubeVipSampleManifest = &cobra.Command{
|
||||
APIVersion: "v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "kube-vip",
|
||||
Name: "kube-vip",
|
||||
Namespace: "kube-system",
|
||||
},
|
||||
Spec: appv1.PodSpec{
|
||||
Containers: []appv1.Container{
|
||||
@@ -110,7 +111,7 @@ var kubeVipSampleManifest = &cobra.Command{
|
||||
},
|
||||
},
|
||||
Command: []string{
|
||||
"/kube/vip",
|
||||
"/kube-vip",
|
||||
"start",
|
||||
"-c",
|
||||
"/vip.yaml",
|
||||
@@ -128,7 +129,7 @@ var kubeVipSampleManifest = &cobra.Command{
|
||||
Name: "config",
|
||||
VolumeSource: appv1.VolumeSource{
|
||||
HostPath: &appv1.HostPathVolumeSource{
|
||||
Path: "/path/to/config",
|
||||
Path: "/etc/kube-vip/config.yaml",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -87,13 +87,18 @@ func (cluster *Cluster) StartCluster(c *kubevip.Config) error {
|
||||
// Cluster configuration
|
||||
configuration := raft.Configuration{}
|
||||
|
||||
for x := range c.Peers {
|
||||
// Add Local Peer
|
||||
configuration.Servers = append(configuration.Servers, raft.Server{
|
||||
ID: raft.ServerID(c.LocalPeer.ID),
|
||||
Address: raft.ServerAddress(fmt.Sprintf("%s:%d", c.LocalPeer.Address, c.LocalPeer.Port))})
|
||||
|
||||
for x := range c.RemotePeers {
|
||||
// Build the address from the peer configuration
|
||||
peerAddress := fmt.Sprintf("%s:%d", c.Peers[x].Address, c.Peers[x].Port)
|
||||
peerAddress := fmt.Sprintf("%s:%d", c.RemotePeers[x].Address, c.RemotePeers[x].Port)
|
||||
|
||||
// Set this peer into the raft configuration
|
||||
configuration.Servers = append(configuration.Servers, raft.Server{
|
||||
ID: raft.ServerID(c.Peers[x].ID),
|
||||
ID: raft.ServerID(c.RemotePeers[x].ID),
|
||||
Address: raft.ServerAddress(peerAddress)})
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ func SampleConfig() {
|
||||
// Generate Sample configuration
|
||||
c := &Config{
|
||||
// Generate sample peers
|
||||
Peers: []RaftPeer{
|
||||
RemotePeers: []RaftPeer{
|
||||
RaftPeer{
|
||||
ID: "server1",
|
||||
Address: "192.168.0.1",
|
||||
|
||||
@@ -6,7 +6,7 @@ import "net/url"
|
||||
type Config struct {
|
||||
|
||||
// Peers are all of the peers within the RAFT cluster
|
||||
Peers []RaftPeer `yaml:"peers"`
|
||||
RemotePeers []RaftPeer `yaml:"remotePeers"`
|
||||
|
||||
// LocalPeer is the configuration of this host
|
||||
LocalPeer RaftPeer `yaml:"localPeer"`
|
||||
|
||||
Reference in New Issue
Block a user