Skip to content

Commit 1ec4e03

Browse files
geraldcroestraefiker
authored andcommitted
Remove etcd v2
1 parent 9cd47dd commit 1ec4e03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+49
-60679
lines changed

Gopkg.lock

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

docs/configuration/backends/etcd.md

-14
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ watch = true
3131
#
3232
prefix = "/traefik"
3333

34-
# Force to use API V3 (otherwise still use API V2)
35-
#
36-
# Deprecated
37-
#
38-
# Optional
39-
# Default: false
40-
#
41-
useAPIV3 = true
42-
43-
4434
# Override default configuration template.
4535
# For advanced users :)
4636
#
@@ -69,7 +59,3 @@ useAPIV3 = true
6959
To enable constraints see [provider-specific constraints section](/configuration/commons/#provider-specific).
7060

7161
Please refer to the [Key Value storage structure](/user-guide/kv-config/#key-value-storage-structure) section to get documentation on Traefik KV structure.
72-
73-
!!! note
74-
The option `useAPIV3` allows using Etcd API V3 only if it's set to true.
75-
This option is **deprecated** and API V2 won't be supported in the future.

docs/user-guide/kv-config.md

-4
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ As a result, it may be possible for Træfik to read an intermediate configuratio
370370
To solve this problem, Træfik supports a special key called `/traefik/alias`.
371371
If set, Træfik use the value as an alternative key prefix.
372372

373-
!!! note
374-
The field `useAPIV3` allows using Etcd V3 API which should support updating multiple keys atomically with Etcd.
375-
Etcd API V2 is deprecated and, in the future, Træfik will support API V3 by default.
376-
377373
Given the key structure below, Træfik will use the `http://172.17.0.2:80` as its only backend (frontend keys have been omitted for brevity).
378374

379375
| Key | Value |

examples/cluster/manage_cluster_docker_environment.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ start_storeconfig_etcd3() {
8888
[etcd]
8989
endpoint = "10.0.1.12:2379"
9090
watch = true
91-
prefix = "/traefik"
92-
useAPIV3 = true' >> $basedir/traefik.toml
91+
prefix = "/traefik"' >> $basedir/traefik.toml
9392
up_environment storeconfig
9493
rm -f $basedir/traefik.toml
9594
waiting_counter=5
@@ -178,7 +177,7 @@ main() {
178177
case $2 in
179178
"--etcd3")
180179
echo "USE ETCD V3 AS KV STORE"
181-
export TRAEFIK_CMD="--etcd --etcd.endpoint=10.0.1.12:2379 --etcd.useAPIV3=true"
180+
export TRAEFIK_CMD="--etcd --etcd.endpoint=10.0.1.12:2379"
182181
start_boulder && \
183182
start_etcd3 && \
184183
start_storeconfig_etcd3 && \

integration/etcd3_test.go

+42-26
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,54 @@ import (
1313
"github.com/abronan/valkeyrie/store/etcd/v3"
1414
"github.com/containous/traefik/integration/try"
1515
"github.com/go-check/check"
16-
1716
checker "github.com/vdemeester/shakers"
1817
)
1918

2019
const (
21-
// Services IP addresses fixed in the configuration
22-
ipEtcd = "172.18.0.2"
23-
ipWhoami01 = "172.18.0.3"
24-
ipWhoami02 = "172.18.0.4"
25-
ipWhoami03 = "172.18.0.5"
26-
ipWhoami04 = "172.18.0.6"
27-
2820
traefikEtcdURL = "http://127.0.0.1:8000/"
2921
traefikWebEtcdURL = "http://127.0.0.1:8081/"
3022
)
3123

24+
var (
25+
ipEtcd string
26+
ipWhoami01 string
27+
ipWhoami02 string
28+
ipWhoami03 string
29+
ipWhoami04 string
30+
)
31+
3232
// Etcd test suites (using libcompose)
3333
type Etcd3Suite struct {
3434
BaseSuite
3535
kv store.Store
3636
}
3737

38-
func (s *Etcd3Suite) SetUpTest(c *check.C) {
38+
func (s *Etcd3Suite) getIPAddress(c *check.C, service, defaultIP string) string {
39+
var ip string
40+
for _, value := range s.composeProject.Container(c, service).NetworkSettings.Networks {
41+
if len(value.IPAddress) > 0 {
42+
ip = value.IPAddress
43+
break
44+
}
45+
}
46+
47+
if len(ip) == 0 {
48+
return defaultIP
49+
}
50+
51+
return ip
52+
}
53+
54+
func (s *Etcd3Suite) SetUpSuite(c *check.C) {
3955
s.createComposeProject(c, "etcd3")
4056
s.composeProject.Start(c)
4157

58+
ipEtcd = s.getIPAddress(c, "etcd", "172.18.0.2")
59+
ipWhoami01 = s.getIPAddress(c, "whoami1", "172.18.0.3")
60+
ipWhoami02 = s.getIPAddress(c, "whoami2", "172.18.0.4")
61+
ipWhoami03 = s.getIPAddress(c, "whoami3", "172.18.0.5")
62+
ipWhoami04 = s.getIPAddress(c, "whoami4", "172.18.0.6")
63+
4264
etcdv3.Register()
4365
url := ipEtcd + ":2379"
4466
kv, err := valkeyrie.NewStore(
@@ -49,7 +71,7 @@ func (s *Etcd3Suite) SetUpTest(c *check.C) {
4971
},
5072
)
5173
if err != nil {
52-
c.Fatal("Cannot create store etcd")
74+
c.Fatalf("Cannot create store etcd %v", err)
5375
}
5476
s.kv = kv
5577

@@ -62,21 +84,22 @@ func (s *Etcd3Suite) SetUpTest(c *check.C) {
6284
}
6385

6486
func (s *Etcd3Suite) TearDownTest(c *check.C) {
87+
// Delete all Traefik keys from ETCD
88+
s.kv.DeleteTree("/traefik")
89+
}
90+
91+
func (s *Etcd3Suite) TearDownSuite(c *check.C) {
6592
// shutdown and delete compose project
6693
if s.composeProject != nil {
6794
s.composeProject.Stop(c)
6895
}
6996
}
7097

71-
func (s *Etcd3Suite) TearDownSuite(c *check.C) {}
72-
7398
func (s *Etcd3Suite) TestSimpleConfiguration(c *check.C) {
7499
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct {
75100
EtcdHost string
76-
UseAPIV3 bool
77101
}{
78102
ipEtcd,
79-
true,
80103
})
81104
defer os.Remove(file)
82105

@@ -95,10 +118,8 @@ func (s *Etcd3Suite) TestSimpleConfiguration(c *check.C) {
95118
func (s *Etcd3Suite) TestNominalConfiguration(c *check.C) {
96119
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct {
97120
EtcdHost string
98-
UseAPIV3 bool
99121
}{
100122
ipEtcd,
101-
true,
102123
})
103124
defer os.Remove(file)
104125

@@ -219,8 +240,7 @@ func (s *Etcd3Suite) TestGlobalConfiguration(c *check.C) {
219240
cmd, display := s.traefikCmd(
220241
withConfigFile("fixtures/simple_web.toml"),
221242
"--etcd",
222-
"--etcd.endpoint="+ipEtcd+":4001",
223-
"--etcd.useAPIV3=true")
243+
"--etcd.endpoint="+ipEtcd+":4001")
224244
defer display(c)
225245
err = cmd.Start()
226246
c.Assert(err, checker.IsNil)
@@ -294,8 +314,7 @@ func (s *Etcd3Suite) TestCertificatesContentWithSNIConfigHandshake(c *check.C) {
294314
cmd, display := s.traefikCmd(
295315
withConfigFile("fixtures/simple_web.toml"),
296316
"--etcd",
297-
"--etcd.endpoint="+ipEtcd+":4001",
298-
"--etcd.useAPIV3=true")
317+
"--etcd.endpoint="+ipEtcd+":4001")
299318
defer display(c)
300319

301320
// Copy the contents of the certificate files into ETCD
@@ -397,8 +416,7 @@ func (s *Etcd3Suite) TestCommandStoreConfig(c *check.C) {
397416
cmd, display := s.traefikCmd(
398417
"storeconfig",
399418
withConfigFile("fixtures/simple_web.toml"),
400-
"--etcd.endpoint="+ipEtcd+":4001",
401-
"--etcd.useAPIV3=true")
419+
"--etcd.endpoint="+ipEtcd+":4001")
402420
defer display(c)
403421
err := cmd.Start()
404422
c.Assert(err, checker.IsNil)
@@ -433,8 +451,7 @@ func (s *Etcd3Suite) TestSNIDynamicTlsConfig(c *check.C) {
433451
cmd, display := s.traefikCmd(
434452
withConfigFile("fixtures/etcd/simple_https.toml"),
435453
"--etcd",
436-
"--etcd.endpoint="+ipEtcd+":4001",
437-
"--etcd.useAPIV3=true")
454+
"--etcd.endpoint="+ipEtcd+":4001")
438455
defer display(c)
439456

440457
snitestComCert, err := ioutil.ReadFile("fixtures/https/snitest.com.cert")
@@ -571,8 +588,7 @@ func (s *Etcd3Suite) TestDeleteSNIDynamicTlsConfig(c *check.C) {
571588
cmd, display := s.traefikCmd(
572589
withConfigFile("fixtures/etcd/simple_https.toml"),
573590
"--etcd",
574-
"--etcd.endpoint="+ipEtcd+":4001",
575-
"--etcd.useAPIV3=true")
591+
"--etcd.endpoint="+ipEtcd+":4001")
576592
defer display(c)
577593

578594
// prepare to config

0 commit comments

Comments
 (0)