Skip to content

Commit

Permalink
Update k3d to v5.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpollet authored Aug 19, 2022
1 parent 321dabb commit 2e3182b
Show file tree
Hide file tree
Showing 24 changed files with 687 additions and 152 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ tidy:
go mod tidy

k3d:
@command -v k3d >/dev/null 2>&1 || curl -s https://raw.githubusercontent.com/rancher/k3d/v3.4.0/install.sh | TAG=v3.4.0 bash
@command -v k3d >/dev/null 2>&1 || curl -s https://raw.githubusercontent.com/rancher/k3d/v5.4.4/install.sh | TAG=v5.4.4 bash

docs-package:
mkdir -p $(CURDIR)/pages
Expand Down
29 changes: 16 additions & 13 deletions integration/acl_disabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ type ACLDisabledSuite struct {
func (s *ACLDisabledSuite) SetUpSuite(c *check.C) {
var err error

requiredImages := []k3d.DockerImage{
{Name: "traefik/mesh:latest", Local: true},
{Name: "traefik:v2.8"},
{Name: "traefik/whoami:v1.6.0"},
{Name: "traefik/whoamitcp:v0.1.0"},
{Name: "traefik/whoamiudp:v0.1.0"},
{Name: "giantswarm/tiny-tools:3.9"},
}

s.logger = logrus.New()
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName,

opts := []k3d.ClusterOptionFunc{
k3d.WithoutTraefik(),
k3d.WithImages(requiredImages...),
)
k3d.WithImages(k3d.DockerImage{Name: "traefik/mesh:latest", Local: true}),
}
if !*disableImport {
opts = append(opts, k3d.WithImages(
k3d.DockerImage{Name: "traefik:v2.8"},
k3d.DockerImage{Name: "traefik/whoami:v1.8.0"},
k3d.DockerImage{Name: "traefik/whoamitcp:v0.2.1"},
k3d.DockerImage{Name: "traefik/whoamiudp:v0.1.2"},
k3d.DockerImage{Name: "giantswarm/tiny-tools:3.9"},
))
}

s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName, opts...)
c.Assert(err, checker.IsNil)

