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
e8366c8e
Commit
e8366c8e
authored
Aug 30, 2018
by
Brad Hoekstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to inject KUBERNETES_ env vars when enableServiceLinks is
false and the pod is in the master namespace.
parent
ac8799a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
15 deletions
+14
-15
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+4
-14
kubelet_pods_test.go
pkg/kubelet/kubelet_pods_test.go
+10
-1
No files found.
pkg/kubelet/kubelet_pods.go
View file @
e8366c8e
...
@@ -514,24 +514,14 @@ func (kl *Kubelet) getServiceEnvVarMap(ns string, enableServiceLinks *bool) (map
...
@@ -514,24 +514,14 @@ func (kl *Kubelet) getServiceEnvVarMap(ns string, enableServiceLinks *bool) (map
}
}
serviceName
:=
service
.
Name
serviceName
:=
service
.
Name
switch
service
.
Namespace
{
// for the case whether the master service namespace is the namespace the pod
// for the case whether the master service namespace is the namespace the pod
// is in, the pod should receive all the services in the namespace.
// is in, the pod should receive all the services in the namespace.
//
if
service
.
Namespace
==
kl
.
masterServiceNamespace
&&
masterServices
.
Has
(
serviceName
)
{
// ordering of the case clauses below enforces this
if
_
,
exists
:=
serviceMap
[
serviceName
];
!
exists
{
case
ns
:
serviceMap
[
serviceName
]
=
service
// If service links are not enabled, we shouldn't add services from
// the same namespace.
if
!*
enableServiceLinks
{
continue
}
}
}
else
if
service
.
Namespace
==
ns
&&
*
enableServiceLinks
{
serviceMap
[
serviceName
]
=
service
serviceMap
[
serviceName
]
=
service
case
kl
.
masterServiceNamespace
:
if
masterServices
.
Has
(
serviceName
)
{
if
_
,
exists
:=
serviceMap
[
serviceName
];
!
exists
{
serviceMap
[
serviceName
]
=
service
}
}
}
}
}
}
...
...
pkg/kubelet/kubelet_pods_test.go
View file @
e8366c8e
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
core
"k8s.io/client-go/testing"
core
"k8s.io/client-go/testing"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/tools/record"
// TODO: remove this import if
// TODO: remove this import if
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
// api.Registry.GroupOrDie(v1.GroupName).GroupVersions[0].String() is changed
// to "v1"?
// to "v1"?
...
@@ -625,7 +626,15 @@ func TestMakeEnvironmentVariables(t *testing.T) {
...
@@ -625,7 +626,15 @@ func TestMakeEnvironmentVariables(t *testing.T) {
container
:
&
v1
.
Container
{},
container
:
&
v1
.
Container
{},
masterServiceNs
:
"kubernetes"
,
masterServiceNs
:
"kubernetes"
,
nilLister
:
false
,
nilLister
:
false
,
expectedEnvs
:
nil
,
expectedEnvs
:
[]
kubecontainer
.
EnvVar
{
{
Name
:
"KUBERNETES_SERVICE_HOST"
,
Value
:
"1.2.3.6"
},
{
Name
:
"KUBERNETES_SERVICE_PORT"
,
Value
:
"8086"
},
{
Name
:
"KUBERNETES_PORT"
,
Value
:
"tcp://1.2.3.6:8086"
},
{
Name
:
"KUBERNETES_PORT_8086_TCP"
,
Value
:
"tcp://1.2.3.6:8086"
},
{
Name
:
"KUBERNETES_PORT_8086_TCP_PROTO"
,
Value
:
"tcp"
},
{
Name
:
"KUBERNETES_PORT_8086_TCP_PORT"
,
Value
:
"8086"
},
{
Name
:
"KUBERNETES_PORT_8086_TCP_ADDR"
,
Value
:
"1.2.3.6"
},
},
},
},
{
{
name
:
"pod in master service ns, service env vars"
,
name
:
"pod in master service ns, service env vars"
,
...
...
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