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
79dab474
Unverified
Commit
79dab474
authored
Nov 14, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70555 from prameshj/nodelocaldnscache
Support running a nodelocal dns cache
parents
3e6d414b
6d7c5e90
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
189 additions
and
1 deletion
+189
-1
nodelocaldns.yaml
cluster/addons/dns/nodelocaldns/nodelocaldns.yaml
+144
-0
config-default.sh
cluster/gce/config-default.sh
+3
-0
config-test.sh
cluster/gce/config-test.sh
+3
-0
configure-helper.sh
cluster/gce/gci/configure-helper.sh
+13
-0
util.sh
cluster/gce/util.sh
+5
-0
local-up-cluster.sh
hack/local-up-cluster.sh
+21
-1
No files found.
cluster/addons/dns/nodelocaldns/nodelocaldns.yaml
0 → 100644
View file @
79dab474
# Copyright 2018 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion
:
v1
kind
:
ServiceAccount
metadata
:
name
:
node-local-dns
namespace
:
kube-system
labels
:
kubernetes.io/cluster-service
:
"
true"
addonmanager.kubernetes.io/mode
:
Reconcile
---
apiVersion
:
v1
kind
:
ConfigMap
metadata
:
name
:
node-local-dns
namespace
:
kube-system
labels
:
addonmanager.kubernetes.io/mode
:
EnsureExists
data
:
Corefile
:
|
__PILLAR__DNS__DOMAIN__:53 {
errors
cache 30
reload
loop
bind __PILLAR__LOCAL__DNS__
forward . __PILLAR__DNS__SERVER__ {
force_tcp
}
prometheus :9253
health __PILLAR__LOCAL__DNS__:8080
}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind __PILLAR__LOCAL__DNS__
forward . __PILLAR__DNS__SERVER__ {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind __PILLAR__LOCAL__DNS__
forward . __PILLAR__DNS__SERVER__ {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind __PILLAR__LOCAL__DNS__
forward . /etc/resolv.conf {
force_tcp
}
prometheus :9253
}
---
apiVersion
:
apps/v1
kind
:
DaemonSet
metadata
:
name
:
node-local-dns
namespace
:
kube-system
labels
:
k8s-app
:
kube-dns
kubernetes.io/cluster-service
:
"
true"
addonmanager.kubernetes.io/mode
:
Reconcile
spec
:
selector
:
matchLabels
:
k8s-app
:
node-local-dns
template
:
metadata
:
labels
:
k8s-app
:
node-local-dns
spec
:
priorityClassName
:
system-node-critical
serviceAccountName
:
node-local-dns
hostNetwork
:
true
dnsPolicy
:
Default
# Don't use cluster DNS.
tolerations
:
-
key
:
"
CriticalAddonsOnly"
operator
:
"
Exists"
containers
:
-
name
:
node-cache
image
:
k8s.gcr.io/k8s-dns-node-cache:1.15.0
resources
:
limits
:
memory
:
30Mi
requests
:
cpu
:
25m
memory
:
5Mi
args
:
[
"
-localip"
,
"
__PILLAR__LOCAL__DNS__"
,
"
-conf"
,
"
/etc/coredns/Corefile"
]
securityContext
:
privileged
:
true
ports
:
-
containerPort
:
53
name
:
dns
protocol
:
UDP
-
containerPort
:
53
name
:
dns-tcp
protocol
:
TCP
-
containerPort
:
9253
name
:
metrics
protocol
:
TCP
livenessProbe
:
httpGet
:
host
:
__PILLAR__LOCAL__DNS__
path
:
/health
port
:
8080
initialDelaySeconds
:
60
timeoutSeconds
:
5
volumeMounts
:
-
name
:
config-volume
mountPath
:
/etc/coredns
volumes
:
-
name
:
config-volume
configMap
:
name
:
node-local-dns
items
:
-
key
:
Corefile
path
:
Corefile
cluster/gce/config-default.sh
View file @
79dab474
...
...
@@ -198,6 +198,9 @@ if [[ ${ENABLE_NETD:-} == "true" ]]; then
NON_MASTER_NODE_LABELS
=
"
${
NON_MASTER_NODE_LABELS
:+
${
NON_MASTER_NODE_LABELS
}
,
}
cloud.google.com/gke-netd-ready=true"
fi
ENABLE_NODELOCAL_DNS
=
"
${
KUBE_ENABLE_NODELOCAL_DNS
:-
false
}
"
LOCAL_DNS_IP
=
"
${
KUBE_LOCAL_DNS_IP
:-
169
.254.20.10
}
"
# Enable metadata concealment by firewalling pod traffic to the metadata server
# and run a proxy daemonset on nodes.
#
...
...
cluster/gce/config-test.sh
View file @
79dab474
...
...
@@ -230,6 +230,8 @@ if [[ ${ENABLE_NETD:-} == "true" ]]; then
NON_MASTER_NODE_LABELS
=
"
${
NON_MASTER_NODE_LABELS
:+
${
NON_MASTER_NODE_LABELS
}
,
}
cloud.google.com/gke-netd-ready=true"
fi
ENABLE_NODELOCAL_DNS
=
"
${
KUBE_ENABLE_NODELOCAL_DNS
:-
false
}
"
# To avoid running Calico on a node that is not configured appropriately,
# label each Node so that the DaemonSet can run the Pods only on ready Nodes.
if
[[
${
NETWORK_POLICY_PROVIDER
:-}
==
"calico"
]]
;
then
...
...
@@ -272,6 +274,7 @@ fi
CLUSTER_DNS_CORE_DNS
=
"
${
CLUSTER_DNS_CORE_DNS
:-
true
}
"
ENABLE_CLUSTER_DNS
=
"
${
KUBE_ENABLE_CLUSTER_DNS
:-
true
}
"
DNS_SERVER_IP
=
"10.0.0.10"
LOCAL_DNS_IP
=
"
${
KUBE_LOCAL_DNS_IP
:-
169
.254.20.10
}
"
DNS_DOMAIN
=
"cluster.local"
# Optional: Enable DNS horizontal autoscaler
...
...
cluster/gce/gci/configure-helper.sh
View file @
79dab474
...
...
@@ -2354,6 +2354,16 @@ EOF
fi
}
# Sets up the manifests of local dns cache agent for k8s addons.
function
setup-nodelocaldns-manifest
{
setup-addon-manifests
"addons"
"dns/nodelocaldns"
local
-r
localdns_file
=
"
${
dst_dir
}
/dns/nodelocaldns/nodelocaldns.yaml"
# Replace the sed configurations with variable values.
sed
-i
-e
"s/__PILLAR__DNS__DOMAIN__/
${
DNS_DOMAIN
}
/g"
"
${
localdns_file
}
"
sed
-i
-e
"s/__PILLAR__DNS__SERVER__/
${
DNS_SERVER_IP
}
/g"
"
${
localdns_file
}
"
sed
-i
-e
"s/__PILLAR__LOCAL__DNS__/
${
LOCAL_DNS_IP
}
/g"
"
${
localdns_file
}
"
}
# Sets up the manifests of netd for k8s addons.
function
setup-netd-manifest
{
local
-r
netd_file
=
"
${
dst_dir
}
/netd/netd.yaml"
...
...
@@ -2525,6 +2535,9 @@ EOF
setup-addon-manifests
"addons"
"dns/kube-dns"
setup-kube-dns-manifest
fi
if
[[
"
${
ENABLE_NODELOCAL_DNS
:-}
"
==
"true"
]]
;
then
setup-nodelocaldns-manifest
fi
fi
if
[[
"
${
ENABLE_NETD
:-}
"
==
"true"
]]
;
then
setup-netd-manifest
...
...
cluster/gce/util.sh
View file @
79dab474
...
...
@@ -708,6 +708,9 @@ function build-kubelet-config {
declare
quoted_dns_server_ip
declare
quoted_dns_domain
quoted_dns_server_ip
=
$(
yaml-quote
"
${
DNS_SERVER_IP
}
"
)
if
[[
"
${
ENABLE_NODELOCAL_DNS
:-}
"
==
"true"
]]
;
then
quoted_dns_server_ip
=
$(
yaml-quote
"
${
LOCAL_DNS_IP
}
"
)
fi
quoted_dns_domain
=
$(
yaml-quote
"
${
DNS_DOMAIN
}
"
)
cat
<<
EOF
kind: KubeletConfiguration
...
...
@@ -848,7 +851,9 @@ LOGGING_DESTINATION: $(yaml-quote ${LOGGING_DESTINATION:-})
ELASTICSEARCH_LOGGING_REPLICAS:
$(
yaml-quote
${
ELASTICSEARCH_LOGGING_REPLICAS
:-})
ENABLE_CLUSTER_DNS:
$(
yaml-quote
${
ENABLE_CLUSTER_DNS
:-
false
})
CLUSTER_DNS_CORE_DNS:
$(
yaml-quote
${
CLUSTER_DNS_CORE_DNS
:-
true
})
ENABLE_NODELOCAL_DNS:
$(
yaml-quote
${
ENABLE_NODELOCAL_DNS
:-
false
})
DNS_SERVER_IP:
$(
yaml-quote
${
DNS_SERVER_IP
:-})
LOCAL_DNS_IP:
$(
yaml-quote
${
LOCAL_DNS_IP
:-})
DNS_DOMAIN:
$(
yaml-quote
${
DNS_DOMAIN
:-})
ENABLE_DNS_HORIZONTAL_AUTOSCALER:
$(
yaml-quote
${
ENABLE_DNS_HORIZONTAL_AUTOSCALER
:-
false
})
KUBE_PROXY_DAEMONSET:
$(
yaml-quote
${
KUBE_PROXY_DAEMONSET
:-
false
})
...
...
hack/local-up-cluster.sh
View file @
79dab474
...
...
@@ -63,7 +63,9 @@ EVICTION_PRESSURE_TRANSITION_PERIOD=${EVICTION_PRESSURE_TRANSITION_PERIOD:-"1m"}
# Note also that you need API_HOST (defined above) for correct DNS.
KUBE_PROXY_MODE
=
${
KUBE_PROXY_MODE
:-
""
}
ENABLE_CLUSTER_DNS
=
${
KUBE_ENABLE_CLUSTER_DNS
:-
true
}
ENABLE_NODELOCAL_DNS
=
${
KUBE_ENABLE_NODELOCAL_DNS
:-
false
}
DNS_SERVER_IP
=
${
KUBE_DNS_SERVER_IP
:-
10
.0.0.10
}
LOCAL_DNS_IP
=
${
KUBE_LOCAL_DNS_IP
:-
169
.254.20.10
}
DNS_DOMAIN
=
${
KUBE_DNS_NAME
:-
"cluster.local"
}
KUBECTL
=
${
KUBECTL
:-
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
}
WAIT_FOR_URL_API_SERVER
=
${
WAIT_FOR_URL_API_SERVER
:-
60
}
...
...
@@ -704,7 +706,11 @@ function start_kubelet {
mkdir -p "
/var/lib/kubelet
" &>/dev/null || sudo mkdir -p "
/var/lib/kubelet
"
# Enable dns
if [[ "
${
ENABLE_CLUSTER_DNS
}
" = true ]]; then
dns_args="
--cluster-dns=
${
DNS_SERVER_IP
}
--cluster-domain=
${
DNS_DOMAIN
}
"
if [[ "
${
ENABLE_NODELOCAL_DNS
:-}
" == "
true
" ]]; then
dns_args="
--cluster-dns=
${
LOCAL_DNS_IP
}
--cluster-domain=
${
DNS_DOMAIN
}
"
else
dns_args="
--cluster-dns=
${
DNS_SERVER_IP
}
--cluster-domain=
${
DNS_DOMAIN
}
"
fi
else
# To start a private DNS server set ENABLE_CLUSTER_DNS and
# DNS_SERVER_IP/DOMAIN. This will at least provide a working
...
...
@@ -908,6 +914,17 @@ function start_kubedns {
fi
}
function start_nodelocaldns {
cp "
${
KUBE_ROOT
}
/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml
" nodelocaldns.yaml
sed -i -e "
s/__PILLAR__DNS__DOMAIN__/
${
DNS_DOMAIN
}
/g
" nodelocaldns.yaml
sed -i -e "
s/__PILLAR__DNS__SERVER__/
${
DNS_SERVER_IP
}
/g
" nodelocaldns.yaml
sed -i -e "
s/__PILLAR__LOCAL__DNS__/
${
LOCAL_DNS_IP
}
/g
" nodelocaldns.yaml
# use kubectl to create nodelocaldns addon
${
KUBECTL
}
--kubeconfig="
${
CERT_DIR
}
/admin.kubeconfig
" --namespace=kube-system create -f nodelocaldns.yaml
echo "
NodeLocalDNS addon successfully deployed.
"
rm nodelocaldns.yaml
}
function start_kubedashboard {
if [[ "
${
ENABLE_CLUSTER_DASHBOARD
}
" = true ]]; then
echo "
Creating kubernetes-dashboard
"
...
...
@@ -1056,6 +1073,9 @@ if [[ "${START_MODE}" != "kubeletonly" ]]; then
fi
start_kubeproxy
start_kubedns
if [[ "
${
ENABLE_NODELOCAL_DNS
:-}
" == "
true
" ]]; then
start_nodelocaldns
fi
start_kubedashboard
fi
...
...
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