Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

remove auto-adding v to the etcd image version #68

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ metadata:
name: "example-etcd-cluster"
spec:
size: 5
version: "3.2.13"
version: "v3.2.13"
```

Apply the size change to the cluster CR:
Expand Down Expand Up @@ -126,7 +126,7 @@ metadata:
name: "example-etcd-cluster"
spec:
size: 3
version: "3.2.13"
version: "v3.2.13"
```
```
$ kubectl apply -f example/example-etcd-cluster.yaml
Expand Down Expand Up @@ -251,7 +251,7 @@ metadata:
name: "example-etcd-cluster"
spec:
size: 3
version: "3.2.13"
version: "v3.2.13"
```

Apply the version change to the cluster CR:
Expand Down
2 changes: 1 addition & 1 deletion doc/user/abs_backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ spec:
storageType: ABS
status:
etcdRevision: 1
etcdVersion: 3.2.13
etcdVersion: v3.2.13
succeeded: true

```
Expand Down
2 changes: 1 addition & 1 deletion doc/user/gcs_backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ spec:
storageType: GCS
status:
etcdRevision: 1
etcdVersion: 3.2.13
etcdVersion: v3.2.13
succeeded: true

```
Expand Down
2 changes: 1 addition & 1 deletion doc/user/oss_backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
storageType: OSS
status:
etcdRevision: 1
etcdVersion: 3.2.13
etcdVersion: v3.2.13
succeeded: true
```

Expand Down
2 changes: 1 addition & 1 deletion doc/user/spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This will use the default version chosen by the etcd-operator.
```yaml
spec:
size: 3
version: "3.2.13"
version: "v3.2.13"
```

## Three member cluster with node selector and anti-affinity across nodes
Expand Down
2 changes: 1 addition & 1 deletion doc/user/walkthrough/backup-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ kind: EtcdBackup
...
status:
etcdRevision: 1
etcdVersion: 3.2.13
etcdVersion: v3.2.13
succeeded: true
```

Expand Down
2 changes: 1 addition & 1 deletion example/example-etcd-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ metadata:
# etcd.database.coreos.com/scope: clusterwide
spec:
size: 3
version: "3.2.13"
version: "v3.2.13"
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/coreos/etcd-operator
go 1.13

require (
cloud.google.com/go v0.52.0 // indirect
cloud.google.com/go/storage v1.6.0
contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
github.com/Azure/azure-sdk-for-go v11.3.0-beta+incompatible
Expand Down Expand Up @@ -36,7 +35,7 @@ require (
github.com/sirupsen/logrus v1.4.2
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/api v0.20.0
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190226173710-145d52631d00
Expand Down
204 changes: 0 additions & 204 deletions go.sum

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions pkg/apis/etcd/v1beta2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"errors"
"strings"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
defaultRepository = "quay.io/coreos/etcd"
DefaultEtcdVersion = "3.2.13"
DefaultEtcdVersion = "v3.2.13"
)

var (
Expand Down Expand Up @@ -86,7 +86,7 @@ type ClusterSpec struct {
// The version must follow the [semver]( http://semver.org) format, for example "3.2.13".
// Only etcd released versions are supported: https://github.com/coreos/etcd/releases
//
// If version is not set, default is "3.2.13".
// If version is not set, default is "v3.2.13".
Version string `json:"version,omitempty"`

// Paused is to pause the control of the operator for the etcd cluster.
Expand Down Expand Up @@ -167,6 +167,12 @@ type PodPolicy struct {
// The default is to not use memory as the storage medium
// No effect if persistent volume is used
Tmpfs bool `json:"tmpfs,omitempty"`

// hostNetwork will set HostNetwork: true in podspec
HostNetwork bool `json:"hostNetwork,omitempty"`

// dnsPolicy will set dnsPolicy: <whatever> in podspec
DNSPolicy v1.DNSPolicy `json:"dnsPolicy,omitempty"`
}

// TODO: move this to initializer
Expand Down Expand Up @@ -199,7 +205,8 @@ func (e *EtcdCluster) SetDefaults() {
c.Version = DefaultEtcdVersion
}

c.Version = strings.TrimLeft(c.Version, "v")
// not used anymore, we take the full version name as final version (not prepending v to the version)
// c.Version = strings.TrimLeft(c.Version, "v")

// convert PodPolicy.AntiAffinity to Pod.Affinity.PodAntiAffinity
// TODO: Remove this once PodPolicy.AntiAffinity is removed
Expand Down
20 changes: 15 additions & 5 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/pborman/uuid"

appsv1beta1 "k8s.io/api/apps/v1beta1"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -136,7 +136,8 @@ fi
}

func ImageName(repo, version string) string {
return fmt.Sprintf("%s:v%v", repo, version)
// return fmt.Sprintf("%s:v%v", repo, version)
return fmt.Sprintf("%s:%s", repo, version)
}

// imageNameBusybox returns the default image for busybox init container, or the image specified in the PodPolicy
Expand Down Expand Up @@ -253,9 +254,9 @@ func AddEtcdVolumeToPod(pod *v1.Pod, pvc *v1.PersistentVolumeClaim, tmpfs bool)
vol.VolumeSource = v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ClaimName: pvc.Name},
}
// Addresses case C from https://github.com/coreos/etcd-operator/blob/master/doc/design/persistent_volumes_etcd_data.md
// When PVC is used, make the pod auto recover in case of failure
pod.Spec.RestartPolicy = v1.RestartPolicyAlways
// Addresses case C from https://github.com/coreos/etcd-operator/blob/master/doc/design/persistent_volumes_etcd_data.md
// When PVC is used, make the pod auto recover in case of failure
pod.Spec.RestartPolicy = v1.RestartPolicyAlways
} else {
vol.VolumeSource = v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}
if tmpfs {
Expand Down Expand Up @@ -433,6 +434,15 @@ func newEtcdPod(kubecli kubernetes.Interface, m *etcdutil.Member, initialCluster
SecurityContext: podSecurityContext(cs.Pod),
},
}

if cs.Pod.DNSPolicy != "" {
pod.Spec.DNSPolicy = cs.Pod.DNSPolicy
}

if cs.Pod.HostNetwork {
pod.Spec.HostNetwork = true
}

SetEtcdVersion(pod, cs.Version)
return pod, nil
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestEtcdUpgrade(t *testing.T) {
t.Fatalf("failed to create 3 members etcd cluster: %v", err)
}

targetVersion := "3.2.13"
targetVersion := "v3.2.13"
updateFunc := func(cl *api.EtcdCluster) {
cl = e2eutil.ClusterWithVersion(cl, targetVersion)
}
Expand Down