Removed .salt template , using .sed template

Removed default config options from yaml.
Removed unused yaml files
This commit is contained in:
Pavithra Ramesh 2018-11-13 15:42:18 -08:00
parent 73b548db06
commit 6d7c5e90ed
11 changed files with 28 additions and 415 deletions

View File

@ -1,34 +0,0 @@
# 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.
# Makefile for the kubedns underscore templates to Salt/Pillar and other formats.
# If you update the *.base templates, please run this Makefile before pushing.
#
# Usage:
# make
all: transform
# .base -> .in pattern rule
%.in: %.base
sed -f transforms2salt.sed $< | sed s/__SOURCE_FILENAME__/$</g > $@
# .base -> .sed pattern rule
%.sed: %.base
sed -f transforms2sed.sed $< | sed s/__SOURCE_FILENAME__/$</g > $@
transform: nodelocaldns.yaml.in nodelocaldns.yaml.sed
.PHONY: transform

View File

@ -12,12 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# __MACHINE_GENERATED_WARNING__
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
name: nodelocaldns name: node-local-dns
namespace: kube-system namespace: kube-system
labels: labels:
kubernetes.io/cluster-service: "true" kubernetes.io/cluster-service: "true"
@ -27,11 +26,10 @@ metadata:
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: nodelocaldns name: node-local-dns
namespace: kube-system namespace: kube-system
labels: labels:
addonmanager.kubernetes.io/mode: EnsureExists addonmanager.kubernetes.io/mode: EnsureExists
data: data:
Corefile: | Corefile: |
__PILLAR__DNS__DOMAIN__:53 { __PILLAR__DNS__DOMAIN__:53 {
@ -83,7 +81,7 @@ data:
apiVersion: apps/v1 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
name: nodelocaldns name: node-local-dns
namespace: kube-system namespace: kube-system
labels: labels:
k8s-app: kube-dns k8s-app: kube-dns
@ -92,14 +90,14 @@ metadata:
spec: spec:
selector: selector:
matchLabels: matchLabels:
k8s-app: nodelocaldns k8s-app: node-local-dns
template: template:
metadata: metadata:
labels: labels:
k8s-app: nodelocaldns k8s-app: node-local-dns
spec: spec:
priorityClassName: system-node-critical priorityClassName: system-node-critical
serviceAccountName: nodelocaldns serviceAccountName: node-local-dns
hostNetwork: true hostNetwork: true
dnsPolicy: Default # Don't use cluster DNS. dnsPolicy: Default # Don't use cluster DNS.
tolerations: tolerations:
@ -116,7 +114,7 @@ spec:
memory: 5Mi memory: 5Mi
args: [ "-localip", "__PILLAR__LOCAL__DNS__", "-conf", "/etc/coredns/Corefile" ] args: [ "-localip", "__PILLAR__LOCAL__DNS__", "-conf", "/etc/coredns/Corefile" ]
securityContext: securityContext:
privileged: true privileged: true
ports: ports:
- containerPort: 53 - containerPort: 53
name: dns name: dns
@ -132,19 +130,15 @@ spec:
host: __PILLAR__LOCAL__DNS__ host: __PILLAR__LOCAL__DNS__
path: /health path: /health
port: 8080 port: 8080
scheme: HTTP
initialDelaySeconds: 60 initialDelaySeconds: 60
timeoutSeconds: 5 timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
volumeMounts: volumeMounts:
- name: config-volume - name: config-volume
mountPath: /etc/coredns mountPath: /etc/coredns
volumes: volumes:
- name: config-volume - name: config-volume
configMap: configMap:
name: nodelocaldns name: node-local-dns
items: items:
- key: Corefile - key: Corefile
path: Corefile path: Corefile
terminationGracePeriodSeconds: 30

View File

@ -1,150 +0,0 @@
# 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.
#
# Warning: This is a file generated from the base underscore template file: nodelocaldns.yaml.base
apiVersion: v1
kind: ServiceAccount
metadata:
name: nodelocaldns
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nodelocaldns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
data:
Corefile: |
{{ pillar['dns_domain'] }}:53 {
errors
cache 30
reload
loop
bind {{ pillar['local_dns_ip'] }}
forward . {{ pillar['dns_server'] }} {
force_tcp
}
prometheus :9253
health {{ pillar['local_dns_ip'] }}:8080
}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind {{ pillar['local_dns_ip'] }}
forward . {{ pillar['dns_server'] }} {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind {{ pillar['local_dns_ip'] }}
forward . {{ pillar['dns_server'] }} {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind {{ pillar['local_dns_ip'] }}
forward . /etc/resolv.conf {
force_tcp
}
prometheus :9253
}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nodelocaldns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:
selector:
matchLabels:
k8s-app: nodelocaldns
template:
metadata:
labels:
k8s-app: nodelocaldns
spec:
priorityClassName: system-node-critical
serviceAccountName: nodelocaldns
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_ip'] }}", "-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_ip'] }}
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
volumes:
- name: config-volume
configMap:
name: nodelocaldns
items:
- key: Corefile
path: Corefile
terminationGracePeriodSeconds: 30

