Skip to content

Commit

Permalink
Merge pull request #16 from Qaplagzy/support-kubeedge-1.17
Browse files Browse the repository at this point in the history
Support kubeedge 1.17
  • Loading branch information
kubeedge-bot authored Jul 23, 2024
2 parents fecfccd + 9e914a1 commit 48ce647
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 585 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
export GOPATH=$(go env GOPATH)
mkdir -p $GOPATH/github.com/kubeedge
git clone -b v1.13.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
git clone -b v1.17.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
- name: Build kubeedge/node image
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
export GOPATH=$(go env GOPATH)
mkdir -p $GOPATH/github.com/kubeedge
git clone -b v1.13.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
git clone -b v1.17.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
- name: Build kubeedge/node image
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
export GOPATH=$(go env GOPATH)
mkdir -p $GOPATH/github.com/kubeedge
git clone -b v1.13.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
git clone -b v1.17.0 https://github.com/kubeedge/kubeedge.git $GOPATH/github.com/kubeedge/kubeedge
- name: Build kubeedge/node image
run: |
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17
1.20
15 changes: 10 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
module github.com/kubeedge/keink

go 1.17
go 1.20

require (
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
sigs.k8s.io/kind v0.0.0
)

require (
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/sys v0.1.0 // indirect
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.20.0
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace sigs.k8s.io/kind => github.com/kubeedge/kind v0.12.0-kubeedge1
replace sigs.k8s.io/kind => github.com/kubeedge/kind v0.21.0-kubeedge1
575 changes: 15 additions & 560 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/build/edgeimage/internal/kube/builder_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func (b *dockerBuilder) Build() (kube.Bits, error) {
filepath.Join(filepath.Join(binDir, "edgecore")),

// CRDs required by KubeEdge
filepath.Join(crdDir, "devices", "devices_v1alpha2_device.yaml"),
filepath.Join(crdDir, "devices", "devices_v1alpha2_devicemodel.yaml"),
filepath.Join(crdDir, "devices", "devices_v1beta1_device.yaml"),
filepath.Join(crdDir, "devices", "devices_v1beta1_devicemodel.yaml"),
filepath.Join(crdDir, "reliablesyncs", "cluster_objectsync_v1alpha1.yaml"),
filepath.Join(crdDir, "reliablesyncs", "objectsync_v1alpha1.yaml"),
filepath.Join(crdDir, "router", "router_v1_rule.yaml"),
Expand Down
43 changes: 41 additions & 2 deletions pkg/build/edgeimage/internal/kube/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ limitations under the License.
package kube

import (
"fmt"
"go/build"
"os"
"path/filepath"

"golang.org/x/tools/go/packages"
"sigs.k8s.io/kind/pkg/errors"
"sigs.k8s.io/kind/pkg/exec"
)

// ImportPath is the canonical import path for the KubeEdge root package
// this is used by FindSource
const ImportPath = "github.com/kubeedge/kubeedge"
const ImportPath = "kubeedge"

// FindSource attempts to locate a KubeEdge checkout using go's build package
func FindSource() (root string, err error) {
Expand All @@ -33,12 +38,46 @@ func FindSource() (root string, err error) {
if err == nil && maybeKubeDir(pkg.Dir) {
return pkg.Dir, nil
}
path, err := findOrCloneKubeEdge(ImportPath)
if err == nil && path != "" {
return path, nil
}
return "", errors.New("could not find kubeedge source")
}

// maybeKubeDir returns true if the dir looks plausibly like a kubernetes
// source directory
func maybeKubeDir(dir string) bool {
// TODO(bentheelder): consider adding other sanity checks
return dir != ""
// check if 'go.mod' exists in the directory
goModPath := dir + "/go.mod"
if _, err := os.Stat(goModPath); os.IsNotExist(err) {
return false
}
return true
}

func findOrCloneKubeEdge(importPath string) (string, error) {
pkg, err := packages.Load(&packages.Config{Mode: packages.NeedFiles}, importPath)
if err == nil && len(pkg) > 0 && pkg[0].GoFiles != nil {
return filepath.Dir(pkg[0].GoFiles[0]), nil
}

branch := "release-1.17"
localDir := filepath.Join(build.Default.GOPATH, "src", importPath)
fmt.Println("Cloning KubeEdge from GitHub to", localDir)

if err := gitClone("https://github.com/kubeedge/kubeedge.git", branch, localDir); err != nil {
return "", err
}

return localDir, nil
}

func gitClone(repoURL, branch, localDir string) error {
cmd := exec.Command("git", "clone", "--branch", branch, repoURL, localDir)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to clone KubeEdge repository: %w", err)
}
return nil
}
31 changes: 19 additions & 12 deletions pkg/cluster/internal/create/actions/kubeedge/kubeedge.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ func (a *Action) startCloudcore(ctx *actions.ActionContext, node nodes.Node) err

// create CRDs
crds := []string{
"devices_v1alpha2_device.yaml",
"devices_v1alpha2_devicemodel.yaml",
"devices_v1beta1_device.yaml",
"devices_v1beta1_devicemodel.yaml",
"cluster_objectsync_v1alpha1.yaml",
"objectsync_v1alpha1.yaml",
"router_v1_rule.yaml",
Expand Down Expand Up @@ -326,31 +326,32 @@ func (a *Action) runStartEdgecore(ctx *actions.ActionContext, node nodes.Node) e
return fmt.Errorf("failed to generate cloudcore config: %v", err)
}

cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|token: .*|token: %s|g" /etc/kubeedge/config/edgecore.yaml`, KubeEdgeToken))
cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "/metaServer:/{n;n;s/false/true/;}" /etc/kubeedge/config/edgecore.yaml`))
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
if err != nil {
return fmt.Errorf("failed to modify token: %v", err)
return fmt.Errorf("failed to modify metaServer: %v", err)
}

// modify runtime to containerd
cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|remoteImageEndpoint: .*|remoteImageEndpoint: %s|g" /etc/kubeedge/config/edgecore.yaml`, "unix:///var/run/containerd/containerd.sock"))
cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|cgroupDriver: .*|cgroupDriver: systemd|g" /etc/kubeedge/config/edgecore.yaml`))
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
if err != nil {
return fmt.Errorf("failed to modify remoteImageEndpoint: %v", err)
return fmt.Errorf("failed to modify cgroupDriver: %v", err)
}
cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|remoteRuntimeEndpoint: .*|remoteRuntimeEndpoint: %s|g" /etc/kubeedge/config/edgecore.yaml`, "unix:///var/run/containerd/containerd.sock"))

cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|imageServiceEndpoint: .*|imageServiceEndpoint: %s|g" /etc/kubeedge/config/edgecore.yaml`, "unix:///var/run/containerd/containerd.sock"))
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
if err != nil {
return fmt.Errorf("failed to modify remoteRuntimeEndpoint: %v", err)
return fmt.Errorf("failed to modify imageServiceEndpoint to remote: %v", err)
}
cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|containerRuntime: .*|containerRuntime: %s|g" /etc/kubeedge/config/edgecore.yaml`, "remote"))

cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|containerRuntimeEndpoint: .*|containerRuntimeEndpoint: %s|g" /etc/kubeedge/config/edgecore.yaml`, "unix:///var/run/containerd/containerd.sock"))
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
if err != nil {
return fmt.Errorf("failed to modify containerRuntime to remote: %v", err)
return fmt.Errorf("failed to modify containerRuntimeEndpoint to remote: %v", err)
}

// modify edgeHub.httpServer websocker.server ip cloudcore ip or control-plane ip
Expand Down Expand Up @@ -381,6 +382,12 @@ func (a *Action) runStartEdgecore(ctx *actions.ActionContext, node nodes.Node) e
return fmt.Errorf("failed to modify resolv: %v", err)
}

cmd = node.Command("bash", "-c", fmt.Sprintf(`sed -i -e "s|token: .*|token: %s|g" /etc/kubeedge/config/edgecore.yaml`, KubeEdgeToken))
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
if err != nil {
return fmt.Errorf("failed to modify token: %v", err)
}
cmd = node.Command("bash", "-c", "systemctl daemon-reload && systemctl enable edgecore && systemctl start edgecore")
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
Expand Down Expand Up @@ -408,7 +415,7 @@ func (a *Action) runStartEdgecoreWithKeadm(ctx *actions.ActionContext, node node
// not start MQTT conainer, error: E0728 01:07:37.717267 1429 remote_runtime.go:116] "RunPodSandbox from runtime service failed" err="rpc error: code = Unknown
// desc = failed to reserve sandbox name \"mqtt___0\": name \"mqtt___0\" is reserved for \"264c9ad4f0be7271711a21b0c89f958da582e1869a3b18fb07dd719b16989595\""
// TODO: debug why edgecore segmentfault with nothing
joinCmd := fmt.Sprintf("keadm join --cloudcore-ipport %s --certport 30002 --token %s --remote-runtime-endpoint unix:///var/run/containerd/containerd.sock --runtimetype remote --with-mqtt=false", controlPlaneIP+":30000", KubeEdgeToken)
joinCmd := fmt.Sprintf("keadm join --cgroupdriver=systemd --cloudcore-ipport=%s --token=%s --remote-runtime-endpoint=unix:///var/run/containerd/containerd.sock", controlPlaneIP+":10000", KubeEdgeToken)
cmd = node.Command("bash", "-c", joinCmd)
lines, err = exec.CombinedOutputLines(cmd)
ctx.Logger.V(3).Info(strings.Join(lines, "\n"))
Expand Down

0 comments on commit 48ce647

Please sign in to comment.