This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Adds a generic CoreDNS chart #785
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,21 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj |
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,16 @@ | ||
name: coredns | ||
version: 0.1.0 | ||
description: CoreDNS is a DNS server that chains middleware and provides Kubernetes DNS Services | ||
keywords: | ||
- coredns | ||
- dns | ||
- kubedns | ||
home: https://coredns.io | ||
icon: https://raw.githubusercontent.com/coredns/logo/master/Icon/CoreDNS_Colour_Icon.svg | ||
sources: | ||
- https://github.com/coredns/coredns | ||
maintainers: | ||
- name: Acaleph | ||
email: [email protected] | ||
- name: Shashidhara TD | ||
email: [email protected] |
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,82 @@ | ||
CoreDNS | ||
======= | ||
|
||
CoreDNS is a DNS server that chains middleware and provides DNS Services | ||
|
||
TL;DR; | ||
------ | ||
|
||
```console | ||
$ helm install --name coredns --namespace=kube-system stable/coredns | ||
``` | ||
|
||
Introduction | ||
------------ | ||
|
||
This chart bootstraps a [CoreDNS](https://github.com/coredns/coredns) deployment on a [Kubernetes](http:https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. This chart will provide DNS Services and can be deployed in multiple configuration to support various scenarios listed below: | ||
|
||
- CoreDNS as a cluster dns service and a drop-in replacement for Kube/SkyDNS. This is the default mode and CoreDNS is deployed as cluster-service in kube-system namespace. This mode is chosen by setting `isClusterService` to true. | ||
- CoreDNS as an external dns service. In this mode CoreDNS is deployed as any kubernetes app in user specified namespace. The CoreDNS service can be exposed outside the cluster by using using either the NodePort or LoadBalancer type of service. This mode is chosen by setting `isClusterService` to false. | ||
- CoreDNS as an external dns provider for kubernetes federation. This is a sub case of 'external dns service' which uses etcd middleware for CoreDNS backend. This deployment mode as a dependency on `etcd-operator` chart, which needs to be pre-installed. To use this deployment mode use below configuration file to override default values. | ||
``` | ||
isClusterService: false | ||
serviceType: "NodePort" | ||
middleware: | ||
kubernetes: | ||
enabled: false | ||
etcd: | ||
enabled: true | ||
zones: | ||
- "<example.io>" | ||
endpoint: "http:https://<etcd-cluster>:2379" | ||
``` | ||
|
||
Prerequisites | ||
------------- | ||
|
||
- Kubernetes 1.4+ with Beta APIs enabled | ||
|
||
Installing the Chart | ||
-------------------- | ||
|
||
The chart can be installed as follows: | ||
|
||
```console | ||
$ helm install --name coredns --namespace=kube-system stable/coredns | ||
``` | ||
|
||
The command deploys CoreDNS on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists various ways to override default configuration during deployment. | ||
|
||
> **Tip**: List all releases using `helm list` | ||
|
||
Uninstalling the Chart | ||
---------------------- | ||
|
||
To uninstall/delete the `my-release` deployment: | ||
|
||
```console | ||
$ helm delete coredns | ||
``` | ||
|
||
The command removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
Configuration | ||
------------- | ||
|
||
See `values.yaml` for configuration notes. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, | ||
|
||
```console | ||
$ helm install --name coredns \ | ||
--set middleware.prometheus.enabled=false \ | ||
stable/coredns | ||
``` | ||
|
||
The above command disables the Prometheus middleware. | ||
|
||
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, | ||
|
||
```console | ||
$ helm install --name coredns -f values.yaml stable/coredns | ||
``` | ||
|
||
> **Tip**: You can use the default [values.yaml](values.yaml) |
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,30 @@ | ||
{{- if .Values.isClusterService }} | ||
CoreDNS is now running in the cluster as a cluster-service. | ||
{{- else }} | ||
CoreDNS is now running in the cluster. | ||
It can be accessed using the below endpoint | ||
{{- if contains "NodePort" .Values.serviceType }} | ||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) | ||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") | ||
echo "$NODE_IP:$NODE_PORT" | ||
{{- else if contains "LoadBalancer" .Values.serviceType }} | ||
NOTE: It may take a few minutes for the LoadBalancer IP to be available. | ||
You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' | ||
|
||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') | ||
echo $SERVICE_IP | ||
{{- else if contains "ClusterIP" .Values.serviceType }} | ||
"{{ template "fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local" | ||
from within the cluster | ||
{{- end }} | ||
{{- end }} | ||
|
||
It can be tested with the following: | ||
|
||
1. Launch a Pod with DNS tools: | ||
|
||
kubectl run -it --rm --restart=Never --image=infoblox/dnstools:latest dnstools | ||
|
||
2. Query the DNS server: | ||
|
||
/ # host kubernetes |
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,16 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "fullname" -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
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,44 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
data: | ||
Corefile: |- | ||
.:53 { | ||
{{- range $key, $middleware := .Values.middleware }} | ||
{{- if $middleware.enabled }} | ||
{{- if eq "kubernetes" $key }} | ||
kubernetes {{ $middleware.clusterDomain }} { | ||
cidrs {{ $middleware.clusterCidr }} | ||
} | ||
{{- end }} | ||
{{- if eq "etcd" $key }} | ||
etcd {{ range $middleware.zones }}{{ . }} {{ end }}{ | ||
{{ if $middleware.path }}path {{ $middleware.path }}{{ end }} | ||
endpoint {{ $middleware.endpoint }} | ||
} | ||
{{- end }} | ||
{{- if eq "loadbalance" $key }} | ||
loadbalance {{ default "round_robin" $middleware.policy }} | ||
{{- end }} | ||
{{- if eq "log" $key }} | ||
log {{ default "stdout" $middleware.file }} | ||
{{- end }} | ||
{{- if eq "errors" $key }} | ||
errors {{ default "stderr" $middleware.file }} | ||
{{- end }} | ||
{{- if eq "health" $key }} | ||
health | ||
{{- end }} | ||
{{- if eq "prometheus" $key }} | ||
prometheus localhost:{{ $middleware.port }} | ||
{{- end }} | ||
{{- if eq "proxy" $key }} | ||
proxy . /etc/resolv.conf | ||
{{- end }} | ||
{{- if eq "cache" $key }} | ||
cache 30 | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
} |
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,72 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
{{- if .Values.isClusterService }} | ||
k8s-app: {{ .Chart.Name | quote }} | ||
kubernetes.io/cluster-service: "true" | ||
kubernetes.io/name: "CoreDNS" | ||
{{- else }} | ||
app: {{ template "fullname" . }} | ||
{{- end }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
{{- if .Values.isClusterService }} | ||
k8s-app: {{ .Chart.Name | quote }} | ||
{{- else }} | ||
app: {{ template "fullname" . }} | ||
{{- end }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- if .Values.isClusterService }} | ||
k8s-app: {{ .Chart.Name | quote }} | ||
{{- else }} | ||
app: {{ template "fullname" . }} | ||
{{- end }} | ||
release: {{ .Release.Name | quote }} | ||
annotations: | ||
{{- if .Values.isClusterService }} | ||
scheduler.alpha.kubernetes.io/critical-pod: '' | ||
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]' | ||
{{- end }} | ||
spec: | ||
containers: | ||
- name: "coredns" | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
args: [ "-conf", "/etc/coredns/Corefile" ] | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/coredns | ||
resources: | ||
{{ toYaml .Values.resources | indent 10 }} | ||
ports: | ||
- containerPort: 53 | ||
name: dns | ||
protocol: UDP | ||
- containerPort: 53 | ||
name: dns-tcp | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 60 | ||
timeoutSeconds: 5 | ||
successThreshold: 1 | ||
failureThreshold: 5 | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: {{ template "fullname" . }} | ||
items: | ||
- key: Corefile | ||
path: Corefile |
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,38 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
{{- if .Values.isClusterService }} | ||
k8s-app: {{ .Chart.Name | quote }} | ||
kubernetes.io/cluster-service: "true" | ||
kubernetes.io/name: "CoreDNS" | ||
{{- else }} | ||
app: {{ template "fullname" . }} | ||
{{- end }} | ||
annotations: | ||
{{- if .Values.middleware.prometheus.enabled }} | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: {{ .Values.middleware.prometheus.port | quote }} | ||
{{- end }} | ||
spec: | ||
selector: | ||
{{- if .Values.isClusterService }} | ||
k8s-app: {{ .Chart.Name | quote }} | ||
{{- else }} | ||
app: {{ template "fullname" . }} | ||
{{- end }} | ||
{{- if .Values.isClusterService }} | ||
clusterIP: {{ .Values.middleware.kubernetes.clusterIP }} | ||
{{- end }} | ||
ports: | ||
- name: dns | ||
port: 53 | ||
protocol: UDP | ||
- name: dns-tcp | ||
port: 53 | ||
protocol: TCP | ||
type: {{ default "ClusterIP" .Values.serviceType }} |
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,57 @@ | ||
# Default values for coredns. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
replicaCount: 1 | ||
|
||
image: | ||
repository: coredns/coredns | ||
tag: "006" | ||
pullPolicy: IfNotPresent | ||
|
||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 128Mi | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
|
||
# isClusterService specifies whether chart should be deployed as cluster-service or normal k8s app. | ||
isClusterService: true | ||
|
||
# serviceType specifies type of service to be created for this chart. | ||
serviceType: "ClusterIP" | ||
|
||
# middleware configuration of CoreDNS refer to https://github.com/coredns/coredns/tree/master/middleware | ||
# for all specific details. set enabled to true/false to enable/disable a middleware. | ||
middleware: | ||
kubernetes: | ||
enabled: true | ||
clusterCidr: "10.3.0.0/24" | ||
clusterDomain: "cluster.local" | ||
clusterIP: | ||
prometheus: | ||
enabled: true | ||
port: "9153" | ||
errors: | ||
enabled: true | ||
file: "stderr" | ||
log: | ||
enabled: false | ||
file: "stdout" | ||
health: | ||
enabled: true | ||
proxy: | ||
enabled: true | ||
cache: | ||
enabled: true | ||
loadbalance: | ||
enabled: true | ||
policy: "round_robin" | ||
etcd: | ||
enabled: false | ||
zones: | ||
- "k8s.io" | ||
path: "/skydns" | ||
endpoint: "http:https://localhost:2379" |
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.
@prydonius @lachie83 should use of alpha schedulers warrant this chart belonging in
incubator/
?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.
@seanknox, thanks for the review. This alpha scheduler API is used by almost all the addons in kubernetes including the
kube-dns
. I do not think the alpha tagging, affect the stability of that API and moreover its used in annotation. All said i am OK to move this chart to incubator if warrants.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.
This only applies to alpha APIs, not alpha annotations