View File

@ -1,150 +0,0 @@
# 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.
#
# Warning: This is a file generated from the base underscore template file: nodelocaldns.yaml.base
apiVersion: v1
kind: ServiceAccount
metadata:
name: nodelocaldns
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nodelocaldns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
data:
Corefile: |
$DNS_DOMAIN:53 {
errors
cache 30
reload
loop
bind $LOCAL_DNS_IP
forward . $DNS_SERVER_IP {
force_tcp
}
prometheus :9253
health $LOCAL_DNS_IP:8080
}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind $LOCAL_DNS_IP
forward . $DNS_SERVER_IP {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind $LOCAL_DNS_IP
forward . $DNS_SERVER_IP {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind $LOCAL_DNS_IP
forward . /etc/resolv.conf {
force_tcp
}
prometheus :9253
}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nodelocaldns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
spec:
selector:
matchLabels:
k8s-app: nodelocaldns
template:
metadata:
labels:
k8s-app: nodelocaldns
spec:
priorityClassName: system-node-critical
serviceAccountName: nodelocaldns
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", "$LOCAL_DNS_IP", "-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: $LOCAL_DNS_IP
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
volumes:
- name: config-volume
configMap:
name: nodelocaldns
items:
- key: Corefile
path: Corefile
terminationGracePeriodSeconds: 30

View File

@ -1,4 +0,0 @@
s/__PILLAR__DNS__SERVER__/{{ pillar['dns_server'] }}/g
s/__PILLAR__DNS__DOMAIN__/{{ pillar['dns_domain'] }}/g
s/__PILLAR__LOCAL__DNS__/{{ pillar['local_dns_ip'] }}/g
s/__MACHINE_GENERATED_WARNING__/Warning: This is a file generated from the base underscore template file: __SOURCE_FILENAME__/g

View File

@ -1,4 +0,0 @@
s/__PILLAR__DNS__SERVER__/$DNS_SERVER_IP/g
s/__PILLAR__DNS__DOMAIN__/$DNS_DOMAIN/g
s/__PILLAR__LOCAL__DNS__/$LOCAL_DNS_IP/g
s/__MACHINE_GENERATED_WARNING__/Warning: This is a file generated from the base underscore template file: __SOURCE_FILENAME__/g

View File

@ -108,10 +108,8 @@ export SERVICE_CLUSTER_IP_RANGE=${SERVICE_CLUSTER_IP_RANGE:-"192.168.3.0/24"}
# Optional: Install cluster DNS. # Optional: Install cluster DNS.
ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}" ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}"
ENABLE_NODELOCAL_DNS="${KUBE_ENABLE_NODELOCAL_DNS:-false}"
# DNS_SERVER_IP must be a IP in SERVICE_CLUSTER_IP_RANGE # DNS_SERVER_IP must be a IP in SERVICE_CLUSTER_IP_RANGE
DNS_SERVER_IP=${DNS_SERVER_IP:-"192.168.3.100"} DNS_SERVER_IP=${DNS_SERVER_IP:-"192.168.3.100"}
LOCAL_DNS_IP=${LOCAL_DNS_IP:-"169.254.20.10"}
DNS_DOMAIN=${DNS_DOMAIN:-"cluster.local"} DNS_DOMAIN=${DNS_DOMAIN:-"cluster.local"}
# Optional: Install Kubernetes UI # Optional: Install Kubernetes UI

