Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3bc8f4e7
Commit
3bc8f4e7
authored
Feb 12, 2015
by
Saad Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4359 from erictune/no_bound_pod_envs
Stop putting env vars into BoundPods.
parents
0a435c81
5b456969
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
61 deletions
+5
-61
master.go
pkg/master/master.go
+3
-8
etcd_test.go
pkg/registry/etcd/etcd_test.go
+1
-4
bound_pod_factory.go
pkg/registry/pod/bound_pod_factory.go
+1
-49
bound_pod_factory_test.go
pkg/registry/pod/bound_pod_factory_test.go
+0
-0
No files found.
pkg/master/master.go
View file @
3bc8f4e7
...
@@ -253,12 +253,7 @@ func setDefaults(c *Config) {
...
@@ -253,12 +253,7 @@ func setDefaults(c *Config) {
// any unhandled paths to "Handler".
// any unhandled paths to "Handler".
func
New
(
c
*
Config
)
*
Master
{
func
New
(
c
*
Config
)
*
Master
{
setDefaults
(
c
)
setDefaults
(
c
)
minionRegistry
:=
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
)
boundPodFactory
:=
&
pod
.
BasicBoundPodFactory
{}
serviceRegistry
:=
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
)
boundPodFactory
:=
&
pod
.
BasicBoundPodFactory
{
ServiceRegistry
:
serviceRegistry
,
MasterServiceNamespace
:
c
.
MasterServiceNamespace
,
}
if
c
.
KubeletClient
==
nil
{
if
c
.
KubeletClient
==
nil
{
glog
.
Fatalf
(
"master.New() called with config.KubeletClient == nil"
)
glog
.
Fatalf
(
"master.New() called with config.KubeletClient == nil"
)
}
}
...
@@ -277,12 +272,12 @@ func New(c *Config) *Master {
...
@@ -277,12 +272,12 @@ func New(c *Config) *Master {
m
:=
&
Master
{
m
:=
&
Master
{
podRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
boundPodFactory
),
podRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
boundPodFactory
),
controllerRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
),
controllerRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
),
serviceRegistry
:
serviceRegistry
,
serviceRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
)
,
endpointRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
),
endpointRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
),
bindingRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
boundPodFactory
),
bindingRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
boundPodFactory
),
eventRegistry
:
event
.
NewEtcdRegistry
(
c
.
EtcdHelper
,
uint64
(
c
.
EventTTL
.
Seconds
())),
eventRegistry
:
event
.
NewEtcdRegistry
(
c
.
EtcdHelper
,
uint64
(
c
.
EventTTL
.
Seconds
())),
namespaceRegistry
:
namespace
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
namespaceRegistry
:
namespace
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
minionRegistry
:
minionRegistry
,
minionRegistry
:
etcd
.
NewRegistry
(
c
.
EtcdHelper
,
nil
)
,
limitRangeRegistry
:
limitrange
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
limitRangeRegistry
:
limitrange
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
resourceQuotaRegistry
:
resourcequota
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
resourceQuotaRegistry
:
resourcequota
.
NewEtcdRegistry
(
c
.
EtcdHelper
),
client
:
c
.
Client
,
client
:
c
.
Client
,
...
...
pkg/registry/etcd/etcd_test.go
View file @
3bc8f4e7
...
@@ -27,7 +27,6 @@ import (
...
@@ -27,7 +27,6 @@ import (
"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/pod"
"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"
...
@@ -36,9 +35,7 @@ import (
...
@@ -36,9 +35,7 @@ import (
func
NewTestEtcdRegistry
(
client
tools
.
EtcdClient
)
*
Registry
{
func
NewTestEtcdRegistry
(
client
tools
.
EtcdClient
)
*
Registry
{
registry
:=
NewRegistry
(
tools
.
EtcdHelper
{
client
,
latest
.
Codec
,
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
}},
registry
:=
NewRegistry
(
tools
.
EtcdHelper
{
client
,
latest
.
Codec
,
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
}},
&
pod
.
BasicBoundPodFactory
{
&
pod
.
BasicBoundPodFactory
{})
ServiceRegistry
:
&
registrytest
.
ServiceRegistry
{},
})
return
registry
return
registry
}
}
...
...
pkg/registry/pod/bound_pod_factory.go
View file @
3bc8f4e7
...
@@ -18,9 +18,6 @@ package pod
...
@@ -18,9 +18,6 @@ package pod
import
(
import
(
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/service"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
type
BoundPodFactory
interface
{
type
BoundPodFactory
interface
{
...
@@ -28,58 +25,13 @@ type BoundPodFactory interface {
...
@@ -28,58 +25,13 @@ type BoundPodFactory interface {
MakeBoundPod
(
machine
string
,
pod
*
api
.
Pod
)
(
*
api
.
BoundPod
,
error
)
MakeBoundPod
(
machine
string
,
pod
*
api
.
Pod
)
(
*
api
.
BoundPod
,
error
)
}
}
type
BasicBoundPodFactory
struct
{
type
BasicBoundPodFactory
struct
{}
// TODO: this should really point at the API rather than a registry
ServiceRegistry
service
.
Registry
MasterServiceNamespace
string
}
var
masterServiceNames
=
util
.
NewStringSet
(
"kubernetes"
,
"kubernetes-ro"
)
// getServiceEnvironmentVariables populates a list of environment variables that are used
// in the container environment to get access to services.
func
(
b
*
BasicBoundPodFactory
)
getServiceEnvironmentVariables
(
ctx
api
.
Context
,
registry
service
.
Registry
,
machine
string
)
([]
api
.
EnvVar
,
error
)
{
var
result
[]
api
.
EnvVar
servicesInNs
,
err
:=
registry
.
ListServices
(
ctx
)
if
err
!=
nil
{
return
result
,
err
}
masterServices
,
err
:=
registry
.
ListServices
(
api
.
WithNamespace
(
api
.
NewContext
(),
b
.
MasterServiceNamespace
))
if
err
!=
nil
{
return
result
,
err
}
projection
:=
map
[
string
]
api
.
Service
{}
services
:=
[]
api
.
Service
{}
for
_
,
service
:=
range
masterServices
.
Items
{
if
masterServiceNames
.
Has
(
service
.
Name
)
{
projection
[
service
.
Name
]
=
service
}
}
for
_
,
service
:=
range
servicesInNs
.
Items
{
projection
[
service
.
Name
]
=
service
}
for
_
,
service
:=
range
projection
{
services
=
append
(
services
,
service
)
}
return
envvars
.
FromServices
(
&
api
.
ServiceList
{
Items
:
services
}),
nil
}
func
(
b
*
BasicBoundPodFactory
)
MakeBoundPod
(
machine
string
,
pod
*
api
.
Pod
)
(
*
api
.
BoundPod
,
error
)
{
func
(
b
*
BasicBoundPodFactory
)
MakeBoundPod
(
machine
string
,
pod
*
api
.
Pod
)
(
*
api
.
BoundPod
,
error
)
{
envVars
,
err
:=
b
.
getServiceEnvironmentVariables
(
api
.
WithNamespace
(
api
.
NewContext
(),
pod
.
Namespace
),
b
.
ServiceRegistry
,
machine
)
if
err
!=
nil
{
return
nil
,
err
}
boundPod
:=
&
api
.
BoundPod
{}
boundPod
:=
&
api
.
BoundPod
{}
if
err
:=
api
.
Scheme
.
Convert
(
pod
,
boundPod
);
err
!=
nil
{
if
err
:=
api
.
Scheme
.
Convert
(
pod
,
boundPod
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
for
ix
,
container
:=
range
boundPod
.
Spec
.
Containers
{
boundPod
.
Spec
.
Containers
[
ix
]
.
Env
=
append
(
container
.
Env
,
envVars
...
)
}
// Make a dummy self link so that references to this bound pod will work.
// Make a dummy self link so that references to this bound pod will work.
boundPod
.
SelfLink
=
"/api/v1beta1/boundPods/"
+
boundPod
.
Name
boundPod
.
SelfLink
=
"/api/v1beta1/boundPods/"
+
boundPod
.
Name
return
boundPod
,
nil
return
boundPod
,
nil
...
...
pkg/registry/pod/bound_pod_factory_test.go
View file @
3bc8f4e7
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment