mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 13:12:20 +00:00
Support running a nodelocal dns cache
This change includes the yaml files and gce startup script changes to run this addon. It is disabled by default, can be enabled by setting KUBE_ENABLE_NODELOCAL_DNS=true An ip address is required for the cache instance to listen for requests on, default is a link local ip address of value 169.254.25.10 addressed review comments, updated image location Picked a different prometheus port so stats port is not same as the coredns deployment Removed the nodelocaldns-ready label. Set memory limit to 30Mi
This commit is contained in:
@@ -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,25 @@ function start_kubedns {
|
||||
fi
|
||||
}
|
||||
|
||||
function start_nodelocaldns {
|
||||
if [[ "${ENABLE_NODELOCAL_DNS}" = true ]]; then
|
||||
cp "${KUBE_ROOT}/cluster/addons/dns/nodelocaldns/localdns.yaml.in" 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_ip'\] }}/${LOCAL_DNS_IP}/g" nodelocaldns.yaml
|
||||
if [[ -n "${CLUSTER_IP_RANGE:-}" ]]; then
|
||||
sed -i -e "s@{{ *pillar\['service_cluster_ip_range'\] *}}@${CLUSTER_IP_RANGE}@g" nodelocaldns.yaml
|
||||
else
|
||||
sed -i -e "s@{{ *pillar\['service_cluster_ip_range'\] *}}@0.0.0.0@g" nodelocaldns.yaml
|
||||
fi
|
||||
# TODO update to dns role once we have one.
|
||||
# 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
|
||||
fi
|
||||
}
|
||||
|
||||
function start_kubedashboard {
|
||||
if [[ "${ENABLE_CLUSTER_DASHBOARD}" = true ]]; then
|
||||
echo "Creating kubernetes-dashboard"
|
||||
@@ -1056,6 +1081,7 @@ if [[ "${START_MODE}" != "kubeletonly" ]]; then
|
||||
fi
|
||||
start_kubeproxy
|
||||
start_kubedns
|
||||
start_nodelocaldns
|
||||
start_kubedashboard
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user