diff --git a/config/yurtadm/cloudimage/README.md b/config/yurtadm/cloudimage/README.md deleted file mode 100644 index 70aed4f5b6f..00000000000 --- a/config/yurtadm/cloudimage/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Build an OpenYurt CloudImage - -`yurtadm init` is implemented by sealer, you can modify the kubefile to make your own openyurt cloudimage. - -```bash -cd openyurt-latest - -# build cloudimage -sealer build -t registry-1.docker.io/openyurt/openyurt-cluster:latest-k8s-1198 -f Kubefile . - -# push to dockerhub -sealer push registry-1.docker.io/openyurt/openyurt-cluster:latest-k8s-1198 -``` \ No newline at end of file diff --git a/config/yurtadm/cloudimage/openyurt-latest/Kubefile b/config/yurtadm/cloudimage/openyurt-latest/Kubefile deleted file mode 100644 index 11b52599046..00000000000 --- a/config/yurtadm/cloudimage/openyurt-latest/Kubefile +++ /dev/null @@ -1,16 +0,0 @@ -FROM kubernetes:v1.19.8-alpine - -# flannel: https://github.com/sealerio/applications/tree/main/flannel -COPY flannel/cni . -COPY flannel/init-kube.sh /scripts/ -COPY flannel/kube-flannel.yml manifests/ - -COPY shell-plugin.yaml plugins - -# openyurt -COPY yamls/*.yaml manifests -COPY install-openyurt.sh . -RUN chmod 777 install-openyurt.sh - -CMD kubectl apply -f manifests/kube-flannel.yml -CMD ./install-openyurt.sh \ No newline at end of file diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bandwidth b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bandwidth deleted file mode 100644 index 441f71df7ad..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bandwidth and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bridge b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bridge deleted file mode 100644 index 64915b3578c..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/bridge and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/firewall b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/firewall deleted file mode 100644 index 714e8d48863..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/firewall and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/flannel b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/flannel deleted file mode 100644 index dc1a0d4aaaa..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/flannel and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-device b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-device deleted file mode 100644 index 6a4647a41a2..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-device and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-local b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-local deleted file mode 100644 index 52d552b9d6e..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/host-local and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ipvlan b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ipvlan deleted file mode 100644 index 935a94e4eb1..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ipvlan and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/loopback b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/loopback deleted file mode 100644 index 323e3665fe6..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/loopback and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/macvlan b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/macvlan deleted file mode 100644 index 8be93b29b17..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/macvlan and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/portmap b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/portmap deleted file mode 100644 index 41bd0a02f4d..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/portmap and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ptp b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ptp deleted file mode 100644 index a9628313f68..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/ptp and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/sbr b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/sbr deleted file mode 100644 index 88d48eb7a7b..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/sbr and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/static b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/static deleted file mode 100644 index d1a34be1348..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/static and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/tuning b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/tuning deleted file mode 100644 index 7f126a9e9d7..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/tuning and /dev/null differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/vlan b/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/vlan deleted file mode 100644 index 56a187210e5..00000000000 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/vlan and /dev/null differ diff --git a/config/yurtadm/cluster-image/README.md b/config/yurtadm/cluster-image/README.md new file mode 100644 index 00000000000..23cc0822b7f --- /dev/null +++ b/config/yurtadm/cluster-image/README.md @@ -0,0 +1,13 @@ +# Build an OpenYurt ClusterImage + +`yurtadm init` is implemented by sealer, you can modify the kubefile to make your own openyurt cluster image. + +```bash +cd openyurt-latest + +# build openyurt ClusterImage +sealer build -t registry-1.docker.io/your_dockerhub_username/openyurt-cluster:latest-k8s-1198 -f Kubefile . + +# push to dockerhub +sealer push registry-1.docker.io/your_dockerhub_username/openyurt-cluster:latest-k8s-1198 +``` \ No newline at end of file diff --git a/config/yurtadm/cluster-image/openyurt-latest/Kubefile b/config/yurtadm/cluster-image/openyurt-latest/Kubefile new file mode 100644 index 00000000000..6076cb2cd88 --- /dev/null +++ b/config/yurtadm/cluster-image/openyurt-latest/Kubefile @@ -0,0 +1,15 @@ +FROM kubernetes:v1.19.8-alpine + +# flannel: https://github.com/sealerio/applications/tree/main/flannel +COPY cni . +COPY init-kube.sh /scripts/ +COPY kube-flannel.yaml.tmpl manifests/ + +COPY shell-plugin.yaml plugins + +# openyurt +COPY yamls/* manifests +COPY install.sh . +RUN chmod 777 install.sh + +CMD ./install.sh \ No newline at end of file diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/bridge b/config/yurtadm/cluster-image/openyurt-latest/cni/bridge new file mode 100755 index 00000000000..4cc76e18680 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/bridge differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/dhcp b/config/yurtadm/cluster-image/openyurt-latest/cni/dhcp old mode 100644 new mode 100755 similarity index 59% rename from config/yurtadm/cloudimage/openyurt-latest/flannel/cni/dhcp rename to config/yurtadm/cluster-image/openyurt-latest/cni/dhcp index ae39ab0892f..1953aca6658 Binary files a/config/yurtadm/cloudimage/openyurt-latest/flannel/cni/dhcp and b/config/yurtadm/cluster-image/openyurt-latest/cni/dhcp differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/flannel b/config/yurtadm/cluster-image/openyurt-latest/cni/flannel new file mode 100755 index 00000000000..2c99c8d52eb Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/flannel differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/host-device b/config/yurtadm/cluster-image/openyurt-latest/cni/host-device new file mode 100755 index 00000000000..005d75603a7 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/host-device differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/host-local b/config/yurtadm/cluster-image/openyurt-latest/cni/host-local new file mode 100755 index 00000000000..e506a5a5939 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/host-local differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/ipvlan b/config/yurtadm/cluster-image/openyurt-latest/cni/ipvlan new file mode 100755 index 00000000000..428b4864fb6 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/ipvlan differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/loopback b/config/yurtadm/cluster-image/openyurt-latest/cni/loopback new file mode 100755 index 00000000000..fcd73791cb1 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/loopback differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/macvlan b/config/yurtadm/cluster-image/openyurt-latest/cni/macvlan new file mode 100755 index 00000000000..e4287cc193d Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/macvlan differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/portmap b/config/yurtadm/cluster-image/openyurt-latest/cni/portmap new file mode 100755 index 00000000000..ed11e2866e5 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/portmap differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/ptp b/config/yurtadm/cluster-image/openyurt-latest/cni/ptp new file mode 100755 index 00000000000..50fb267153a Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/ptp differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/sample b/config/yurtadm/cluster-image/openyurt-latest/cni/sample new file mode 100755 index 00000000000..e813677c9d6 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/sample differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/tuning b/config/yurtadm/cluster-image/openyurt-latest/cni/tuning new file mode 100755 index 00000000000..822cd5c1c86 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/tuning differ diff --git a/config/yurtadm/cluster-image/openyurt-latest/cni/vlan b/config/yurtadm/cluster-image/openyurt-latest/cni/vlan new file mode 100755 index 00000000000..3f3af9b33f1 Binary files /dev/null and b/config/yurtadm/cluster-image/openyurt-latest/cni/vlan differ diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/init-kube.sh b/config/yurtadm/cluster-image/openyurt-latest/init-kube.sh similarity index 98% rename from config/yurtadm/cloudimage/openyurt-latest/flannel/init-kube.sh rename to config/yurtadm/cluster-image/openyurt-latest/init-kube.sh index 3cc67e44ead..e9618b4cb57 100644 --- a/config/yurtadm/cloudimage/openyurt-latest/flannel/init-kube.sh +++ b/config/yurtadm/cluster-image/openyurt-latest/init-kube.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright © 2021 Alibaba Group Holding Ltd. +# Copyright © 2022 Alibaba Group Holding Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -117,8 +117,6 @@ authorization: cacheUnauthorizedTTL: 30s cgroupDriver: ${criDriver} cgroupsPerQOS: true -clusterDNS: -- 10.96.0.10 clusterDomain: cluster.local configMapAndSecretChangeDetectionStrategy: Watch containerLogMaxFiles: 5 diff --git a/config/yurtadm/cloudimage/openyurt-latest/install-openyurt.sh b/config/yurtadm/cluster-image/openyurt-latest/install.sh similarity index 97% rename from config/yurtadm/cloudimage/openyurt-latest/install-openyurt.sh rename to config/yurtadm/cluster-image/openyurt-latest/install.sh index 5318fbcd2a6..9914fd09f00 100644 --- a/config/yurtadm/cloudimage/openyurt-latest/install-openyurt.sh +++ b/config/yurtadm/cluster-image/openyurt-latest/install.sh @@ -16,6 +16,8 @@ echo "[INFO] Start installing OpenYurt." +kubectl apply -f manifests/kube-flannel.yaml + ## label node kubectl label node $HOSTNAME openyurt.io/is-edge-worker=false @@ -27,9 +29,9 @@ kubectl apply -f manifests/yurt-app-manager.yaml kubectl apply -f manifests/yurthub-cfg.yaml ## configure coredns +kubectl scale --replicas=0 deployment/coredns -n kube-system kubectl apply -f manifests/coredns.yaml kubectl annotate svc kube-dns -n kube-system openyurt.io/topologyKeys='openyurt.io/nodepool' -kubectl scale --replicas=0 deployment/coredns -n kube-system ## configure kube-proxy kubectl patch cm -n kube-system kube-proxy --patch '{"data": {"config.conf": "apiVersion: kubeproxy.config.k8s.io/v1alpha1\nbindAddress: 0.0.0.0\nfeatureGates:\n EndpointSliceProxying: true\nbindAddressHardFail: false\nclusterCIDR: 100.64.0.0/10\nconfigSyncPeriod: 0s\nenableProfiling: false\nipvs:\n excludeCIDRs:\n - 10.103.97.2/32\n minSyncPeriod: 0s\n strictARP: false\nkind: KubeProxyConfiguration\nmode: ipvs\nudpIdleTimeout: 0s\nwinkernel:\n enableDSR: false\nkubeconfig.conf:"}}' && kubectl delete pod --selector k8s-app=kube-proxy -n kube-system diff --git a/config/yurtadm/cloudimage/openyurt-latest/flannel/kube-flannel.yml b/config/yurtadm/cluster-image/openyurt-latest/kube-flannel.yaml.tmpl similarity index 95% rename from config/yurtadm/cloudimage/openyurt-latest/flannel/kube-flannel.yml rename to config/yurtadm/cluster-image/openyurt-latest/kube-flannel.yaml.tmpl index 17a430942a9..65dd71ee794 100644 --- a/config/yurtadm/cloudimage/openyurt-latest/flannel/kube-flannel.yml +++ b/config/yurtadm/cluster-image/openyurt-latest/kube-flannel.yaml.tmpl @@ -66,6 +66,7 @@ rules: resources: - nodes verbs: + - get - list - watch - apiGroups: @@ -125,7 +126,7 @@ data: } net-conf.json: | { - "Network": "10.244.0.0/16", + "Network": "{{ .PodCIDR }}", "Backend": { "Type": "vxlan" } @@ -166,7 +167,7 @@ spec: serviceAccountName: flannel initContainers: - name: install-cni - image: quay.io/coreos/flannel:v0.14.0 + image: registry.cn-hangzhou.aliyuncs.com/openyurt/flannel-edge:v0.14.0-1 command: - cp args: @@ -180,7 +181,7 @@ spec: mountPath: /etc/kube-flannel/ containers: - name: kube-flannel - image: quay.io/coreos/flannel:v0.14.0 + image: registry.cn-hangzhou.aliyuncs.com/openyurt/flannel-edge:v0.14.0-1 command: - /opt/bin/flanneld args: diff --git a/config/yurtadm/cloudimage/openyurt-latest/shell-plugin.yaml b/config/yurtadm/cluster-image/openyurt-latest/shell-plugin.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/shell-plugin.yaml rename to config/yurtadm/cluster-image/openyurt-latest/shell-plugin.yaml diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/coredns.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/coredns.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/coredns.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/coredns.yaml diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-app-manager.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-app-manager.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-app-manager.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-app-manager.yaml diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-controller-manager.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-controller-manager.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-controller-manager.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-controller-manager.yaml diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-tunnel-agent.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-tunnel-agent.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-tunnel-agent.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-tunnel-agent.yaml diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-tunnel-server.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-tunnel-server.yaml.tmpl similarity index 98% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-tunnel-server.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-tunnel-server.yaml.tmpl index 3db48f81165..361e66ea1e7 100644 --- a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurt-tunnel-server.yaml +++ b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurt-tunnel-server.yaml.tmpl @@ -202,6 +202,7 @@ spec: args: - --bind-address=$(NODE_IP) - --insecure-bind-address=$(NODE_IP) + - --cert-ips={{ .YurttunnelServerAddress }} - --proxy-strategy=destHost - --v=2 env: diff --git a/config/yurtadm/cloudimage/openyurt-latest/yamls/yurthub-cfg.yaml b/config/yurtadm/cluster-image/openyurt-latest/yamls/yurthub-cfg.yaml similarity index 100% rename from config/yurtadm/cloudimage/openyurt-latest/yamls/yurthub-cfg.yaml rename to config/yurtadm/cluster-image/openyurt-latest/yamls/yurthub-cfg.yaml diff --git a/go.mod b/go.mod index 03392e526c4..70b36e5a3b3 100644 --- a/go.mod +++ b/go.mod @@ -22,8 +22,6 @@ require ( github.com/openyurtio/yurt-app-manager-api v0.18.8 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.0 - github.com/sealyun/lvscare v1.1.2-alpha.2 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect github.com/spf13/cobra v1.2.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 diff --git a/go.sum b/go.sum index 510a60abb2f..e264d0487e4 100644 --- a/go.sum +++ b/go.sum @@ -477,8 +477,6 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/ipvs v1.0.1 h1:aoZ7fhLTXgDbzVrAnvV+XbKOU8kOET7B3+xULDF/1o0= -github.com/moby/ipvs v1.0.1/go.mod h1:2pngiyseZbIKXNv7hsKj3O9UEz30c53MT9005gt2hxQ= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= @@ -568,8 +566,6 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sealyun/lvscare v1.1.2-alpha.2 h1:SlnEAXOPn5gC6l8tgvbn9fApyJaQ0ecQHSV3cEfvQYY= -github.com/sealyun/lvscare v1.1.2-alpha.2/go.mod h1:FtOEdsXuYtw9Jwd/Jct25K+PcpUFSDemvF4VgNygjj0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -596,7 +592,6 @@ github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= @@ -631,13 +626,10 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= -github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20200603190939-5a869a71f0cb h1:MY3XXjEi7+I9L6iwK4x0KWNL9OaWMQ5CntP06o+8zZc= github.com/vishvananda/netlink v1.1.1-0.20200603190939-5a869a71f0cb/go.mod h1:FSQhuTO7eHT34mPzX+B04SUAjiqLxtXs1et0S6l9k4k= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/wonderivan/logger v1.0.0 h1:Z6Nz+3SNcizolx3ARH11axdD4DXjFpb2J+ziGUVlv/U= -github.com/wonderivan/logger v1.0.0/go.mod h1:NObMfQ3WOLKfYEZuGeZQfuQfSPE5+QNgRddVMzsAT/k= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= @@ -864,7 +856,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/pkg/yurtadm/README.md b/pkg/yurtadm/README.md index 9a425b23d78..2207597e261 100644 --- a/pkg/yurtadm/README.md +++ b/pkg/yurtadm/README.md @@ -7,7 +7,7 @@ To expand the cluster later, users can use the `yurtadm join` command to add edg ## 2.Ability Using yurtadm, you can do: - Create a simple openyurt cluster with just one command. -- Create a High-Availability OpenYurt cluster. +- Create a High Availability OpenYurt cluster. ## 3.Process ### 3.1 Compile Yurtadm @@ -26,10 +26,10 @@ Execute the following command as root account, no need to install container runt ```bash # Initialize an OpenYurt cluster. -yurtadm init --apiserver-advertise-address 192.168.152.131 --openyurt-version latest --passwd 1234 +yurtadm init --apiserver-advertise-address 1.2.3.4 --openyurt-version latest --passwd xxx -# Initialize an OpenYurt cluster with multiple masters. -yurtadm init --apiserver-advertise-address 192.168.152.131,192.168.152.132 --openyurt-version v0.7.0 --passwd 1234 +# Initialize an OpenYurt high availability cluster. +yurtadm init --apiserver-advertise-address 1.2.3.4,1.2.3.5,1.2.3.6 --openyurt-version v0.7.0 --passwd xxx ``` `yurtadm init` will use sealer to create a K8s cluster. And kubeadm, kubectl, docker, etc. will all be installed during this process. @@ -40,23 +40,23 @@ Get bootstrap token from the master: ```bash kubeadm token create W0720 20:46:19.782354 31205 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io] -zffaj3.a5vjzf09qn9ft3gt +abcdef.0123456789abcdef ``` Before `yurtadm join` you need to install a runtime (like docker) on the worker node. Then execute the `yurtadm join` command in the worker node: ```bash # Join the edge node to cluster. -yurtadm join 192.168.152.131:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 +yurtadm join 1.2.3.4:6443 --token=abcdef.0123456789abcdef --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 -# Join the edge node to cluster with multiple masters. -yurtadm join 192.168.152.131:6443,192.168.152.132:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 +# Join the edge node to a high availability cluster. +yurtadm join 1.2.3.4:6443,1.2.3.5:6443,1.2.3.6:6443 --token=abcdef.0123456789abcdef --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 # Join the cloud node to cluster. -yurtadm join 192.168.152.131:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 +yurtadm join 1.2.3.4:6443 --token=abcdef.0123456789abcdef --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 -# Join the cloud node to cluster with multiple masters. -yurtadm join 192.168.152.131:6443,192.168.152.132:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 +# Join the cloud node to a high availability cluster. +yurtadm join 1.2.3.4:6443,1.2.3.5:6443,1.2.3.6:6443 --token=abcdef.0123456789abcdef --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 ``` ## Other Problems diff --git a/pkg/yurtadm/cmd/join/join.go b/pkg/yurtadm/cmd/join/join.go index fd183ffe382..b0b1363785a 100644 --- a/pkg/yurtadm/cmd/join/join.go +++ b/pkg/yurtadm/cmd/join/join.go @@ -48,16 +48,16 @@ import ( var ( joinExample = templates.Examples(i18n.T(` # Join the edge node to cluster. - yurtadm join 192.168.152.131:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 + yurtadm join 1.2.3.4:6443 --token=abcdef.0123456789abcdef --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 - # Join the edge node to cluster with multiple masters. - yurtadm join 192.168.152.131:6443,192.168.152.132:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 + # Join the edge node to a high availability cluster. + yurtadm join 1.2.3.4:6443,1.2.3.5:6443,1.2.3.6:6443 --token=abcdef.0123456789abcdef --node-type=edge --discovery-token-unsafe-skip-ca-verification --v=5 # Join the cloud node to cluster. - yurtadm join 192.168.152.131:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 + yurtadm join 1.2.3.4:6443 --token=abcdef.0123456789abcdef --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 - # Join the cloud node to cluster with multiple masters. - yurtadm join 192.168.152.131:6443,192.168.152.132:6443 --token=zffaj3.a5vjzf09qn9ft3gt --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 + # Join the cloud node to a high availability cluster. + yurtadm join 1.2.3.4:6443,1.2.3.5:6443,1.2.3.6:6443 --token=abcdef.0123456789abcdef --node-type=cloud --discovery-token-unsafe-skip-ca-verification --v=5 `)) joinWorkerNodeDoneMsg = dedent.Dedent(` diff --git a/pkg/yurtadm/cmd/join/phases/joinnode.go b/pkg/yurtadm/cmd/join/phases/joinnode.go index dc159a83449..0b6ad36843d 100644 --- a/pkg/yurtadm/cmd/join/phases/joinnode.go +++ b/pkg/yurtadm/cmd/join/phases/joinnode.go @@ -24,14 +24,10 @@ import ( "strings" "github.com/pkg/errors" - "github.com/sirupsen/logrus" - v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/version" clientset "k8s.io/client-go/kubernetes" - "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" @@ -49,13 +45,6 @@ import ( "github.com/openyurtio/openyurt/pkg/yurtadm/util/edgenode" ) -const ( - LvsCareStaticPodName = "kube-lvscare" - LvsCareCommand = "/usr/bin/lvscare" - DefaultLvsCareImage = "fanux/lvscare:latest" - LvsStaticPodFileName = "kube-lvscare.yaml" -) - // NewEdgeNodePhase creates a yurtadm workflow phase that start kubelet on a edge node. func NewEdgeNodePhase() workflow.Phase { return workflow.Phase{ @@ -83,10 +72,6 @@ func runJoinNode(c workflow.RunData) error { return err } - if err := addLvsStaticPodYaml(data, filepath.Join(constants.KubernetesDir, constants.ManifestsSubDirName)); err != nil { - return err - } - if err := addYurthubStaticYaml(data, filepath.Join(constants.KubernetesDir, constants.ManifestsSubDirName)); err != nil { return err } @@ -170,106 +155,6 @@ func writeConfigBytesToDisk(b []byte, kubeletDir string) error { return nil } -// LvsStaticPodYaml return lvs care static pod yaml -func LvsStaticPodYaml(vip string, masters []string, image string) string { - if vip == "" || len(masters) == 0 { - return "" - } - if image == "" { - image = DefaultLvsCareImage - } - args := []string{"care", "--vs", vip + ":6443", "--health-path", "/healthz", "--health-schem", "https"} - for _, m := range masters { - args = append(args, "--rs") - args = append(args, m) - } - flag := true - pod := componentPod(v1.Container{ - Name: LvsCareStaticPodName, - Image: image, - Command: []string{LvsCareCommand}, - Args: args, - ImagePullPolicy: v1.PullIfNotPresent, - SecurityContext: &v1.SecurityContext{Privileged: &flag}, - }) - yaml, err := podToYaml(pod) - if err != nil { - logrus.Errorf("failed to decode lvs care static pod yaml: %s", err) - return "" - } - return string(yaml) -} - -// componentPod returns a Pod object from the container and volume specifications -func componentPod(container v1.Container) v1.Pod { - hostPathType := v1.HostPathUnset - mountName := "lib-modules" - volumes := []v1.Volume{ - {Name: mountName, VolumeSource: v1.VolumeSource{ - HostPath: &v1.HostPathVolumeSource{ - Path: "/lib/modules", - Type: &hostPathType, - }, - }}, - } - container.VolumeMounts = []v1.VolumeMount{ - {Name: mountName, ReadOnly: true, MountPath: "/lib/modules"}, - } - - return v1.Pod{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "Pod", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: container.Name, - Namespace: metav1.NamespaceSystem, - }, - Spec: v1.PodSpec{ - Containers: []v1.Container{container}, - HostNetwork: true, - Volumes: volumes, - }, - } -} - -func podToYaml(pod v1.Pod) ([]byte, error) { - codecs := scheme.Codecs - gv := v1.SchemeGroupVersion - const mediaType = runtime.ContentTypeYAML - info, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType) - if !ok { - return []byte{}, errors.Errorf("unsupported media type %q", mediaType) - } - - encoder := codecs.EncoderForVersion(info.Serializer, gv) - return runtime.Encode(encoder, &pod) -} - -// addLvsStaticPodYaml generate lvscare static yaml for worker node. -func addLvsStaticPodYaml(data joindata.YurtJoinData, podManifestPath string) error { - klog.Info("[join-node] Adding lvscare static yaml") - if _, err := os.Stat(podManifestPath); err != nil { - if os.IsNotExist(err) { - err = os.MkdirAll(podManifestPath, os.ModePerm) - if err != nil { - return err - } - } else { - klog.Errorf("Describe dir %s fail: %v", podManifestPath, err) - return err - } - } - - yaml := LvsStaticPodYaml(yurtconstants.DefaultVIP, strings.Split(data.ServerAddr(), ","), DefaultLvsCareImage) - if err := os.WriteFile(filepath.Join(podManifestPath, LvsStaticPodFileName), []byte(yaml), 0600); err != nil { - return err - } - - klog.Info("[join-node] Add lvscare static yaml is ok") - return nil -} - // addYurthubStaticYaml generate YurtHub static yaml for worker node. func addYurthubStaticYaml(data joindata.YurtJoinData, podManifestPath string) error { klog.Info("[join-node] Adding edge hub static yaml") @@ -286,9 +171,9 @@ func addYurthubStaticYaml(data joindata.YurtJoinData, podManifestPath string) er } // convert - // 192.168.152.131:6443,192.168.152.132:6443 + // 1.2.3.4:6443,1.2.3.5:6443,1.2.3.6:6443 // to - // https://192.168.152.131:6443,https://192.168.152.132:6443 + // https://1.2.3.4:6443,https://1.2.3.5:6443,https://1.2.3.6:6443 serverAddrs := strings.Split(data.ServerAddr(), ",") for i := 0; i < len(serverAddrs); i++ { serverAddrs[i] = fmt.Sprintf("https://%s", serverAddrs[i]) diff --git a/pkg/yurtadm/cmd/join/phases/preflight.go b/pkg/yurtadm/cmd/join/phases/preflight.go index 19bf074c068..9ba6ab821bd 100644 --- a/pkg/yurtadm/cmd/join/phases/preflight.go +++ b/pkg/yurtadm/cmd/join/phases/preflight.go @@ -17,7 +17,6 @@ limitations under the License. package phases import ( - "fmt" "strings" "github.com/pkg/errors" @@ -30,7 +29,6 @@ import ( "github.com/openyurtio/openyurt/pkg/util/kubernetes/kubeadm/app/cmd/phases/workflow" "github.com/openyurtio/openyurt/pkg/util/kubernetes/kubeadm/app/preflight" "github.com/openyurtio/openyurt/pkg/yurtadm/cmd/join/joindata" - yurtconstants "github.com/openyurtio/openyurt/pkg/yurtadm/constants" ) // NewPreflightPhase creates a kubeadm workflow phase that implements preflight checks for a new node join @@ -73,7 +71,7 @@ func runPreflight(c workflow.RunData) error { Discovery: kubeadmapi.Discovery{ TLSBootstrapToken: data.JoinToken(), BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{ - APIServerEndpoint: fmt.Sprintf("%s:6443", yurtconstants.DefaultVIP), + APIServerEndpoint: strings.Split(data.ServerAddr(), ",")[0], Token: data.JoinToken()}, }, ControlPlane: nil, diff --git a/pkg/yurtadm/cmd/join/phases/prepare.go b/pkg/yurtadm/cmd/join/phases/prepare.go index 030d653211b..97044d95faa 100644 --- a/pkg/yurtadm/cmd/join/phases/prepare.go +++ b/pkg/yurtadm/cmd/join/phases/prepare.go @@ -20,7 +20,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "k8s.io/klog/v2" @@ -28,7 +27,6 @@ import ( "github.com/openyurtio/openyurt/pkg/util/kubernetes/kubeadm/app/cmd/phases/workflow" "github.com/openyurtio/openyurt/pkg/util/kubernetes/kubeadm/app/constants" "github.com/openyurtio/openyurt/pkg/yurtadm/cmd/join/joindata" - yurtconstants "github.com/openyurtio/openyurt/pkg/yurtadm/constants" "github.com/openyurtio/openyurt/pkg/yurtadm/util/kubernetes" "github.com/openyurtio/openyurt/pkg/yurtadm/util/system" ) @@ -68,13 +66,6 @@ func runPrepare(c workflow.RunData) error { return err } - if err := system.AddVIPHosts(); err != nil { - return err - } - if err := system.AddIPVS(fmt.Sprintf("%s:6443", yurtconstants.DefaultVIP), strings.Split(data.ServerAddr(), ",")); err != nil { - return err - } - if err := kubernetes.CheckAndInstallKubelet(data.KubernetesResourceServer(), data.KubernetesVersion()); err != nil { return err } diff --git a/pkg/yurtadm/cmd/yurtinit/init.go b/pkg/yurtadm/cmd/yurtinit/init.go index 54a4a452cd5..03387d8b493 100644 --- a/pkg/yurtadm/cmd/yurtinit/init.go +++ b/pkg/yurtadm/cmd/yurtinit/init.go @@ -79,18 +79,15 @@ spec: pk: /root/.ssh/id_rsa user: root env: + - PodCIDR={{.pod_subnet}} - YurttunnelServerAddress={{.yurttunnel_server_address}} --- ## Custom configurations must specify kind, will be merged to default kubeadm configs kind: ClusterConfiguration networking: - {{if .pod_subnet }} podSubnet: {{.pod_subnet}} - {{end}} - {{if .service_subnet}} serviceSubnet: {{.service_subnet}} - {{end}} controllerManager: extraArgs: controllers: -nodelifecycle,*,bootstrapsigner,tokencleaner @@ -100,10 +97,10 @@ controllerManager: var ( initExample = templates.Examples(i18n.T(` # Initialize an OpenYurt cluster. - yurtadm init --apiserver-advertise-address 192.168.152.131 --openyurt-version latest --passwd 1234 + yurtadm init --apiserver-advertise-address 1.2.3.4 --openyurt-version latest --passwd xxx - # Initialize an OpenYurt cluster with multiple masters. - yurtadm init --apiserver-advertise-address 192.168.152.131,192.168.152.132 --openyurt-version latest --passwd 1234 + # Initialize an OpenYurt high availability cluster. + yurtadm init --apiserver-advertise-address 1.2.3.4,1.2.3.5,1.2.3.6 --openyurt-version latest --passwd xxx `)) ValidSealerVersions = []string{ diff --git a/pkg/yurtadm/cmd/yurtinit/options.go b/pkg/yurtadm/cmd/yurtinit/options.go index e8c9bc9920e..9ed603a08e3 100644 --- a/pkg/yurtadm/cmd/yurtinit/options.go +++ b/pkg/yurtadm/cmd/yurtinit/options.go @@ -43,6 +43,8 @@ func NewInitOptions() *InitOptions { ImageRepository: constants.DefaultOpenYurtImageRegistry, OpenYurtVersion: constants.DefaultOpenYurtVersion, K8sVersion: constants.DefaultK8sVersion, + PodSubnet: constants.DefaultPodSubnet, + ServiceSubnet: constants.DefaultServiceSubnet, } } diff --git a/pkg/yurtadm/constants/constants.go b/pkg/yurtadm/constants/constants.go index 4aa1808cfab..2819fa0bbb1 100644 --- a/pkg/yurtadm/constants/constants.go +++ b/pkg/yurtadm/constants/constants.go @@ -24,7 +24,6 @@ const ( YurttunnelAgentComponentName = "yurt-tunnel-agent" YurttunnelNamespace = "kube-system" - EtcHostsFile = "/etc/hosts" SysctlK8sConfig = "/etc/sysctl.d/k8s.conf" KubeletConfigureDir = "/etc/kubernetes" KubeletWorkdir = "/var/lib/kubelet" @@ -47,11 +46,11 @@ const ( EdgeNode = "edge" CloudNode = "cloud" - DefaultVIP = "10.103.97.2" - DefaultAPIserverDomain = "apiserver.cluster.local" DefaultOpenYurtImageRegistry = "registry.cn-hangzhou.aliyuncs.com/openyurt" DefaultOpenYurtVersion = "latest" DefaultK8sVersion = "1198" // default kubernetes 1.19.8 + DefaultPodSubnet = "10.244.0.0/16" + DefaultServiceSubnet = "10.96.0.0/12" YurtControllerManager = "yurt-controller-manager" YurtTunnelServer = "yurt-tunnel-server" YurtTunnelAgent = "yurt-tunnel-agent" diff --git a/pkg/yurtadm/util/kubernetes/util.go b/pkg/yurtadm/util/kubernetes/util.go index 3c6bcd6499c..de456060c3c 100644 --- a/pkg/yurtadm/util/kubernetes/util.go +++ b/pkg/yurtadm/util/kubernetes/util.go @@ -144,20 +144,35 @@ func CheckAndInstallKubelet(kubernetesResourceServer, clusterVersion string) err klog.Infof("Cni dir %s already exist, skip install.", constants.KubeCniDir) return nil } + + ////download and install kubernetes-cni + //cniUrl := fmt.Sprintf(constants.CniUrlFormat, constants.KubeCniVersion, runtime.GOARCH, constants.KubeCniVersion) + //savePath := fmt.Sprintf("%s/cni-plugins-linux-%s-%s.tgz", constants.TmpDownloadDir, runtime.GOARCH, constants.KubeCniVersion) + //klog.V(1).Infof("Download cni from: %s", cniUrl) + //if err := util.DownloadFile(cniUrl, savePath, 3); err != nil { + // return err + //} + // + //if err := os.MkdirAll(constants.KubeCniDir, 0600); err != nil { + // return err + //} + //if err := util.Untar(savePath, constants.KubeCniDir); err != nil { + // return err + //} + //download and install kubernetes-cni - cniUrl := fmt.Sprintf(constants.CniUrlFormat, constants.KubeCniVersion, runtime.GOARCH, constants.KubeCniVersion) - savePath := fmt.Sprintf("%s/cni-plugins-linux-%s-%s.tgz", constants.TmpDownloadDir, runtime.GOARCH, constants.KubeCniVersion) + cniUrl := "https://github.com/openyurtio/openyurt/releases/download/v0.7.0/openyurt-cni-0.8.7-0.x86_64.rpm" + savePath := fmt.Sprintf("%s/openyurt-cni-0.8.7-0.x86_64.rpm", constants.TmpDownloadDir) klog.V(1).Infof("Download cni from: %s", cniUrl) if err := util.DownloadFile(cniUrl, savePath, 3); err != nil { return err } - - if err := os.MkdirAll(constants.KubeCniDir, 0600); err != nil { - return err - } - if err := util.Untar(savePath, constants.KubeCniDir); err != nil { + // rpm -ivh --nodeps --force /tmp/openyurt-cni-0.8.7-0.x86_64.rpm + // will install cni binaries to /opt/cni/bin/ + if _, err := exec.Command("rpm", "-ivh", "--nodeps", "--force", savePath).CombinedOutput(); err != nil { return err } + return nil } diff --git a/pkg/yurtadm/util/system/util.go b/pkg/yurtadm/util/system/util.go index f17d51d253a..dcf4634105e 100644 --- a/pkg/yurtadm/util/system/util.go +++ b/pkg/yurtadm/util/system/util.go @@ -22,7 +22,6 @@ import ( "os/exec" "github.com/opencontainers/selinux/go-selinux" - "github.com/sealyun/lvscare/care" "k8s.io/klog/v2" "github.com/openyurtio/openyurt/pkg/yurtadm/constants" @@ -76,32 +75,3 @@ func SetSELinux() error { selinux.SetDisabled() return nil } - -// AddVIPHosts add the vip to the hosts. -func AddVIPHosts() error { - klog.Info("Adding vip to the hosts") - f, err := os.OpenFile(constants.EtcHostsFile, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0660) - if err != nil { - return fmt.Errorf("Open file %s fail: %w ", constants.EtcHostsFile, err) - } - defer f.Close() - f.WriteString(fmt.Sprintf("%s %s\n", constants.DefaultVIP, constants.DefaultAPIserverDomain)) - return nil -} - -// AddIPVS add ipvs rules. -func AddIPVS(virtualServer string, realServer []string) error { - klog.Info("Adding ipvs rules") - lvscare := &care.LvsCare{ - HealthPath: "/healthz", - HealthSchem: "https", - VirtualServer: virtualServer, - RealServer: realServer, - RunOnce: true, - Clean: true, - Interval: 5, - } - - go lvscare.VsAndRsCare() - return nil -}