Skip to content

Commit

Permalink
Add ability to provide custom CoreDNS Tolerations and Affinity
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Sep 22, 2021
1 parent b5de993 commit 416ffde
Show file tree
Hide file tree
Showing 13 changed files with 1,453 additions and 0 deletions.
908 changes: 908 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/apis/kops/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kops
import (
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -470,6 +471,10 @@ type KubeDNSConfig struct {
CacheMaxSize int `json:"cacheMaxSize,omitempty"`
// CacheMaxConcurrent is the maximum number of concurrent queries for dnsmasq
CacheMaxConcurrent int `json:"cacheMaxConcurrent,omitempty"`
// Tolerations are tolerations to apply to the kube-dns deployment
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Affinity is the kube-dns affinity, uses the same syntax as kubectl's affinity
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// CoreDNSImage is used to override the default image used for CoreDNS
CoreDNSImage string `json:"coreDNSImage,omitempty"`
// CPAImage is used to override the default image used for Cluster Proportional Autoscaler
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/v1alpha2/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha2

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -471,6 +472,10 @@ type KubeDNSConfig struct {
CacheMaxSize int `json:"cacheMaxSize,omitempty"`
// CacheMaxConcurrent is the maximum number of concurrent queries for dnsmasq
CacheMaxConcurrent int `json:"cacheMaxConcurrent,omitempty"`
// Tolerations are tolerations to apply to the kube-dns deployment
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Affinity is the kube-dns affinity, uses the same syntax as kubectl's affinity
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// CoreDNSImage is used to override the default image used for CoreDNS
CoreDNSImage string `json:"coreDNSImage,omitempty"`
// CPAImage is used to override the default image used for Cluster Proportional Autoscaler
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,18 @@ spec:
priorityClassName: system-cluster-critical
serviceAccountName: coredns
tolerations:
{{- if KubeDNS.Tolerations }}
{{ KubeDNS.Tolerations | indent 8 }}
{{- else }}
- key: "CriticalAddonsOnly"
operator: "Exists"
{{- end }}
nodeSelector:
kubernetes.io/os: linux
affinity:
{{- if KubeDNS.Affinity }}
{{ KubeDNS.Affinity | indent 8 }}
{{- else }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
Expand All @@ -132,6 +139,7 @@ spec:
operator: In
values: ["kube-dns"]
topologyKey: kubernetes.io/hostname
{{- end }}
containers:
- name: coredns
image: {{ if KubeDNS.CoreDNSImage }}{{ KubeDNS.CoreDNSImage }}{{ else }}k8s.gcr.io/coredns/coredns:v1.8.4{{ end }}
Expand Down
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/bootstrapchannelbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestBootstrapChannelBuilder_BuildTasks(t *testing.T) {
runChannelBuilderTest(t, "metrics-server/insecure-1.19", []string{"metrics-server.addons.k8s.io-k8s-1.11"})
runChannelBuilderTest(t, "metrics-server/secure-1.18", []string{"metrics-server.addons.k8s.io-k8s-1.11"})
runChannelBuilderTest(t, "metrics-server/secure-1.19", []string{"metrics-server.addons.k8s.io-k8s-1.11"})
runChannelBuilderTest(t, "coredns", []string{"coredns.addons.k8s.io-k8s-1.12"})
}

func TestBootstrapChannelBuilder_ServiceAccountIAM(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
metadata:
creationTimestamp: "2016-12-10T22:42:27Z"
name: minimal.example.com
spec:
kubernetesApiAccess:
- 0.0.0.0/0
channel: stable
cloudProvider: aws
configBase: memfs://clusters.example.com/minimal.example.com
etcdClusters:
- etcdMembers:
- instanceGroup: master-us-test-1a
name: master-us-test-1a
name: main
- etcdMembers:
- instanceGroup: master-us-test-1a
name: master-us-test-1a
name: events
iam: {}
kubernetesVersion: v1.20.0
kubeDNS:
provider: CoreDNS
tolerations:
- effect: NoSchedule
operator: Exists
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kops.k8s.io/instancegroup
operator: In
values:
- master
- ondemand-nodes
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values:
- kube-dns
topologyKey: kubernetes.io/hostname
weight: 100
masterInternalName: api.internal.minimal.example.com
masterPublicName: api.minimal.example.com
networkCIDR: 172.20.0.0/16
networking:
cni: {}
nonMasqueradeCIDR: 100.64.0.0/10
sshAccess:
- 0.0.0.0/0
topology:
masters: public
nodes: public
subnets:
- cidr: 172.20.32.0/19
name: us-test-1a
type: Public
zone: us-test-1a
Loading

0 comments on commit 416ffde

Please sign in to comment.