Skip to content

Commit

Permalink
Merge pull request #8402 from rdrgmnzs/etcd-setting-overwrite
Browse files Browse the repository at this point in the history
Allow users to overwrite etcd settings.
  • Loading branch information
k8s-ci-robot authored Mar 15, 2020
2 parents 11cfc42 + 7e16cad commit e7846fd
Show file tree
Hide file tree
Showing 13 changed files with 414 additions and 3 deletions.
30 changes: 30 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,36 @@ spec:
manager:
description: Manager describes the manager configuration
properties:
env:
description: Env allows users to pass in env variables to
the etcd-manager container. Variables starting with ETCD_
will be further passed down to the etcd process. This allows
etcd setting to be configured/overwriten. No config validation
is done. A list of etcd config ENV vars can be found at
https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
items:
description: EnvVar represents an environment variable present
in a Container.
properties:
name:
description: Name of the environment variable. Must
be a C_IDENTIFIER.
type: string
value:
description: 'Variable references $(VAR_NAME) are expanded
using the previous defined environment variables in
the container and any service environment variables.
If a variable cannot be resolved, the reference in
the input string will be unchanged. The $(VAR_NAME)
syntax can be escaped with a double $$, ie: $$(VAR_NAME).
Escaped references will never be expanded, regardless
of whether the variable exists or not. Defaults to
"".'
type: string
required:
- name
type: object
type: array
image:
description: Image is the etcd manager image to use.
type: string
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// Env allows users to pass in env variables to the etcd-manager container.
// Variables starting with ETCD_ will be further passed down to the etcd process.
// This allows etcd setting to be overwriten. No config validation is done.
// A list of etcd config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
Env []EnvVar `json:"env,omitempty"`
}

// EtcdMemberSpec is a specification for a etcd member
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// Env allows users to pass in env variables to the etcd-manager container.
// Variables starting with ETCD_ will be further passed down to the etcd process.
// This allows etcd setting to be configured/overwriten. No config validation is done.
// A list of etcd config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
Env []EnvVar `json:"env,omitempty"`
}

// EtcdMemberSpec is a specification for a etcd member
Expand Down
22 changes: 22 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.conversion.go

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

7 changes: 6 additions & 1 deletion pkg/apis/kops/v1alpha1/zz_generated.deepcopy.go

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 @@ -459,6 +459,11 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// Env allows users to pass in env variables to the etcd-manager container.
// Variables starting with ETCD_ will be further passed down to the etcd process.
// This allows etcd setting to be configured/overwriten. No config validation is done.
// A list of etcd config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
Env []EnvVar `json:"env,omitempty"`
}

// EtcdMemberSpec is a specification for a etcd member
Expand Down
22 changes: 22 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.

7 changes: 6 additions & 1 deletion 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.

7 changes: 6 additions & 1 deletion pkg/apis/kops/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/model/components/etcdmanager/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po
klog.Warningf("overloading image in manifest %s with images %s", bundle, etcdCluster.Manager.Image)
container.Image = etcdCluster.Manager.Image
}

}

// With etcd-manager the hosts changes are self-contained, so
Expand Down Expand Up @@ -488,6 +489,18 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po

container.Env = envMap.ToEnvVars()

if etcdCluster.Manager != nil && len(etcdCluster.Manager.Env) > 0 {
for _, envVar := range etcdCluster.Manager.Env {
klog.Warningf("overloading ENV var in manifest %s with %s=%s", bundle, envVar.Name, envVar.Value)
configOverwrite := v1.EnvVar{
Name: envVar.Name,
Value: envVar.Value,
}

container.Env = append(container.Env, configOverwrite)
}
}

{
foundPKI := false
for i := range pod.Spec.Volumes {
Expand Down
1 change: 1 addition & 0 deletions pkg/model/components/etcdmanager/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func Test_RunEtcdManagerBuilder(t *testing.T) {
"tests/minimal",
"tests/proxy",
"tests/old_versions_mount_hosts",
"tests/overwrite_settings",
}
for _, basedir := range tests {
basedir := basedir
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
name: us-test-1a
manager:
env:
- name: ETCD_QUOTA_BACKEND_BYTES
value: "10737418240"
memoryRequest: 100Mi
name: main
provider: Manager
backups:
backupStore: memfs://clusters.example.com/minimal.example.com/backups/etcd-main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
name: us-test-1a
manager:
env:
- name: ETCD_QUOTA_BACKEND_BYTES
value: "10737418240"
memoryRequest: 100Mi
name: events
provider: Manager
backups:
backupStore: memfs://clusters.example.com/minimal.example.com/backups/etcd-events
kubernetesVersion: v1.17.0
masterInternalName: api.internal.minimal.example.com
masterPublicName: api.minimal.example.com
networkCIDR: 172.20.0.0/16
networking:
kubenet: {}
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

---

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
creationTimestamp: "2016-12-10T22:42:28Z"
name: nodes
labels:
kops.k8s.io/cluster: minimal.example.com
spec:
associatePublicIp: true
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2016-10-21
machineType: t2.medium
maxSize: 2
minSize: 2
role: Node
subnets:
- us-test-1a

---

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
creationTimestamp: "2016-12-10T22:42:28Z"
name: master-us-test-1a
labels:
kops.k8s.io/cluster: minimal.example.com
spec:
associatePublicIp: true
image: kope.io/k8s-1.4-debian-jessie-amd64-hvm-ebs-2016-10-21
machineType: m3.medium
maxSize: 1
minSize: 1
role: Master
subnets:
- us-test-1a
Loading

0 comments on commit e7846fd

Please sign in to comment.