Skip to content

Commit

Permalink
Allow users to overwrite etcd settings.
Browse files Browse the repository at this point in the history
Fix typo

fix env vars config  ordering
  • Loading branch information
rdrgmnzs authored and Rodrigo Menezes committed Jan 27, 2020
1 parent 7022cad commit 07fc09a
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 3 deletions.
7 changes: 7 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,13 @@ spec:
manager:
description: Manager describes the manager configuration
properties:
etcdConfigOverwrite:
additionalProperties:
type: string
description: EtcdConfigOverwrite allows etcd setting to be
overwritten with ENV variables. The setting are not validated.
A list of config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
type: object
image:
description: Image is the etcd manager image to use.
type: string
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// EtcdConfigOverwrite allows etcd setting to be overwritten with ENV variables. The setting are not validated.
// A list of config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
EtcdConfigOverwrite map[string]string `json:"etcdConfigOverwrite,omitempty"`
}

// EtcdMemberSpec is a specification for a etcd member
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/kops/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// EtcdConfigOverwrite allows etcd setting to be overwritten with ENV variables. The setting are not validated.
// A list of config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
EtcdConfigOverwrite map[string]string `json:"etcdConfigOverwrite,omitempty"`
}

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

9 changes: 8 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.

3 changes: 3 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ type EtcdBackupSpec struct {
type EtcdManagerSpec struct {
// Image is the etcd manager image to use.
Image string `json:"image,omitempty"`
// EtcdConfigOverwrite allows etcd setting to be overwritten with ENV variables. The setting are not validated.
// A list of config ENV vars can be found at https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/configuration.md
EtcdConfigOverwrite map[string]string `json:"etcdConfigOverwrite,omitempty"`
}

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

9 changes: 8 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.

9 changes: 8 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 @@ -251,6 +251,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 @@ -477,6 +478,18 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po

container.Env = envMap.ToEnvVars()

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

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

{
foundPKI := false
for i := range pod.Spec.Volumes {
Expand Down

0 comments on commit 07fc09a

Please sign in to comment.