Skip to content

Commit f13b122

Browse files
committed
started work on eks bootstrap config changes
Signed-off-by: Richard Case <richard@weave.works>
1 parent bab7f7e commit f13b122

11 files changed

+544
-61
lines changed

bootstrap/eks/api/v1alpha3/zz_generated.conversion.go

+30-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/eks/api/v1alpha4/zz_generated.conversion.go

+30-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/eks/api/v1beta1/eksconfig_types.go

+31
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,37 @@ type EKSConfigSpec struct {
2626
// KubeletExtraArgs passes the specified kubelet args into the Amazon EKS machine bootstrap script
2727
// +optional
2828
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
29+
// ContainerRuntime specify the container runtime to use when bootstrapping EKS.
30+
// +optional
31+
ContainerRuntime *string `json:"containerRuntime,omitempty"`
32+
// DNSClusterIP overrides the IP address to use for DNS queries within the cluster.
33+
// +optional
34+
DNSClusterIP *string `json:"dnsClusterIP,omitempty"`
35+
// DockerConfigJson is used for the contents of the /etc/docker/daemon.json file. Useful if you want a custom config differing from the default one in the AMI.
36+
// This is expected to be a json string.
37+
// +optional
38+
DockerConfigJson *string `json:"dockerConfigJson,omitempty"`
39+
// APIRetryAttempts is the number of retry attempts for AWS API call.
40+
// +optional
41+
APIRetryAttempts *int `json:"apiRetryAttempts,omitempty"`
42+
// PauseContainer allows customization of the pause container to use.
43+
// +optional
44+
PauseContainer *PauseContainer `json:"pauseContainer,omitempty"`
45+
// UseMaxPods sets --max-pods for the kubelet when true.
46+
// +optional
47+
UseMaxPods *bool `json:"useMaxPods,omitempty"`
48+
// ServiceIPV6Cidr is the ipv6 cidr range of the cluster. If this is specifed then
49+
// the ip family will be set to ipv6.
50+
// +optional
51+
ServiceIPV6Cidr *string `json:"serviceIPV6Cidr,omitempty"`
52+
}
53+
54+
// PauseContainer
55+
type PauseContainer struct {
56+
// AccountNumber is the AWS account number to pull the pause container from.
57+
AccountNumber string `json:"accountNumber"`
58+
// Version is the tag of the pause container to use.
59+
Version string `json:"version"`
2960
}
3061

3162
// EKSConfigStatus defines the observed state of the Amazon EKS Bootstrap Configuration.

bootstrap/eks/api/v1beta1/zz_generated.deepcopy.go

+55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/eks/controllers/eksconfig_controller.go