View File

@ -31,7 +31,7 @@ function deploy_dns {
sed -i -e "s/\\\$DNS_SERVER_IP/${DNS_SERVER_IP}/g" kube-dns.yaml sed -i -e "s/\\\$DNS_SERVER_IP/${DNS_SERVER_IP}/g" kube-dns.yaml
KUBEDNS=`eval "${KUBECTL} get services --namespace=kube-system | grep kube-dns | cat"` KUBEDNS=`eval "${KUBECTL} get services --namespace=kube-system | grep kube-dns | cat"`
if [ ! "$KUBEDNS" ]; then if [ ! "$KUBEDNS" ]; then
# use kubectl to create kube-dns addon # use kubectl to create kube-dns addon
${KUBECTL} --namespace=kube-system create -f kube-dns.yaml ${KUBECTL} --namespace=kube-system create -f kube-dns.yaml
@ -44,28 +44,6 @@ function deploy_dns {
echo echo
} }
function deploy_nodelocaldns {
echo "Deploying NodeLocalDNS on Kubernetes"
cp "${KUBE_ROOT}/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml.sed" nodelocaldns.yaml
sed -i -e "s/\\\$DNS_DOMAIN/${DNS_DOMAIN}/g" nodelocaldns.yaml
sed -i -e "s/\\\$DNS_SERVER_IP/${DNS_SERVER_IP}/g" nodelocaldns.yaml
sed -i -e "s/\\\$LOCAL_DNS_IP/${LOCAL_DNS_IP}/g" nodelocaldns.yaml
NODELOCALDNS=$(${KUBECTL} get pods --namespace=kube-system -o jsonpath='{.items[*].metadata.name}' \
| tr ' ' "\n" | grep "nodelocaldns")
if [[ -z "${NODELOCALDNS}" ]]; then
# use kubectl to create nodelocaldns addon
${KUBECTL} --namespace=kube-system create -f nodelocaldns.yaml
echo "NodeLocalDNS addon is successfully deployed."
else
echo "NodeLocalDNS addon is already deployed. Skipping."
fi
echo
}
function deploy_dashboard { function deploy_dashboard {
echo "Deploying Kubernetes Dashboard" echo "Deploying Kubernetes Dashboard"
@ -79,14 +57,11 @@ function deploy_dashboard {
} }
if [[ "${ENABLE_CLUSTER_DNS}" == "true" ]]; then if [ "${ENABLE_CLUSTER_DNS}" == true ]; then
deploy_dns deploy_dns
fi fi
if [[ "${ENABLE_NODELOCAL_DNS}" == "true" ]]; then if [ "${ENABLE_CLUSTER_UI}" == true ]; then
deploy_nodelocaldns
fi
if [[ "${ENABLE_CLUSTER_UI}" == "true" ]]; then
deploy_dashboard deploy_dashboard
fi fi

View File

@ -302,16 +302,11 @@ function post-provision-master() {
# DOCKER_OPTS # DOCKER_OPTS
# DNS_SERVER_IP # DNS_SERVER_IP
# DNS_DOMAIN # DNS_DOMAIN
# ENABLE_NODELOCAL_DNS
# LOCAL_DNS_IP
function provision-node() { function provision-node() {
echo "[INFO] Provision node on $1" echo "[INFO] Provision node on $1"
local node=$1 local node=$1
local node_ip=${node#*@} local node_ip=${node#*@}
local dns_ip=${DNS_SERVER_IP#*@} local dns_ip=${DNS_SERVER_IP#*@}
if [ "${ENABLE_NODELOCAL_DNS}" == true ]; then
dns_ip=${LOCAL_DNS_IP}
fi
local dns_domain=${DNS_DOMAIN#*@} local dns_domain=${DNS_DOMAIN#*@}
ensure-setup-dir ${node} ensure-setup-dir ${node}

View File

@ -2351,12 +2351,12 @@ EOF
# Sets up the manifests of local dns cache agent for k8s addons. # Sets up the manifests of local dns cache agent for k8s addons.
function setup-nodelocaldns-manifest { function setup-nodelocaldns-manifest {
setup-addon-manifests "addons" "dns/nodelocaldns"
local -r localdns_file="${dst_dir}/dns/nodelocaldns/nodelocaldns.yaml" local -r localdns_file="${dst_dir}/dns/nodelocaldns/nodelocaldns.yaml"
mv "${dst_dir}/dns/nodelocaldns/nodelocaldns.yaml.in" "${localdns_file}" # Replace the sed configurations with variable values.
# Replace the salt configurations with variable values. sed -i -e "s/__PILLAR__DNS__DOMAIN__/${DNS_DOMAIN}/g" "${localdns_file}"
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\['dns_server'\] *}}@${DNS_SERVER_IP}@g" "${localdns_file}" sed -i -e "s/__PILLAR__LOCAL__DNS__/${LOCAL_DNS_IP}/g" "${localdns_file}"
sed -i -e "s@{{ *pillar\['local_dns_ip'\] *}}@${LOCAL_DNS_IP}@g" "${localdns_file}"
} }
# Sets up the manifests of netd for k8s addons. # Sets up the manifests of netd for k8s addons.
@ -2531,7 +2531,6 @@ EOF
setup-kube-dns-manifest setup-kube-dns-manifest
fi fi
if [[ "${ENABLE_NODELOCAL_DNS:-}" == "true" ]]; then if [[ "${ENABLE_NODELOCAL_DNS:-}" == "true" ]]; then
setup-addon-manifests "addons" "dns/nodelocaldns"
setup-nodelocaldns-manifest setup-nodelocaldns-manifest
fi fi
fi fi

View File

@ -706,7 +706,7 @@ function start_kubelet {
mkdir -p "/var/lib/kubelet" &>/dev/null || sudo mkdir -p "/var/lib/kubelet" mkdir -p "/var/lib/kubelet" &>/dev/null || sudo mkdir -p "/var/lib/kubelet"
# Enable dns # Enable dns
if [[ "${ENABLE_CLUSTER_DNS}" = true ]]; then if [[ "${ENABLE_CLUSTER_DNS}" = true ]]; then
if [[ "${ENABLE_NODELOCAL_DNS}" = true ]]; then if [[ "${ENABLE_NODELOCAL_DNS:-}" == "true" ]]; then
dns_args="--cluster-dns=${LOCAL_DNS_IP} --cluster-domain=${DNS_DOMAIN}" dns_args="--cluster-dns=${LOCAL_DNS_IP} --cluster-domain=${DNS_DOMAIN}"
else else
dns_args="--cluster-dns=${DNS_SERVER_IP} --cluster-domain=${DNS_DOMAIN}" dns_args="--cluster-dns=${DNS_SERVER_IP} --cluster-domain=${DNS_DOMAIN}"
@ -915,22 +915,14 @@ function start_kubedns {
} }
function start_nodelocaldns { function start_nodelocaldns {
if [[ "${ENABLE_NODELOCAL_DNS}" = true ]]; then cp "${KUBE_ROOT}/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml" nodelocaldns.yaml
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_domain'\] }}/${DNS_DOMAIN}/g" nodelocaldns.yaml sed -i -e "s/__PILLAR__DNS__SERVER__/${DNS_SERVER_IP}/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
sed -i -e "s/{{ pillar\['local_dns_ip'\] }}/${LOCAL_DNS_IP}/g" nodelocaldns.yaml # use kubectl to create nodelocaldns addon
if [[ -n "${CLUSTER_IP_RANGE:-}" ]]; then ${KUBECTL} --kubeconfig="${CERT_DIR}/admin.kubeconfig" --namespace=kube-system create -f nodelocaldns.yaml
sed -i -e "s@{{ *pillar\['service_cluster_ip_range'\] *}}@${CLUSTER_IP_RANGE}@g" nodelocaldns.yaml echo "NodeLocalDNS addon successfully deployed."
else rm nodelocaldns.yaml
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 { function start_kubedashboard {
@ -1081,7 +1073,9 @@ if [[ "${START_MODE}" != "kubeletonly" ]]; then
fi fi
start_kubeproxy start_kubeproxy
start_kubedns start_kubedns
start_nodelocaldns if [[ "${ENABLE_NODELOCAL_DNS:-}" == "true" ]]; then
start_nodelocaldns
fi
start_kubedashboard start_kubedashboard
fi fi