diff --git a/docs/content/user-guides/crd-acme/index.md b/docs/content/user-guides/crd-acme/index.md index 5a02451dd..f6e4d9263 100644 --- a/docs/content/user-guides/crd-acme/index.md +++ b/docs/content/user-guides/crd-acme/index.md @@ -18,7 +18,7 @@ In the following, the Kubernetes resources defined in YAML configuration files c !!! important "Kubectl Version" - With the `rancher/k3s` version used in this guide (`0.5.0`), the kubectl version needs to be >= `0.11`. + With the `rancher/k3s` version used in this guide (`0.8.0`), the kubectl version needs to be >= `0.11`. ## k3s Docker-compose Configuration diff --git a/docs/content/user-guides/crd-acme/k3s.yml b/docs/content/user-guides/crd-acme/k3s.yml index 6e9042646..a424d9f56 100644 --- a/docs/content/user-guides/crd-acme/k3s.yml +++ b/docs/content/user-guides/crd-acme/k3s.yml @@ -1,5 +1,5 @@ server: - image: rancher/k3s:v0.5.0 + image: rancher/k3s:v0.8.0 command: server --disable-agent --no-deploy traefik environment: - K3S_CLUSTER_SECRET=somethingtotallyrandom @@ -17,7 +17,7 @@ server: - 6443:6443 node: - image: rancher/k3s:v0.5.0 + image: rancher/k3s:v0.8.0 privileged: true links: - server diff --git a/integration/fixtures/k8s/05-ingressroutetcp.yml b/integration/fixtures/k8s/05-ingressroutetcp.yml index f7b1896a8..8c9fbf7d1 100644 --- a/integration/fixtures/k8s/05-ingressroutetcp.yml +++ b/integration/fixtures/k8s/05-ingressroutetcp.yml @@ -1,7 +1,7 @@ apiVersion: traefik.containo.us/v1alpha1 kind: IngressRouteTCP metadata: - name: test3.crd + name: test3.route namespace: default spec: diff --git a/integration/fixtures/k8s/config.skip/.gitkeep b/integration/fixtures/k8s/config.skip/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/integration/integration_test.go b/integration/integration_test.go index 599b2e8c5..2ec9a448e 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -119,17 +119,32 @@ func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) { cmd, out := s.cmdTraefik(args...) return cmd, func(c *check.C) { if c.Failed() || *showLog { + s.displayLogK3S(c) s.displayTraefikLog(c, out) } } } +func (s *BaseSuite) displayLogK3S(c *check.C) { + filePath := "./fixtures/k8s/config.skip/k3s.log" + if _, err := os.Stat(filePath); err == nil { + content, errR := ioutil.ReadFile(filePath) + if errR != nil { + log.WithoutContext().Error(errR) + } + log.WithoutContext().Println(string(content)) + } + log.WithoutContext().Println() + log.WithoutContext().Println("################################") + log.WithoutContext().Println() +} + func (s *BaseSuite) displayTraefikLog(c *check.C, output *bytes.Buffer) { if output == nil || output.Len() == 0 { - log.Infof("%s: No Traefik logs.", c.TestName()) + log.WithoutContext().Infof("%s: No Traefik logs.", c.TestName()) } else { - log.Infof("%s: Traefik logs: ", c.TestName()) - log.Infof(output.String()) + log.WithoutContext().Infof("%s: Traefik logs: ", c.TestName()) + log.WithoutContext().Infof(output.String()) } } diff --git a/integration/k8s_test.go b/integration/k8s_test.go index 457d639e8..4a5deddeb 100644 --- a/integration/k8s_test.go +++ b/integration/k8s_test.go @@ -16,6 +16,7 @@ import ( "github.com/containous/traefik/v2/integration/try" "github.com/containous/traefik/v2/pkg/api" + "github.com/containous/traefik/v2/pkg/log" "github.com/go-check/check" "github.com/pmezard/go-difflib/difflib" checker "github.com/vdemeester/shakers" @@ -30,7 +31,7 @@ func (s *K8sSuite) SetUpSuite(c *check.C) { s.createComposeProject(c, "k8s") s.composeProject.Start(c) - abs, err := filepath.Abs("./fixtures/k8s/kubeconfig.yaml") + abs, err := filepath.Abs("./fixtures/k8s/config.skip/kubeconfig.yaml") c.Assert(err, checker.IsNil) err = try.Do(60*time.Second, try.DoCondition(func() error { @@ -46,17 +47,19 @@ func (s *K8sSuite) SetUpSuite(c *check.C) { func (s *K8sSuite) TearDownSuite(c *check.C) { s.composeProject.Stop(c) - err := os.Remove("./fixtures/k8s/kubeconfig.yaml") - if err != nil { - c.Log(err) + generatedFiles := []string{ + "./fixtures/k8s/config.skip/kubeconfig.yaml", + "./fixtures/k8s/config.skip/k3s.log", + "./fixtures/k8s/coredns.yaml", + "./fixtures/k8s/rolebindings.yaml", + "./fixtures/k8s/traefik.yaml", } - err = os.Remove("./fixtures/k8s/coredns.yaml") - if err != nil { - c.Log(err) - } - err = os.Remove("./fixtures/k8s/traefik.yaml") - if err != nil { - c.Log(err) + + for _, filename := range generatedFiles { + err := os.Remove(filename) + if err != nil { + log.WithoutContext().Warning(err) + } } } @@ -83,6 +86,9 @@ func (s *K8sSuite) TestCRDConfiguration(c *check.C) { } func testConfiguration(c *check.C, path string) { + err := try.GetRequest("http://127.0.0.1:8080/api/entrypoints", 20*time.Second, try.BodyContains(`"name":"web"`)) + c.Assert(err, checker.IsNil) + expectedJSON := filepath.FromSlash(path) if *updateExpected { @@ -93,7 +99,7 @@ func testConfiguration(c *check.C, path string) { } var buf bytes.Buffer - err := try.GetRequest("http://127.0.0.1:8080/api/rawdata", 20*time.Second, try.StatusCodeIs(http.StatusOK), matchesConfig(expectedJSON, &buf)) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 40*time.Second, try.StatusCodeIs(http.StatusOK), matchesConfig(expectedJSON, &buf)) if !*updateExpected { if err != nil { diff --git a/integration/resources/compose/k8s.yml b/integration/resources/compose/k8s.yml index d457fc333..29e14104b 100644 --- a/integration/resources/compose/k8s.yml +++ b/integration/resources/compose/k8s.yml @@ -1,18 +1,18 @@ server: - image: rancher/k3s:v0.5.0 - command: server --disable-agent --no-deploy traefik + image: rancher/k3s:v0.8.0 + command: server --disable-agent --no-deploy traefik --log /output/k3s.log environment: - K3S_CLUSTER_SECRET=somethingtotallyrandom - K3S_KUBECONFIG_OUTPUT=/output/kubeconfig.yaml - K3S_KUBECONFIG_MODE=666 volumes: - - ../../fixtures/k8s:/output + - ../../fixtures/k8s/config.skip:/output - ../../fixtures/k8s:/var/lib/rancher/k3s/server/manifests ports: - 6443:6443 node: - image: rancher/k3s:v0.5.0 + image: rancher/k3s:v0.8.0 privileged: true links: - server diff --git a/integration/tcp_test.go b/integration/tcp_test.go index 5551911a9..c1fc0d57c 100644 --- a/integration/tcp_test.go +++ b/integration/tcp_test.go @@ -31,7 +31,7 @@ func (s *TCPSuite) TestMixed(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("Path(`/test`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("Path(`/test`)")) c.Assert(err, checker.IsNil) // Traefik passes through, termination handled by whoami-a @@ -81,7 +81,7 @@ func (s *TCPSuite) TestTLSOptions(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`whoami-c.test`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`whoami-c.test`)")) c.Assert(err, checker.IsNil) // Check that we can use a client tls version <= 1.1 with hostSNI 'whoami-c.test' @@ -111,7 +111,7 @@ func (s *TCPSuite) TestNonTLSFallback(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) c.Assert(err, checker.IsNil) // Traefik passes through, termination handled by whoami-a @@ -145,7 +145,7 @@ func (s *TCPSuite) TestNonTlsTcp(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) c.Assert(err, checker.IsNil) // Traefik will forward every requests on the given port to whoami-no-tls @@ -165,7 +165,7 @@ func (s *TCPSuite) TestCatchAllNoTLS(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) c.Assert(err, checker.IsNil) // Traefik will forward every requests on the given port to whoami-no-tls @@ -185,7 +185,7 @@ func (s *TCPSuite) TestCatchAllNoTLSWithHTTPS(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 500*time.Millisecond, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) + err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 5*time.Second, try.StatusCodeIs(http.StatusOK), try.BodyContains("HostSNI(`*`)")) c.Assert(err, checker.IsNil) req := httptest.NewRequest(http.MethodGet, "https://127.0.0.1:8093/test", nil) diff --git a/integration/testdata/rawdata-crd.json b/integration/testdata/rawdata-crd.json index 8600da5de..c26803e36 100644 --- a/integration/testdata/rawdata-crd.json +++ b/integration/testdata/rawdata-crd.json @@ -82,11 +82,11 @@ } }, "tcpRouters": { - "default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": { + "default/test3.route-673acf455cb2dab0b43a@kubernetescrd": { "entryPoints": [ "footcp" ], - "service": "default/test3.crd-673acf455cb2dab0b43a", + "service": "default/test3.route-673acf455cb2dab0b43a", "rule": "HostSNI(`*`)", "tls": { "passthrough": false, @@ -96,7 +96,7 @@ } }, "tcpServices": { - "default/test3.crd-673acf455cb2dab0b43a@kubernetescrd": { + "default/test3.route-673acf455cb2dab0b43a@kubernetescrd": { "loadBalancer": { "servers": [ { @@ -109,7 +109,7 @@ }, "status": "enabled", "usedBy": [ - "default/test3.crd-673acf455cb2dab0b43a@kubernetescrd" + "default/test3.route-673acf455cb2dab0b43a@kubernetescrd" ] } }