+24-7
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ import (
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/runtime"
2929
"k8s.io/utils/pointer"
30-
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
31-
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/internal/userdata"
32-
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1"
30+
3331
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3432
bsutil "sigs.k8s.io/cluster-api/bootstrap/util"
3533
expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
@@ -39,11 +37,16 @@ import (
3937
"sigs.k8s.io/cluster-api/util/conditions"
4038
"sigs.k8s.io/cluster-api/util/patch"
4139
"sigs.k8s.io/cluster-api/util/predicates"
40+
4241
ctrl "sigs.k8s.io/controller-runtime"
4342
"sigs.k8s.io/controller-runtime/pkg/client"
4443
"sigs.k8s.io/controller-runtime/pkg/controller"
4544
"sigs.k8s.io/controller-runtime/pkg/handler"
4645
"sigs.k8s.io/controller-runtime/pkg/source"
46+
47+
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
48+
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/internal/userdata"
49+
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1"
4750
)
4851

4952
// EKSConfigReconciler reconciles a EKSConfig object.
@@ -186,12 +189,26 @@ func (r *EKSConfigReconciler) joinWorker(ctx context.Context, cluster *clusterv1
186189
log.Info("Generating userdata")
187190

188191
// generate userdata
189-
userDataScript, err := userdata.NewNode(&userdata.NodeInput{
192+
nodeInput := &userdata.NodeInput{
190193
// AWSManagedControlPlane webhooks default and validate EKSClusterName
191-
ClusterName: controlPlane.Spec.EKSClusterName,
192-
194+
ClusterName: controlPlane.Spec.EKSClusterName,
193195
KubeletExtraArgs: config.Spec.KubeletExtraArgs,
194-
})
196+
ContainerRuntime: config.Spec.ContainerRuntime,
197+
DNSClusterIP: config.Spec.DNSClusterIP,
198+
DockerConfigJson: config.Spec.DockerConfigJson,
199+
APIRetryAttempts: config.Spec.APIRetryAttempts,
200+
UseMaxPods: config.Spec.UseMaxPods,
201+
}
202+
if config.Spec.ServiceIPV6Cidr != nil && *config.Spec.ServiceIPV6Cidr != "" {
203+
nodeInput.ServiceIPV6Cidr = config.Spec.ServiceIPV6Cidr
204+
nodeInput.IPFamily = pointer.String("ipv6")
205+
}
206+
if config.Spec.PauseContainer != nil {
207+
nodeInput.PauseContainerAccount = &config.Spec.PauseContainer.AccountNumber
208+
nodeInput.PauseConatinerVersion = &config.Spec.PauseContainer.Version
209+
}
210+
211+
userDataScript, err := userdata.NewNode(nodeInput)
195212
if err != nil {
196213
log.Error(err, "Failed to create a worker join configuration")
197214
conditions.MarkFalse(config, eksbootstrapv1.DataSecretAvailableCondition, eksbootstrapv1.DataSecretGenerationFailedReason, clusterv1.ConditionSeverityWarning, "")
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package userdata
18+
19+
/*
20+
echo "--dns-cluster-ip Overrides the IP address to use for DNS queries within the cluster. Defaults to 10.100.0.10 or 172.20.0.10 based on the IP address of the primary interface"
21+
22+
DockerConfigJson *string
23+
*/
24+
25+
const argsTemplate = `{{- define "args" -}}
26+
{{- if .KubeletExtraArgs }} --kubelet-extra-args '{{ template "kubeletArgsTemplate" .KubeletExtraArgs }}'
27+
{{- end -}}
28+
{{- if .ContainerRuntime }} --container-runtime {{.ContainerRuntime}}{{- end -}}
29+
{{- if .IPFamily }} --ip-family {{.IPFamily}}{{- end -}}
30+
{{- if .ServiceIPV6Cidr }} --service-ipv6-cidr {{.ServiceIPV6Cidr}}{{- end -}}
31+
{{- if .UseMaxPods }} --use-max-pods {{.UseMaxPods}}{{- end -}}
32+
{{- if .APIRetryAttempts }} --aws-api-retry-attempts {{.APIRetryAttempts}}{{- end -}}
33+
{{- if .PauseContainerAccount }} --pause-container-account {{.PauseContainerAccount}}{{- end -}}
34+
{{- if .PauseConatinerVersion }} --pause-container-version {{.PauseConatinerVersion}}{{- end -}}
35+
{{- if .DNSClusterIP }} --dns-cluster-ip {{.DNSClusterIP}}{{- end -}}
36+
{{- if .DockerConfigJson }} --docker-config-json {{.DockerConfigJson}}{{- end -}}
37+
{{- end -}}`
38+
39+
const kubeletArgsTemplate = `{{- define "kubeletArgsTemplate" -}}
40+
{{- $first := true -}}
41+
{{- range $k, $v := . -}}
42+
{{- if $first -}}{{ $first = false -}}{{- else }} {{ end -}}
43+
--{{$k}}={{$v}}
44+
{{- end -}}
45+
{{- end -}}
46+
`

bootstrap/eks/internal/userdata/kubelet_args.go

-31
This file was deleted.

bootstrap/eks/internal/userdata/node.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ import (
2424

2525
const (
2626
nodeUserData = `#!/bin/bash
27-
/etc/eks/bootstrap.sh {{.ClusterName}} {{- template "args" .KubeletExtraArgs }}
27+
/etc/eks/bootstrap.sh {{.ClusterName}} {{- template "args" . }}
2828
`
2929
)
3030

3131
// NodeInput defines the context to generate a node user data.
3232
type NodeInput struct {
33-
ClusterName string
34-
KubeletExtraArgs map[string]string
33+
ClusterName string
34+
KubeletExtraArgs map[string]string
35+
ContainerRuntime *string
36+
DNSClusterIP *string
37+
DockerConfigJson *string
38+
APIRetryAttempts *int
39+
PauseContainerAccount *string
40+
PauseConatinerVersion *string
41+
UseMaxPods *bool
42+
IPFamily *string
43+
ServiceIPV6Cidr *string
3544
}
3645

3746
// NewNode returns the user data string to be used on a node instance.

0 commit comments

Comments
 (0)