Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
b7b62b38
Commit
b7b62b38
authored
Dec 01, 2021
by
xuweiwei
Committed by
GitHub
Dec 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/kubernetes: clean code (#5017)
Signed-off-by:
xuweiwei
<
xuweiwei_yewu@cmss.chinamobile.com
>
parent
372e9559
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
plugin/kubernetes/kubernetes.go
plugin/kubernetes/kubernetes.go
+5
-5
No files found.
plugin/kubernetes/kubernetes.go
View file @
b7b62b38
...
...
@@ -315,7 +315,7 @@ func (k *Kubernetes) endpointSliceSupported(kubeClient *kubernetes.Clientset) (b
// Disable use of endpoint slices for k8s versions 1.18 and earlier. The Endpointslices API was enabled
// by default in 1.17 but Service -> Pod proxy continued to use Endpoints by default until 1.19.
// DNS results should be built from the same source data that the proxy uses. This decision assumes
// k8s EndpointSliceProxying featuregate is at the default (i.e. only enabled for k8s >= 1.19).
// k8s EndpointSliceProxying feature
gate is at the default (i.e. only enabled for k8s >= 1.19).
major
,
_
:=
strconv
.
Atoi
(
sv
.
Major
)
minor
,
_
:=
strconv
.
Atoi
(
strings
.
TrimRight
(
sv
.
Minor
,
"+"
))
if
major
<=
1
&&
minor
<=
18
{
...
...
@@ -413,9 +413,9 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
zonePath
:=
msg
.
Path
(
zone
,
coredns
)
ip
:=
""
if
strings
.
Count
(
podname
,
"-"
)
==
3
&&
!
strings
.
Contains
(
podname
,
"--"
)
{
ip
=
strings
.
Replace
(
podname
,
"-"
,
"."
,
-
1
)
ip
=
strings
.
Replace
All
(
podname
,
"-"
,
"."
)
}
else
{
ip
=
strings
.
Replace
(
podname
,
"-"
,
":"
,
-
1
)
ip
=
strings
.
Replace
All
(
podname
,
"-"
,
":"
)
}
if
k
.
podMode
==
podModeInsecure
{
...
...
@@ -514,7 +514,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
podsCount
:=
0
for
_
,
ep
:=
range
endpointsListFunc
()
{
for
_
,
eps
:=
range
ep
.
Subsets
{
podsCount
=
podsCount
+
len
(
eps
.
Addresses
)
podsCount
+=
len
(
eps
.
Addresses
)
}
}
...
...
@@ -557,7 +557,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
}
for
_
,
p
:=
range
eps
.
Ports
{
if
!
(
match
(
r
.
port
,
p
.
Name
)
&&
match
(
r
.
protocol
,
string
(
p
.
Protocol
)
))
{
if
!
(
match
(
r
.
port
,
p
.
Name
)
&&
match
(
r
.
protocol
,
p
.
Protocol
))
{
continue
}
s
:=
msg
.
Service
{
Host
:
addr
.
IP
,
Port
:
int
(
p
.
Port
),
TTL
:
k
.
ttl
}
...
...
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