This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Use core-dns over kube-dns for clusters >= 1.10 #715
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1dc1ecd
Use code-dns for Kubernetes > 0.10
JoshVanL a5034f7
Ensure old dns deployment is removed from cluster
JoshVanL f3ffc46
Ensure kube-dns is delete when migrating
JoshVanL ce1cf71
Update acceptance tests to use core-dns
JoshVanL 0f5c5e6
Adds Prometheus scaping for core-dns, removes kubectl delete
JoshVanL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# deletes resources to a kubernetes master | ||
define kubernetes::delete( | ||
$format = 'yaml', | ||
){ | ||
require ::kubernetes | ||
|
||
$apply_file = "${::kubernetes::apply_dir}/${name}.${format}" | ||
|
||
file {$apply_file: | ||
ensure => absent, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,61 @@ | ||
require 'spec_helper' | ||
|
||
describe 'kubernetes::dns' do | ||
let(:pre_condition) do | ||
[ | ||
'include kubernetes::apiserver' | ||
] | ||
context 'with default values for all parameters' do | ||
let(:pre_condition) do | ||
" | ||
class{'kubernetes': version => '1.9.0'} | ||
define kubernetes::apply( | ||
$manifests, | ||
){ | ||
kubernetes::addon_manager_labels($manifests[0]) | ||
} | ||
define kubernetes::delete(){} | ||
" | ||
end | ||
|
||
let(:manifests) do | ||
catalogue.resource('Kubernetes::Apply', 'kube-dns').send(:parameters)[:manifests] | ||
end | ||
|
||
it { should contain_class('kubernetes::dns') } | ||
|
||
it 'be valid yaml' do | ||
manifests.each do |manifest| | ||
YAML.parse manifest | ||
end | ||
end | ||
|
||
it 'should write manifests' do | ||
expect(manifests.join('\n---\n')).to match(%{--domain=cluster\.local\.}) | ||
expect(manifests.join('\n---\n')).to match(%{clusterIP: 10\.254\.0\.10}) | ||
end | ||
end | ||
|
||
context 'with default values for all parameters' do | ||
context 'with version 1.11' do | ||
let(:pre_condition) do | ||
" | ||
class{'kubernetes': version => '1.11.0'} | ||
define kubernetes::apply( | ||
$manifests, | ||
){ | ||
kubernetes::addon_manager_labels($manifests[0]) | ||
} | ||
define kubernetes::delete(){} | ||
" | ||
end | ||
|
||
let(:manifests) do | ||
catalogue.resource('Kubernetes::Apply', 'core-dns').send(:parameters)[:manifests] | ||
end | ||
|
||
it 'be valid yaml' do | ||
manifests.each do |manifest| | ||
YAML.parse manifest | ||
end | ||
end | ||
|
||
it { should contain_class('kubernetes::dns') } | ||
|
||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
puppet/modules/kubernetes/templates/core-dns-config-map.yaml.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: coredns | ||
namespace: kube-system | ||
labels: | ||
addonmanager.kubernetes.io/mode: Reconcile | ||
data: | ||
Corefile: | | ||
.:53 { | ||
errors | ||
health | ||
kubernetes <%= @cluster_domain %> in-addr.arpa ip6.arpa { | ||
pods insecure | ||
upstream | ||
fallthrough in-addr.arpa ip6.arpa | ||
} | ||
prometheus :9153 | ||
proxy . /etc/resolv.conf | ||
cache 30 | ||
reload | ||
loadbalance | ||
} |
88 changes: 88 additions & 0 deletions
88
puppet/modules/kubernetes/templates/core-dns-deployment.yaml.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: core-dns | ||
namespace: kube-system | ||
labels: | ||
k8s-app: core-dns | ||
kubernetes.io/name: "CoreDNS" | ||
addonmanager.kubernetes.io/mode: Reconcile | ||
spec: | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 10% | ||
maxUnavailable: 0 | ||
selector: | ||
matchLabels: | ||
k8s-app: core-dns | ||
template: | ||
metadata: | ||
labels: | ||
k8s-app: core-dns | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
prometheus.io/port: '9153' | ||
scheduler.alpha.kubernetes.io/critical-pod: '' | ||
<%- if @version_before_1_6 -%> | ||
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]' | ||
<%- end -%> | ||
spec: | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
effect: NoSchedule | ||
- key: "CriticalAddonsOnly" | ||
operator: "Exists" | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: coredns | ||
items: | ||
- key: Corefile | ||
path: Corefile | ||
containers: | ||
- name: core-dns | ||
image: coredns/coredns:1.2.0 | ||
imagePullPolicy: IfNotPresent | ||
resources: | ||
limits: | ||
memory: 170Mi | ||
requests: | ||
cpu: 100m | ||
memory: 70Mi | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 60 | ||
timeoutSeconds: 5 | ||
successThreshold: 1 | ||
failureThreshold: 5 | ||
args: [ "-conf", "/etc/coredns/Corefile" ] | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/coredns | ||
readOnly: true | ||
ports: | ||
- containerPort: 53 | ||
name: dns | ||
protocol: UDP | ||
- containerPort: 53 | ||
name: dns-tcp | ||
protocol: TCP | ||
- containerPort: 9153 | ||
name: metrics | ||
protocol: TCP | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
add: | ||
- NET_BIND_SERVICE | ||
drop: | ||
- all | ||
readOnlyRootFilesystem: true | ||
dnsPolicy: Default | ||
<%- if @rbac_enabled -%> | ||
serviceAccountName: core-dns | ||
<%- end -%> |
17 changes: 17 additions & 0 deletions
17
puppet/modules/kubernetes/templates/dns-cluster-role-binding.yaml.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
annotations: | ||
rbac.authorization.kubernetes.io/autoupdate: "true" | ||
addonmanager.kubernetes.io/mode: Reconcile | ||
labels: | ||
kubernetes.io/bootstrapping: rbac-defaults | ||
name: system:<%= @app_name %> | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: system:<%= @app_name %> | ||
subjects: | ||
- kind: ServiceAccount | ||
name: <%= @app_name %> | ||
namespace: kube-system |
18 changes: 18 additions & 0 deletions
18
puppet/modules/kubernetes/templates/dns-cluster-role.yaml.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
kubernetes.io/bootstrapping: rbac-defaults | ||
addonmanager.kubernetes.io/mode: Reconcile | ||
name: system:<%= @app_name %> | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- endpoints | ||
- services | ||
- pods | ||
- namespaces | ||
verbs: | ||
- list | ||
- watch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we setup the annotation to scrape it?