Skip to content

Commit

Permalink
Add containerd config files (#170)
Browse files Browse the repository at this point in the history
* Add containerd config files

* Add containerd.service file

* Bump go version from 1.13 to 1.16

* Ignore G306 for go sec
  • Loading branch information
LinuxSuRen committed Aug 24, 2021
1 parent 90cf193 commit 193bba5
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 30 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build
runs-on: macos-10.15
steps:
- name: Set up Go 1.13
- name: Set up Go 1.16
uses: actions/[email protected]
with:
go-version: 1.13
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/[email protected]
Expand All @@ -29,10 +29,10 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
- name: Set up Go 1.16
uses: actions/[email protected]
with:
go-version: 1.13
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/[email protected]
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: '-exclude=G402,G204,G304,G110 ./...'
args: '-exclude=G402,G204,G304,G110,G306 ./...'
CodeQL:
name: CodeQL
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: 1.13.x
go-version: 1.16.x
- name: Upgrade upx
run: |
# try to fix https://github.com/jenkins-zh/jenkins-cli/issues/493
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module github.com/linuxsuren/ks

go 1.15
go 1.16

require (
github.com/AlecAivazis/survey/v2 v2.2.16
github.com/AlecAivazis/survey/v2 v2.3.1
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/Pallinder/go-randomdata v1.2.0
github.com/huandu/xstrings v1.3.2 // indirect
github.com/linuxsuren/cobra-extension v0.0.10
github.com/linuxsuren/go-cli-alias v0.0.6
github.com/linuxsuren/http-downloader v0.0.32-0.20210822064615-b730515cf035
github.com/linuxsuren/http-downloader v0.0.33
github.com/mitchellh/copystructure v1.1.1 // indirect
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/AlecAivazis/survey/v2 v2.2.2/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk=
github.com/AlecAivazis/survey/v2 v2.2.16 h1:KJ4fLFqY/NfR5OaFLcf4pThxrlV2YCHGCnCHAKLsJ+U=
github.com/AlecAivazis/survey/v2 v2.2.16/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg=
github.com/AlecAivazis/survey/v2 v2.3.1 h1:lzkuHA60pER7L4eYL8qQJor4bUWlJe4V0gqAT19tdOA=
github.com/AlecAivazis/survey/v2 v2.3.1/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest v0.9.6/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630=
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
Expand Down Expand Up @@ -143,7 +143,6 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
Expand Down Expand Up @@ -367,8 +366,8 @@ github.com/linuxsuren/go-cli-alias v0.0.6 h1:PGYf1xqy5GzGINeRhiZR1PTlp09cbyC66MG
github.com/linuxsuren/go-cli-alias v0.0.6/go.mod h1:Sa7xNUI72BgHTcywDU8MXVSH1q72SLdMALZSSANwuUM=
github.com/linuxsuren/http-downloader v0.0.2-0.20201207132639-19888a6beaec/go.mod h1:zRZY9FCDBuYNDxbI2Ny5suasZsMk7J6q9ecQ3V3PIqI=
github.com/linuxsuren/http-downloader v0.0.6/go.mod h1:xxgh2OE7WGL9TwDE9L8Gh7Lqq9fFPuHbh5tofUitEfE=
github.com/linuxsuren/http-downloader v0.0.32-0.20210822064615-b730515cf035 h1:pjzJ/FZtQ+DpW2p8gEX/GnamSELEJlR484C1QkfeXUw=
github.com/linuxsuren/http-downloader v0.0.32-0.20210822064615-b730515cf035/go.mod h1:bGdGvSNCmk7LRuhffIK/ZsAIGpKmrcgJqEjdM8lJzdc=
github.com/linuxsuren/http-downloader v0.0.33 h1:ivAVsVS5zEr8F/oPCrdRdtFP+DLWQjGmVA9AVnUu/vo=
github.com/linuxsuren/http-downloader v0.0.33/go.mod h1:qgMo/GRgQlU6EnIQ+Ul6e0rEJiDFM6+Jcz63ZH2Dhw4=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
Expand Down
11 changes: 11 additions & 0 deletions kubectl-plugin/install/containerd/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# /etc/containerd/config.toml
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "kubesphere/pause:3.2"
[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://registry-1.docker.io"]
[plugins."io.containerd.grpc.v1.cri".cni]
bin_dir = "/opt/cni/bin"
conf_dir = "/etc/cni/net.d"
22 changes: 22 additions & 0 deletions kubectl-plugin/install/containerd/containerd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target

[Service]
ExecStartPre=/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Restart=always
RestartSec=5
Delegate=yes
KillMode=process
OOMScoreAdjust=-999
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity

[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions kubectl-plugin/install/containerd/crictl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# /etc/crictl.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 2
debug: false
pull-image-on-create: false
31 changes: 31 additions & 0 deletions kubectl-plugin/install/containerd/kk_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
name: kk-config-file
spec:
hosts:
- {name: node1, address: {{.address}}, inetnalAddress: {{.address}}}
roleGroups:
etcd:
- node1
master:
- node1
worker:
- node1
controlPlaneEndpoint:
domain: lb.kubesphere.local
address: ""
port: 6443
kubernetes:
version: v1.19.8
imageRepo: kubesphere
clusterName: cluster.local
containerManager: {{.container}}
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
registry:
registryMirrors: []
insecureRegistries: []
addons: []
38 changes: 38 additions & 0 deletions kubectl-plugin/install/containerd/resource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package containerd

import (
// Enable go embed
_ "embed"
)

//go:embed config.toml
var configToml string

// GetConfigToml returns the default containerd config file content
func GetConfigToml() string {
return configToml
}

//go:embed crictl.yaml
var crictl string

// GetCrictl returns the default crictl config file content
func GetCrictl() string {
return crictl
}

//go:embed kk_config.yaml
var kkConfig string

// GetKKConfig returns the default kubekey config file content
func GetKKConfig() string {
return kkConfig
}

//go:embed containerd.service
var containerdService string

// GetContainerdService returns the default containerd.service file content
func GetContainerdService() string {
return containerdService
}
13 changes: 13 additions & 0 deletions kubectl-plugin/install/containerd/resource_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package containerd

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestEmebdContent(t *testing.T) {
assert.NotEmpty(t, GetCrictl(), "crictl config file is empty")
assert.NotEmpty(t, GetConfigToml(), "containerd config file is empty")
assert.NotEmpty(t, GetKKConfig(), "kk config file is empty")
assert.NotEmpty(t, GetContainerdService(), "containerd.service is empty")
}
7 changes: 7 additions & 0 deletions kubectl-plugin/install/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"
"html/template"
"os"
"runtime"
"sync"
)

Expand Down Expand Up @@ -35,6 +36,8 @@ ks install kind --nightly latest --components DevOps`,
flags.BoolVarP(&opt.Reset, "reset", "", false, "")
flags.StringVarP(&opt.Nightly, "nightly", "", "",
"Supported date format is '20200101', or you can use 'latest' which means yesterday")
flags.BoolVarP(&opt.fetch, "fetch", "", true,
"Indicate if fetch the latest config of tools")

_ = cmd.RegisterFlagCompletionFunc("components", common.ArrayCompletion("DevOps"))
return
Expand Down Expand Up @@ -70,6 +73,9 @@ func (o *kindOption) reset(cmd *cobra.Command, args []string) (err error) {
func (o *kindOption) preRunE(_ *cobra.Command, _ []string) (err error) {
is := installer.Installer{
Provider: "github",
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Fetch: o.fetch,
}
err = is.CheckDepAndInstall(map[string]string{
"kind": "kind",
Expand Down Expand Up @@ -224,6 +230,7 @@ type kindOption struct {
portMappings map[string]string
ksVersion string
components []string
fetch bool

Reset bool
Nightly string
Expand Down
Loading

0 comments on commit 193bba5

Please sign in to comment.