Skip to content

Commit

Permalink
Set default containerd runtime to containerd for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Hacman committed May 10, 2020
1 parent 37b4feb commit 217d39a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
5 changes: 3 additions & 2 deletions cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func (o *CreateClusterOptions) InitDefaults() {

o.Authorization = AuthorizationFlagRBAC

o.ContainerRuntime = "docker"
//o.ContainerRuntime = "docker"
o.ContainerRuntime = "containerd"
}

var (
Expand Down Expand Up @@ -869,7 +870,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr

if c.Image != "" {
for _, group := range instanceGroups {
group.Spec.Image = c.Image
group.Spec.Image = "379101102735/debian-stretch-hvm-x86_64-gp2-2020-02-10-73984"
}
}

Expand Down
20 changes: 13 additions & 7 deletions nodeup/pkg/model/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,26 +453,32 @@ func (b *ContainerdBuilder) buildKubenetConflistTemplate(c *fi.ModelBuilderConte
"{",
" \"cniVersion\": \"0.3.1\",",
" \"name\": \"kubenet\",",
" \"plugins\": [{",
" \"plugins\": [",
" {",
" \"type\": \"bridge\",",
" \"bridge\": \"cbr0\",",
" \"mtu\": 1460,",
" \"addIf\": \"eth0\",",
" \"isGateway\": true,",
" \"ipMasq\": false,",
" \"hairpinMode\": false,",
" \"ipMasq\": true,",
" \"hairpinMode\": true,",
" \"promiscMode\": true,",
" \"ipam\": {",
" \"type\": \"host-local\",",
" \"subnet\": \"{{.PodCIDR}}\",",
" \"subnet\": \"" + b.Cluster.Spec.NetworkCIDR + "\",",
" \"routes\": [{ \"dst\": \"0.0.0.0/0\" }]",
" }",
" }]",
" }",
" {",
" \"type\": \"port-mapper\",",
" \"capabilities\": {\"portMappings\": true},",
" }",
" ]",
"}",
}
contents := strings.Join(lines, "\n")

c.AddTask(&nodetasks.File{
Path: "/etc/containerd/kubenet.conflist.template",
Path: "/etc/cni/cni.d/10-kubenet.conf",
Contents: fi.NewStringResource(contents),
Type: nodetasks.FileType_File,
})
Expand Down
19 changes: 1 addition & 18 deletions pkg/model/components/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package components

import (
"fmt"
"strings"

"k8s.io/klog"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
Expand Down Expand Up @@ -63,22 +61,7 @@ func (b *ContainerdOptionsBuilder) BuildOptions(o interface{}) error {

// Apply defaults for containerd running in container runtime mode
containerd.LogLevel = fi.String("info")
if clusterSpec.Networking != nil && clusterSpec.Networking.Kubenet != nil {
// Using containerd with Kubenet requires special configuration. This is a temporary backwards-compatible solution
// and will be deprecated when Kubenet is deprecated:
// https://github.com/containerd/cri/blob/master/docs/config.md#cni-config-template
lines := []string{
"version = 2",
"[plugins]",
" [plugins.\"io.containerd.grpc.v1.cri\"]",
" [plugins.\"io.containerd.grpc.v1.cri\".cni]",
" conf_template = \"/etc/containerd/kubenet.conflist.template\"",
}
contents := strings.Join(lines, "\n")
containerd.ConfigOverride = fi.String(contents)
} else {
containerd.ConfigOverride = fi.String("")
}
containerd.ConfigOverride = fi.String("")

} else if clusterSpec.ContainerRuntime == "docker" {
if fi.StringValue(containerd.Version) == "" {
Expand Down

0 comments on commit 217d39a

Please sign in to comment.