@@ -20,7 +20,7 @@ import (
2020
2121var (
2222 k3sImage = "rancher/k3s"
23- k3sVersion = "v1.18.20 -k3s1"
23+ k3sVersion = "v1.21.14 -k3s1"
2424)
2525
2626// DockerImage holds the configuration of a Docker image.
@@ -41,19 +41,19 @@ type ClusterOptionFunc func(opts *ClusterOptions)
4141// WithoutTraefik tells k3d to not start a k3s cluster with Traefik already installed in.
4242func WithoutTraefik () func (opts * ClusterOptions ) {
4343 return func (opts * ClusterOptions ) {
44- opts .Cmd = append (opts .Cmd , "--k3s-server- arg" , "--no-deploy =traefik" )
44+ opts .Cmd = append (opts .Cmd , "--k3s-arg" , "--disable =traefik@server:0 " )
4545 }
4646}
4747
4848// WithoutCoreDNS tells k3d to not start a k3s cluster with CoreDNS already installed in.
4949func WithoutCoreDNS () func (opts * ClusterOptions ) {
5050 return func (opts * ClusterOptions ) {
51- opts .Cmd = append (opts .Cmd , "--k3s-server- arg" , "--no-deploy =coredns" )
51+ opts .Cmd = append (opts .Cmd , "--k3s-arg" , "--disable =coredns@server:0 " )
5252 }
5353}
5454
55- // WithImages tells k3d to import the given image. Images which are tagged a local won't be pull locally before being
56- // imported.
55+ // WithImages tells k3d to import the given image.
56+ // Images which are tagged a local won't be pull locally before being imported.
5757func WithImages (images ... DockerImage ) func (opts * ClusterOptions ) {
5858 return func (opts * ClusterOptions ) {
5959 opts .Images = append (opts .Images , images ... )
@@ -70,11 +70,7 @@ type Cluster struct {
7070
7171// NewCluster creates a new k3s cluster using the given configuration.
7272func NewCluster (logger logrus.FieldLogger , masterURL string , name string , opts ... ClusterOptionFunc ) (* Cluster , error ) {
73- clusterOpts := ClusterOptions {
74- Images : []DockerImage {
75- {Name : "rancher/coredns-coredns:1.6.3" },
76- },
77- }
73+ var clusterOpts ClusterOptions
7874
7975 for _ , opt := range opts {
8076 opt (& clusterOpts )
@@ -330,10 +326,12 @@ func pullDockerImages(logger logrus.FieldLogger, images []DockerImage) error {
330326}
331327
332328func importDockerImages (logger logrus.FieldLogger , clusterName string , images []DockerImage ) error {
333- args := [] string {
334- "image" , "import" , "--cluster" , clusterName ,
329+ if len ( images ) == 0 {
330+ return nil
335331 }
336332
333+ args := []string {"image" , "import" , "--cluster" , clusterName }
334+
337335 for _ , image := range images {
338336 args = append (args , image .Name )
339337 }
0 commit comments