Skip to content

Commit

Permalink
Merge kube-dns templates into a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHohn committed Oct 3, 2017
1 parent f369c1a commit db8f9dd
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
- /cluster-proportional-autoscaler
- --namespace=kube-system
- --configmap=kube-dns-autoscaler
# Should keep target in sync with cluster/addons/dns/kubedns-controller.yaml.base
# Should keep target in sync with cluster/addons/dns/kube-dns.yaml.base
- --target=Deployment/kube-dns
# When cluster is using large nodes(with more cores), "coresPerReplica" should dominate.
# If using small nodes, "nodesPerReplica" should dominate.
Expand Down
2 changes: 1 addition & 1 deletion cluster/addons/dns/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ all: transform
%.sed: %.base
sed -f transforms2sed.sed $< | sed s/__SOURCE_FILENAME__/$</g > $@

transform: kubedns-controller.yaml.in kubedns-svc.yaml.in kubedns-controller.yaml.sed kubedns-svc.yaml.sed
transform: kube-dns.yaml.in kube-dns.yaml.sed

.PHONY: transform
16 changes: 6 additions & 10 deletions cluster/addons/dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ will be clobbered, in addition the replicas count for kube-dns Deployment will
be reset to 1. See [Cluster add-ons README](../README.md) and
[#36411](https://github.com/kubernetes/kubernetes/issues/36411) for reference.

## kube-dns Deployment and Service templates
## kube-dns addon templates

This directory contains the base UNDERSCORE templates that can be used to
generate the kubedns-controller.yaml.in and kubedns.controller.yaml.in needed in
Salt format.
generate the kube-dns.yaml.in needed in Salt format.

Due to a varied preference in templating language choices, the transform
Makefile in this directory should be enhanced to generate all required formats
Expand All @@ -38,7 +37,7 @@ that supply values for your new parameter. Here is one way you might find those
scripts:

```
cd kubernetes && git grep 'kubedns-controller.yaml'
cd kubernetes && git grep 'kube-dns.yaml'
```

### Base Template files
Expand All @@ -47,22 +46,19 @@ These are the authoritative base templates.
Run 'make' to generate the Salt and Sed yaml templates from these.

```
kubedns-controller.yaml.base
kubedns-svc.yaml.base
kube-dns.yaml.base
```

### Generated Salt files

```
kubedns-controller.yaml.in
kubedns-svc.yaml.in
kube-dns.yaml.in
```

### Generated Sed files

```
kubedns-controller.yaml.sed
kubedns-svc.yaml.sed
kube-dns.yaml.sed
```

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/addons/dns/README.md?pixel)]()
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,45 @@

# __MACHINE_GENERATED_WARNING__

apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: __PILLAR__DNS__SERVER__
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-dns
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kube-dns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,47 @@
# Should keep target in cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml
# in sync with this file.

# Warning: This is a file generated from the base underscore template file: kubedns-controller.yaml.base
# Warning: This is a file generated from the base underscore template file: kube-dns.yaml.base

apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: {{ pillar['dns_server'] }}
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-dns
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kube-dns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,47 @@
# Should keep target in cluster/addons/dns-horizontal-autoscaler/dns-horizontal-autoscaler.yaml
# in sync with this file.

# Warning: This is a file generated from the base underscore template file: kubedns-controller.yaml.base
# Warning: This is a file generated from the base underscore template file: kube-dns.yaml.base

apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "KubeDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: $DNS_SERVER_IP
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-dns
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: kube-dns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down
21 changes: 0 additions & 21 deletions cluster/addons/dns/kubedns-cm.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions cluster/addons/dns/kubedns-sa.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions cluster/addons/dns/kubedns-svc.yaml.base

This file was deleted.

37 changes: 0 additions & 37 deletions cluster/addons/dns/kubedns-svc.yaml.in

This file was deleted.

37 changes: 0 additions & 37 deletions cluster/addons/dns/kubedns-svc.yaml.sed

This file was deleted.

16 changes: 7 additions & 9 deletions cluster/centos/deployAddons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@ export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/centos/config-d

function deploy_dns {
echo "Deploying DNS on Kubernetes"
sed -e "s/\\\$DNS_DOMAIN/${DNS_DOMAIN}/g" "${KUBE_ROOT}/cluster/addons/dns/kubedns-controller.yaml.sed" > kubedns-controller.yaml
sed -e "s/\\\$DNS_SERVER_IP/${DNS_SERVER_IP}/g" "${KUBE_ROOT}/cluster/addons/dns/kubedns-svc.yaml.sed" > kubedns-svc.yaml
cp "${KUBE_ROOT}/cluster/addons/dns/kube-dns.yaml.sed" kube-dns.yaml
sed -i -e "s/\\\$DNS_DOMAIN/${DNS_DOMAIN}/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"`

if [ ! "$KUBEDNS" ]; then
# use kubectl to create kube-dns deployment and service
${KUBECTL} --namespace=kube-system create -f kubedns-sa.yaml
${KUBECTL} --namespace=kube-system create -f kubedns-cm.yaml
${KUBECTL} --namespace=kube-system create -f kubedns-controller.yaml
${KUBECTL} --namespace=kube-system create -f kubedns-svc.yaml
# use kubectl to create kube-dns addon
${KUBECTL} --namespace=kube-system create -f kube-dns.yaml

echo "Kube-dns deployment and service is successfully deployed."
echo "Kube-dns addon is successfully deployed."
else
echo "Kube-dns deployment and service is already deployed. Skipping."
echo "Kube-dns addon is already deployed. Skipping."
fi

echo
Expand Down
Loading

0 comments on commit db8f9dd

Please sign in to comment.