-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
refactor yurtadm init/join and support to create high-availability OpenYurt cluster #926
Conversation
@windydayc: GitHub didn't allow me to assign the following users: Peeknut. Note that only openyurtio members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: windydayc The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov Report
@@ Coverage Diff @@
## master #926 +/- ##
==========================================
+ Coverage 35.30% 43.66% +8.36%
==========================================
Files 76 83 +7
Lines 9913 11260 +1347
==========================================
+ Hits 3500 4917 +1417
+ Misses 6146 5908 -238
- Partials 267 435 +168
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
84ac931
to
2291e7b
Compare
config/yurtadm/cloudimage/README.md
Outdated
@@ -0,0 +1,13 @@ | |||
# Build an OpenYurt CloudImage | |||
|
|||
`yurtadm init` is implemented by sealer, you can modify the kubefile to make your own openyurt cloudimage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openyurt cloudimage --> openyurt cluster image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
config/yurtadm/cloudimage/README.md
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that common end user can not push openyurt-cluster image into OpenYurt dockerhub, because they can not get the password.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. It is just an example.
Solved.
pkg/yurtadm/README.md
Outdated
|
||
```bash | ||
# Initialize an OpenYurt cluster. | ||
yurtadm init --apiserver-advertise-address 192.168.152.131 --openyurt-version latest --passwd 1234 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the mean of the address 192.168.152.131
and passwd 1234
? where do end users can find these kind of information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should make clear introduction in the tutorial for concrete ip address and password, if not, end user will not understand the meaning.
|
||
### 3.2 Initialize the OpenYurt cluster | ||
Execute the following command as root account, no need to install container runtimes such as docker in advance. Docker will be automatically installed during the execution of `yurtadm init`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to a image for explaining which kind of nodes and components are installed by yurtadm init
and yurtadm join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker is installed by sealer apply, so before yurtadm init
, you don't need to install docker.
While sealer is not involved in yurtadm join
, so before yurtadm join
, you should install docker.
@@ -0,0 +1,148 @@ | |||
apiVersion: v1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about use yaml file in openyurtio/openyurt/config/setup
directory? so we don't need to manage yaml file of openyurt here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rambohe-ch
At present, some parameters in yaml are not fixed, but are rendered by env in clusterfile, that is, the suffix .yaml.tmpl
file. Later, if you need to add user-defined parameters in env, .yaml.tmpl
files also need to be changed, so the file here (.yaml.tmpl
) may be somewhat different from that in the openyurtio/openyurt/config/setup
directory.
see: Using Clusterfile to init a cluster - Env render support | sealer
@@ -0,0 +1,177 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init-kube.sh
is used for initializing system for kubernetes, so it's not reasonable to put this file under flannel
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
} | ||
net-conf.json: | | ||
{ | ||
"Network": "10.244.0.0/16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this network should be configured by end user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
serviceAccountName: flannel | ||
initContainers: | ||
- name: install-cni | ||
image: quay.io/coreos/flannel:v0.14.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to use the optimized flannel image, mentioned here: https://openyurt.io/docs/user-manuals/network/edge-pod-network/
btw: cni plugin host-local
should use the optimized plugin, please pay attentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
# SELinux is unused in CaaSP | ||
rule: 'RunAsAny' | ||
--- | ||
kind: ClusterRole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cluster role should be suitable for the optimized flannel image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
## configure coredns | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's more reasonable to scale deployment/coredns before applying daemonset/coredns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
COPY install-openyurt.sh . | ||
RUN chmod 777 install-openyurt.sh | ||
|
||
CMD kubectl apply -f manifests/kube-flannel.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not put kubectl apply -f manifests/kube-flannel.yml
into install-openyurt.sh
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
FROM kubernetes:v1.19.8-alpine | ||
|
||
# flannel: https://github.com/sealerio/applications/tree/main/flannel | ||
COPY flannel/cni . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why put cni files under flannel directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved.
COPY flannel/init-kube.sh /scripts/ | ||
COPY flannel/kube-flannel.yml manifests/ | ||
|
||
COPY shell-plugin.yaml plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when do we apply this yaml file(shell-plugin.yaml)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is sealer's plugin: http://sealer.cool/docs/getting-started/plugin.html#plugin-type-list
Sealer will automatically execute all plugins under the plugins directory.
pkg/yurtadm/cmd/join/join.go
Outdated
"github.com/openyurtio/openyurt/pkg/yurtadm/cmd/join/joindata" | ||
yurtphase "github.com/openyurtio/openyurt/pkg/yurtadm/cmd/join/phases" | ||
yurtconstants "github.com/openyurtio/openyurt/pkg/yurtadm/constants" | ||
yurtadmutil "github.com/openyurtio/openyurt/pkg/yurtadm/util/kubernetes" | ||
) | ||
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not use concrete ip address and token in the example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will change it to 1.2.3.4
pkg/yurtadm/cmd/yurtinit/init.go
Outdated
` | ||
) | ||
|
||
var ( | ||
initExample = templates.Examples(i18n.T(` | ||
# Initialize an OpenYurt cluster. | ||
yurtadm init --apiserver-advertise-address 192.168.152.131 --openyurt-version latest --passwd 1234 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ddiot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, solved.
cgroupDriver: ${criDriver} | ||
cgroupsPerQOS: true | ||
clusterDNS: | ||
- 10.96.0.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ip address should be match with value that set by end user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
@windydayc please do not push --force when you fixed above comments. |
@Peeknut PTAL |
c7b1a9e
to
c3c3726
Compare
cd openyurt-latest | ||
|
||
# build openyurt ClusterImage | ||
sealer build -t registry-1.docker.io/your_dockerhub_username/openyurt-cluster:latest-k8s-1198 -f Kubefile . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is better to explain how to install sealer and the version of sealer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
kubectl annotate svc kube-dns -n kube-system openyurt.io/topologyKeys='openyurt.io/nodepool' | ||
|
||
## 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are many IP addresses, how to make sure these IP addresses are available to all users?
pkg/yurtadm/constants/constants.go
Outdated
@@ -48,6 +48,9 @@ const ( | |||
|
|||
DefaultOpenYurtImageRegistry = "registry.cn-hangzhou.aliyuncs.com/openyurt" | |||
DefaultOpenYurtVersion = "latest" | |||
DefaultK8sVersion = "1198" // default kubernetes 1.19.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use 1.19.8? 1198 is unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
pkg/yurtadm/util/kubernetes/util.go
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
pkg/yurtadm/util/kubernetes/util.go
Outdated
//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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using constants, it is better to define in const.
If configuration is supported, it is better to use fmt.Sprintf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Peeknut
openyurt-cni-0.8.7-0.x86_64.rpm(https://github.com/openyurtio/openyurt/releases/download/v0.7.0/openyurt-cni-0.8.7-0.x86_64.rpm) is only seen on https://github.com/openyurtio/openyurt/releases, and it has not changed.
It seems that it has little to do with the openyurt version.
Which one should be constants here? It seems that the openyurt version cannot be obtained in the yurtadm join
codes. Even if it can be obtained, if it is latest
version, there is no link like https://github.com/openyurtio/openyurt/releases/download/`latest`/openyurt-cni-0.8.7-0.x86_64.rpm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced it with cniUrl := fmt.Sprintf("%s", constants.OpenYurtCniUrl)
For config/yurtadm/cluster-image/openyurt-latest/cni directory, I have replaced the content in openyurt-cni-0.8.7-0.x86_64.rpm in https://github.com/openyurtio/openyurt/releases Reason see: https://openyurt.io/docs/user-manuals/network/edge-pod-network/#ipam-pod-ip-address-kept |
For |
2878046
to
0e12e94
Compare
@Peeknut I have solved the above problems. Please have a look. |
@windydayc I think it's not a good idea to maintian the cni binaries in openyurt repo, could you explain the reason?
|
|
7f0d3c3
to
e93fbf7
Compare
What type of PR is this?
/kind feature
/kind enhancement
What this PR does / why we need it:
At present, the installation of OpenYurt cluster is still a little complicated, there is a lack of a unified installation way that can simply and automatically install OpenYurt cluster.
In addition, currently the
yurtadm
command cannot cope with scenarios that requiring high availability. Therefore, it is necessary to provide a way to create high availability OpenYurt cluster.Special notes for your reviewer:
/assign @rambohe-ch @Peeknut