mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +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.
|
// New returns a new instance of Master connected to the given etcd server.
|
||||||
func New(c *Config) *Master {
|
func New(c *Config) *Master {
|
||||||
minionRegistry := makeMinionRegistry(c)
|
minionRegistry := makeMinionRegistry(c)
|
||||||
|
serviceRegistry := etcd.NewRegistry(c.EtcdHelper, nil)
|
||||||
|
manifestFactory := &pod.BasicManifestFactory{
|
||||||
|
ServiceRegistry: serviceRegistry,
|
||||||
|
}
|
||||||
m := &Master{
|
m := &Master{
|
||||||
podRegistry: etcd.NewRegistry(c.EtcdHelper),
|
podRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
|
||||||
controllerRegistry: etcd.NewRegistry(c.EtcdHelper),
|
controllerRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
|
||||||
serviceRegistry: etcd.NewRegistry(c.EtcdHelper),
|
serviceRegistry: serviceRegistry,
|
||||||
endpointRegistry: etcd.NewRegistry(c.EtcdHelper),
|
endpointRegistry: etcd.NewRegistry(c.EtcdHelper, nil),
|
||||||
bindingRegistry: etcd.NewRegistry(c.EtcdHelper),
|
bindingRegistry: etcd.NewRegistry(c.EtcdHelper, manifestFactory),
|
||||||
minionRegistry: minionRegistry,
|
minionRegistry: minionRegistry,
|
||||||
client: c.Client,
|
client: c.Client,
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
etcderr "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
|
etcderr "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors/etcd"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/constraint"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/pod"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
@ -37,17 +38,15 @@ import (
|
|||||||
// with backed by etcd.
|
// with backed by etcd.
|
||||||
type Registry struct {
|
type Registry struct {
|
||||||
tools.EtcdHelper
|
tools.EtcdHelper
|
||||||
manifestFactory ManifestFactory
|
manifestFactory pod.ManifestFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRegistry creates an etcd registry.
|
// NewRegistry creates an etcd registry.
|
||||||
func NewRegistry(helper tools.EtcdHelper) *Registry {
|
func NewRegistry(helper tools.EtcdHelper, manifestFactory pod.ManifestFactory) *Registry {
|
||||||
registry := &Registry{
|
registry := &Registry{
|
||||||
EtcdHelper: helper,
|
EtcdHelper: helper,
|
||||||
}
|
}
|
||||||
registry.manifestFactory = &BasicManifestFactory{
|
registry.manifestFactory = manifestFactory
|
||||||
serviceRegistry: registry,
|
|
||||||
}
|
|
||||||
return registry
|
return registry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"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/registry/registrytest"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
@ -32,10 +33,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
|
func NewTestEtcdRegistry(client tools.EtcdClient) *Registry {
|
||||||
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
|
registry := NewRegistry(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner},
|
||||||
registry.manifestFactory = &BasicManifestFactory{
|
&pod.BasicManifestFactory{
|
||||||
serviceRegistry: ®istrytest.ServiceRegistry{},
|
ServiceRegistry: ®istrytest.ServiceRegistry{},
|
||||||
}
|
})
|
||||||
return registry
|
return registry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package etcd
|
package pod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
@ -27,11 +27,12 @@ type ManifestFactory interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BasicManifestFactory struct {
|
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) {
|
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 {
|
if err != nil {
|
||||||
return api.ContainerManifest{}, err
|
return api.ContainerManifest{}, err
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package etcd
|
package pod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
@ -28,7 +28,7 @@ import (
|
|||||||
func TestMakeManifestNoServices(t *testing.T) {
|
func TestMakeManifestNoServices(t *testing.T) {
|
||||||
registry := registrytest.ServiceRegistry{}
|
registry := registrytest.ServiceRegistry{}
|
||||||
factory := &BasicManifestFactory{
|
factory := &BasicManifestFactory{
|
||||||
serviceRegistry: ®istry,
|
ServiceRegistry: ®istry,
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
manifest, err := factory.MakeManifest("machine", api.Pod{
|
||||||
@ -74,7 +74,7 @@ func TestMakeManifestServices(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
factory := &BasicManifestFactory{
|
factory := &BasicManifestFactory{
|
||||||
serviceRegistry: ®istry,
|
ServiceRegistry: ®istry,
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
manifest, err := factory.MakeManifest("machine", api.Pod{
|
||||||
@ -150,7 +150,7 @@ func TestMakeManifestServicesExistingEnvVar(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
factory := &BasicManifestFactory{
|
factory := &BasicManifestFactory{
|
||||||
serviceRegistry: ®istry,
|
ServiceRegistry: ®istry,
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest, err := factory.MakeManifest("machine", api.Pod{
|
manifest, err := factory.MakeManifest("machine", api.Pod{
|
Loading…
Reference in New Issue
Block a user