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
f5ee757b
Unverified
Commit
f5ee757b
authored
Jun 22, 2020
by
Hussein Galal
Committed by
GitHub
Jun 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cluster dns configmap (#1785)
parent
01035ba9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
server.go
pkg/server/server.go
+46
-0
No files found.
pkg/server/server.go
View file @
f5ee757b
...
@@ -13,6 +13,8 @@ import (
...
@@ -13,6 +13,8 @@ import (
"strings"
"strings"
"time"
"time"
corev1
"k8s.io/api/core/v1"
"github.com/pkg/errors"
"github.com/pkg/errors"
"github.com/rancher/helm-controller/pkg/helm"
"github.com/rancher/helm-controller/pkg/helm"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/clientaccess"
...
@@ -137,6 +139,9 @@ func runControllers(ctx context.Context, config *Config) error {
...
@@ -137,6 +139,9 @@ func runControllers(ctx context.Context, config *Config) error {
if
!
config
.
DisableAgent
{
if
!
config
.
DisableAgent
{
go
setMasterRoleLabel
(
ctx
,
sc
.
Core
.
Core
()
.
V1
()
.
Node
())
go
setMasterRoleLabel
(
ctx
,
sc
.
Core
.
Core
()
.
V1
()
.
Node
())
}
}
go
setClusterDNSConfig
(
ctx
,
config
,
sc
.
Core
.
Core
()
.
V1
()
.
ConfigMap
())
if
controlConfig
.
NoLeaderElect
{
if
controlConfig
.
NoLeaderElect
{
go
func
()
{
go
func
()
{
start
(
ctx
)
start
(
ctx
)
...
@@ -430,3 +435,44 @@ func setMasterRoleLabel(ctx context.Context, nodes v1.NodeClient) error {
...
@@ -430,3 +435,44 @@ func setMasterRoleLabel(ctx context.Context, nodes v1.NodeClient) error {
}
}
return
nil
return
nil
}
}
func
setClusterDNSConfig
(
ctx
context
.
Context
,
controlConfig
*
Config
,
configMap
v1
.
ConfigMapClient
)
error
{
nodeName
:=
os
.
Getenv
(
"NODE_NAME"
)
// check if configmap already exists
_
,
err
:=
configMap
.
Get
(
"kube-system"
,
"cluster-dns"
,
metav1
.
GetOptions
{})
if
err
==
nil
{
logrus
.
Infof
(
"cluster dns configmap already exists"
)
return
nil
}
clusterDNS
:=
controlConfig
.
ControlConfig
.
ClusterDNS
clusterDomain
:=
controlConfig
.
ControlConfig
.
ClusterDomain
c
:=
&
corev1
.
ConfigMap
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"ConfigMap"
,
APIVersion
:
"v1"
,
},
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"cluster-dns"
,
Namespace
:
"kube-system"
,
},
Data
:
map
[
string
]
string
{
"clusterDNS"
:
clusterDNS
.
String
(),
"clusterDomain"
:
clusterDomain
,
},
}
for
{
_
,
err
=
configMap
.
Create
(
c
)
if
err
==
nil
{
logrus
.
Infof
(
"cluster dns configmap has been set successfully"
)
break
}
logrus
.
Infof
(
"Waiting for master node %s startup: %v"
,
nodeName
,
err
)
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
<-
time
.
After
(
time
.
Second
)
:
}
}
return
nil
}
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