c.Assert(s.cluster.CreateNamespace(s.logger, traefikMeshNamespace), checker.IsNil)
Expand Down Expand Up @@ -79,7 +82,7 @@ func (s *ACLDisabledSuite) TestTCPService(c *check.C) {

// TestUDPService deploys a UDP service "server" with one Pod called "server" and asserts this service is
// reachable and that a connection has been established with this Pod.
func (s *ACLDisabledSuite) TestUDPervice(c *check.C) {
func (s *ACLDisabledSuite) TestUDPService(c *check.C) {
c.Assert(s.cluster.Apply(s.logger, "testdata/acl_disabled/udp"), checker.IsNil)
defer s.cluster.Delete(s.logger, "testdata/acl_disabled/udp")

Expand Down
23 changes: 13 additions & 10 deletions integration/acl_enabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ type ACLEnabledSuite struct {
func (s *ACLEnabledSuite) SetUpSuite(c *check.C) {
var err error

requiredImages := []k3d.DockerImage{
{Name: "traefik/mesh:latest", Local: true},
{Name: "traefik:v2.8"},
{Name: "traefik/whoami:v1.6.0"},
{Name: "giantswarm/tiny-tools:3.9"},
}

s.logger = logrus.New()
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName,

opts := []k3d.ClusterOptionFunc{
k3d.WithoutTraefik(),
k3d.WithImages(requiredImages...),
)
k3d.WithImages(k3d.DockerImage{Name: "traefik/mesh:latest", Local: true}),
}
if !*disableImport {
opts = append(opts, k3d.WithImages(
k3d.DockerImage{Name: "traefik:v2.8"},
k3d.DockerImage{Name: "traefik/whoami:v1.8.0"},
k3d.DockerImage{Name: "giantswarm/tiny-tools:3.9"},
))
}

s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName, opts...)
c.Assert(err, checker.IsNil)

c.Assert(s.cluster.CreateNamespace(s.logger, traefikMeshNamespace), checker.IsNil)
Expand Down
31 changes: 16 additions & 15 deletions integration/coredns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ type CoreDNSSuite struct {
func (s *CoreDNSSuite) SetUpSuite(c *check.C) {
var err error

requiredImages := []k3d.DockerImage{
{Name: "traefik/whoami:v1.6.0"},
{Name: "coredns/coredns:1.3.1"},
{Name: "coredns/coredns:1.4.0"},
{Name: "coredns/coredns:1.5.2"},
{Name: "coredns/coredns:1.6.3"},
{Name: "coredns/coredns:1.7.0"},
{Name: "coredns/coredns:1.8.0"},
{Name: "coredns/coredns:1.9.0"},
{Name: "giantswarm/tiny-tools:3.9"},
s.logger = logrus.New()

opts := []k3d.ClusterOptionFunc{k3d.WithoutTraefik()}
if !*disableImport {
opts = append(opts, k3d.WithImages(
k3d.DockerImage{Name: "traefik/whoami:v1.8.0"},
k3d.DockerImage{Name: "coredns/coredns:1.3.1"},
k3d.DockerImage{Name: "coredns/coredns:1.4.0"},
k3d.DockerImage{Name: "coredns/coredns:1.5.2"},
k3d.DockerImage{Name: "coredns/coredns:1.6.3"},
k3d.DockerImage{Name: "coredns/coredns:1.7.0"},
k3d.DockerImage{Name: "coredns/coredns:1.8.0"},
k3d.DockerImage{Name: "coredns/coredns:1.9.0"},
k3d.DockerImage{Name: "giantswarm/tiny-tools:3.9"},
))
}

s.logger = logrus.New()
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName,
k3d.WithoutTraefik(),
k3d.WithImages(requiredImages...),
)
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName, opts...)
c.Assert(err, checker.IsNil)

c.Assert(s.cluster.CreateNamespace(s.logger, traefikMeshNamespace), checker.IsNil)
Expand Down
1 change: 1 addition & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
var (
integration = flag.Bool("integration", false, "run integration tests")
debug = flag.Bool("debug", false, "debug log level")
disableImport = flag.Bool("disable-import", false, "disable images import")
masterURL = "https://localhost:8443"
k3dClusterName = "traefik-mesh-integration"
traefikMeshNamespace = "traefik-mesh"
Expand Down
22 changes: 10 additions & 12 deletions integration/k3d/k3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

var (
k3sImage = "rancher/k3s"
k3sVersion = "v1.18.20-k3s1"
k3sVersion = "v1.21.14-k3s1"
)

// DockerImage holds the configuration of a Docker image.
Expand All @@ -41,19 +41,19 @@ type ClusterOptionFunc func(opts *ClusterOptions)
// WithoutTraefik tells k3d to not start a k3s cluster with Traefik already installed in.
func WithoutTraefik() func(opts *ClusterOptions) {
return func(opts *ClusterOptions) {
opts.Cmd = append(opts.Cmd, "--k3s-server-arg", "--no-deploy=traefik")
opts.Cmd = append(opts.Cmd, "--k3s-arg", "--disable=traefik@server:0")
}
}

// WithoutCoreDNS tells k3d to not start a k3s cluster with CoreDNS already installed in.
func WithoutCoreDNS() func(opts *ClusterOptions) {
return func(opts *ClusterOptions) {
opts.Cmd = append(opts.Cmd, "--k3s-server-arg", "--no-deploy=coredns")
opts.Cmd = append(opts.Cmd, "--k3s-arg", "--disable=coredns@server:0")
}
}

// WithImages tells k3d to import the given image. Images which are tagged a local won't be pull locally before being
// imported.
// WithImages tells k3d to import the given image.
// Images which are tagged a local won't be pull locally before being imported.
func WithImages(images ...DockerImage) func(opts *ClusterOptions) {
return func(opts *ClusterOptions) {
opts.Images = append(opts.Images, images...)
Expand All @@ -70,11 +70,7 @@ type Cluster struct {

// NewCluster creates a new k3s cluster using the given configuration.
func NewCluster(logger logrus.FieldLogger, masterURL string, name string, opts ...ClusterOptionFunc) (*Cluster, error) {
clusterOpts := ClusterOptions{
Images: []DockerImage{
{Name: "rancher/coredns-coredns:1.6.3"},
},
}
var clusterOpts ClusterOptions

for _, opt := range opts {
opt(&clusterOpts)
Expand Down Expand Up @@ -330,10 +326,12 @@ func pullDockerImages(logger logrus.FieldLogger, images []DockerImage) error {
}

func importDockerImages(logger logrus.FieldLogger, clusterName string, images []DockerImage) error {
args := []string{
"image", "import", "--cluster", clusterName,
if len(images) == 0 {
return nil
}

args := []string{"image", "import", "--cluster", clusterName}

for _, image := range images {
args = append(args, image.Name)
}
Expand Down
26 changes: 13 additions & 13 deletions integration/kubedns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ type KubeDNSSuite struct {
func (s *KubeDNSSuite) SetUpSuite(c *check.C) {
var err error

requiredImages := []k3d.DockerImage{
{Name: "traefik/whoami:v1.6.0"},
{Name: "coredns/coredns:1.6.3"},
{Name: "giantswarm/tiny-tools:3.9"},
{Name: "gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7"},
{Name: "gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7"},
{Name: "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7"},
s.logger = logrus.New()

opts := []k3d.ClusterOptionFunc{k3d.WithoutTraefik(), k3d.WithoutCoreDNS()}
if !*disableImport {
opts = append(opts, k3d.WithImages(
k3d.DockerImage{Name: "traefik/whoami:v1.8.0"},
k3d.DockerImage{Name: "coredns/coredns:1.6.3"},
k3d.DockerImage{Name: "giantswarm/tiny-tools:3.9"},
k3d.DockerImage{Name: "gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.15.13"},
k3d.DockerImage{Name: "gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.15.13"},
k3d.DockerImage{Name: "gcr.io/google_containers/k8s-dns-sidecar-amd64:1.15.13"},
))
}

s.logger = logrus.New()
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName,
k3d.WithoutTraefik(),
k3d.WithoutCoreDNS(),
k3d.WithImages(requiredImages...),
)
s.cluster, err = k3d.NewCluster(s.logger, masterURL, k3dClusterName, opts...)
c.Assert(err, checker.IsNil)

c.Assert(s.cluster.CreateNamespace(s.logger, traefikMeshNamespace), checker.IsNil)
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/acl_disabled/http/1.server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
containers:
- name: server-http
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
containers:
- name: server-v1
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
containers:
- name: server-v2
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/acl_disabled/udp/1.server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
spec:
containers:
- name: server-udp
image: traefik/whoamiudp:v0.1.0
image: traefik/whoamiudp:v0.1.2
imagePullPolicy: IfNotPresent
ports:
- name: udp
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/acl_enabled/http/1.server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
serviceAccountName: server
containers:
- name: server-http
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/acl_enabled/http/3.server-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
serviceAccountName: server-api
containers:
- name: server-http-api
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion integration/testdata/acl_enabled/http/4.server-header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
serviceAccountName: server-header
containers:
- name: server-http-header
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
serviceAccountName: server-split
containers:
- name: server-http-split-v1
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down Expand Up @@ -63,7 +63,7 @@ spec:
serviceAccountName: server-split
containers:
- name: server-http-split-v2
image: traefik/whoami:v1.6.0
image: traefik/whoami:v1.8.0
imagePullPolicy: IfNotPresent
readinessProbe:
httpGet:
Expand Down
Loading

0 comments on commit 2e3182b

Please sign in to comment.