mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Extract the minion registry from the etcd implementation into the pod registry where it belongs.
This commit is contained in:
parent
6df5afb88e
commit
253bce42fe
@ -83,12 +83,16 @@ func NewEtcdHelper(etcdServers []string, version string) (helper tools.EtcdHelpe
|
||||
// New returns a new instance of Master connected to the given etcd server.
|
||||
func New(c *Config) *Master {
|
||||
minionRegistry := makeMinionRegistry(c)
|
||||
serviceRegistry := etcd.NewRegistry(c.EtcdHelper, nil)
|
||||
manifestFactory := &pod.BasicManifestFactory{
|
||||
ServiceRegistry: serviceRegistry,
|
||||
}
|
||||
m := &Master{
|
||||
podRegistry: etcd.NewRegistry(c.EtcdHelper),
|
||||
controllerRegistry: etcd.NewRegistry(c.EtcdHelper),
|
||||
serviceRegistry: etcd.NewRegistry(c.EtcdHelper),
|
||||
endpointRegistry: etcd.NewRegistry(c.EtcdHelper),
|
||||
bindingRegistry: etcd.NewRegistry(c.EtcdHelper),
|
||||
podRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
|
||||
controllerRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
|
||||
serviceRegistry: serviceRegistry,
|
||||
endpointRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
|
||||
bindingRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
|
||||
minionRegistry: minionRegistry,
|
||||
client: c.Client,
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
etcderr "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
@ -37,17 +38,15 @@ import (
|
||||
// with backed by etcd.
|
||||
type Registry struct {
|
||||
tools.EtcdHelper
|
||||
manifestFactory ManifestFactory
|
||||
manifestFactory pod.ManifestFactory
|
||||
}
|
||||
|
||||
// NewRegistry creates an etcd registry.
|
||||
func NewRegistry(helper tools.EtcdHelper) *Registry {
|
||||
func NewRegistry(helper tools.EtcdHelper, manifestFactory pod.ManifestFactory) *Registry {
|
||||
registry := &Registry{
|
||||
EtcdHelper: helper,
|
||||
}
|
||||
registry.manifestFactory = &BasicManifestFactory{
|
||||
serviceRegistry: registry,
|
||||
}
|
||||
registry.manifestFactory = manifestFactory
|
||||
return registry
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/registrytest"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||
@ -32,10 +33,10 @@ import (
|
||||
)
|
||||
|
||||
func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
|
||||
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
|
||||
registry.manifestFactory = &BasicManifestFactory{
|
||||
serviceRegistry: ®istrytest.ServiceRegistry{},
|
||||
}
|
||||
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner},
|
||||
&pod.BasicManifestFactory{
|
||||
ServiceRegistry: ®istrytest.ServiceRegistry{},
|
||||
})
|
||||
return registry
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package etcd
|
||||
package pod
|
||||
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@ -27,11 +27,12 @@ type ManifestFactory interface {
|
||||
}
|
||||
|
||||
type BasicManifestFactory struct {
|
||||
serviceRegistry service.Registry
|
||||
// TODO: this should really point at the API rather than a registry
|
||||
ServiceRegistry service.Registry
|
||||
}
|
||||
|
||||
func (b *BasicManifestFactory) MakeManifest(machine string, pod api.Pod) (api.ContainerManifest, error) {
|
||||
envVars, err := service.GetServiceEnvironmentVariables(b.serviceRegistry, machine)
|
||||
envVars, err := service.GetServiceEnvironmentVariables(b.ServiceRegistry, machine)
|
||||
if err != nil {
|
||||
return api.ContainerManifest{}, err
|
||||
}
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package etcd
|
||||
package pod
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
@ -28,7 +28,7 @@ import (
|
||||
func TestMakeManifestNoServices(t *testing.T) {
|
||||
registry := registrytest.ServiceRegistry{}
|
||||
factory := &BasicManifestFactory{
|
||||
serviceRegistry: ®istry,
|
||||
ServiceRegistry: ®istry,
|
||||
}
|
||||
|
||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
||||
@ -74,7 +74,7 @@ func TestMakeManifestServices(t *testing.T) {
|
||||
},
|
||||
}
|
||||
factory := &BasicManifestFactory{
|
||||
serviceRegistry: ®istry,
|
||||
ServiceRegistry: ®istry,
|
||||
}
|
||||
|
||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
||||
@ -150,7 +150,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
|
||||
},
|
||||
}
|
||||
factory := &BasicManifestFactory{
|
||||
serviceRegistry: ®istry,
|
||||
ServiceRegistry: ®istry,
|
||||
}
|
||||
|
||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
Loading…
Reference in New Issue
Block a user