Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Always create required dnsmasq resources
Browse files Browse the repository at this point in the history
The dnsmasq-node ServiceAccount must exist whether or not CoreDNS-local
has been enabled. Therefore, it is created alongside the DaemonSet rather
than as part of the coredns-local manifest.

Additionally, always create dnsmasq-node-coredns-local.yaml If this file
does not exist (as would be the case if the CoreDNS local feature has
not been enabled), controller nodes will fail to come up with the error:
> error: the path "/srv/kubernetes/manifests/dnsmasq-node-coredns-local.yaml" does not exist
This is caused when `kubectl delete` is called against the file because
of the line `remove "${mfdir}/dnsmasq-node-coredns-local.yaml`.

This manifest must always be generated because the CoreDNS-local
feature cannot be enabled and then later disabled without otherwise
requiring manual operator intervention.
  • Loading branch information
kfr2 committed Aug 26, 2020
1 parent 27bd765 commit 5483b50
Showing 1 changed file with 42 additions and 44 deletions.
86 changes: 42 additions & 44 deletions builtin/files/userdata/cloud-config-controller
Original file line number Diff line number Diff line change
Expand Up @@ -5445,51 +5445,8 @@ write_files:
- --v=2
- --logtostderr

{{ if and .KubeDns.NodeLocalResolver .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
- path: /srv/kubernetes/manifests/dnsmasq-node-coredns-local.yaml
content: |
apiVersion: v1
kind: ServiceAccount
metadata:
name: dnsmasq
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dnsmasq
rules:
- apiGroups: [""]
resources: ["endpoints", "services", "pods", "namespaces"]
verbs: ["list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dnsmasq
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dnsmasq
subjects:
- kind: ServiceAccount
name: dnsmasq
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dnsmasq-privileged-psp
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-psp
subjects:
- kind: ServiceAccount
name: dnsmasq
namespace: kube-system
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -5522,11 +5479,52 @@ write_files:
cache 30
reload
}
{{ end }}

{{ if .KubeDns.NodeLocalResolver }}
- path: /srv/kubernetes/manifests/dnsmasq-node-ds.yaml
content: |
apiVersion: v1
kind: ServiceAccount
metadata:
name: dnsmasq
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: dnsmasq
rules:
- apiGroups: [""]
resources: ["endpoints", "services", "pods", "namespaces"]
verbs: ["list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dnsmasq
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dnsmasq
subjects:
- kind: ServiceAccount
name: dnsmasq
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dnsmasq-privileged-psp
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-psp
subjects:
- kind: ServiceAccount
name: dnsmasq
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down

0 comments on commit 5483b50

Please sign in to comment.