- A+
所属分类:未分类
下载
k3s的最新版本下载地址如下:https://github.com/rancher/k3s/releases/download/v0.4.0/k3s
下载命令如下:
wget https://github.com/rancher/k3s/releases/download/v0.4.0/k3s
我这里下载到/opt目录下,下载完成后,添加可执行权限,命令如下:
chmod +x k3s
这样我们就可以执行server了,这里说明一下,执行之前先要配置防火墙以及selinux,我这里都关闭了。
参数介绍请下载本网站客户端,搜索linux命令k3s查看,我们这里两台机器,
服务端:192.168.241.128
客户端:192.168.241.130
启动server端
128上我们这里只启动server端,所以就不启动agent,命令如下:
./k3s server --disable-agent
结果如下:
[rancher@rancher opt]# ./k3s server --disable-agent INFO[0000] Preparing data dir /var/lib/rancher/k3s/data/e249e3fc5ccf8ea07732c672f3062154b47357f5c85e1735339f087752a0f3ee INFO[2019-04-25T12:40:07.086194213+08:00] Starting k3s v0.4.0 (7822549f) INFO[2019-04-25T12:40:08.672739237+08:00] Running kube-apiserver --advertise-port=6445 --insecure-port=0 --service-account-key-file=/var/lib/rancher/k3s/server/tls/service.key --service-account-issuer=k3s --kubelet-client-certificate=/var/lib/rancher/k3s/server/tls/token-node.crt --proxy-client-cert-file=/var/lib/rancher/k3s/server/tls/client-auth-proxy.crt --proxy-client-key-file=/var/lib/rancher/k3s/server/tls/client-auth-proxy.key --authorization-mode=Node,RBAC --service-cluster-ip-range=10.43.0.0/16 --advertise-address=127.0.0.1 --secure-port=6444 --kubelet-client-key=/var/lib/rancher/k3s/server/tls/token-node.key --requestheader-client-ca-file=/var/lib/rancher/k3s/server/tls/request-header-ca.crt --requestheader-allowed-names=kubernetes-proxy --requestheader-group-headers=X-Remote-Group --cert-dir=/var/lib/rancher/k3s/server/tls/temporary-certs --service-account-signing-key-file=/var/lib/rancher/k3s/server/tls/service.key --bind-address=127.0.0.1 --api-audiences=unknown --basic-auth-file=/var/lib/rancher/k3s/server/cred/passwd --requestheader-username-headers=X-Remote-User --watch-cache=false --allow-privileged=true --tls-cert-file=/var/lib/rancher/k3s/server/tls/localhost.crt --tls-private-key-file=/var/lib/rancher/k3s/server/tls/localhost.key --requestheader-extra-headers-prefix=X-Remote-Extra- INFO[2019-04-25T12:40:09.089202818+08:00] Running kube-scheduler --port=10251 --bind-address=127.0.0.1 --secure-port=0 --kubeconfig=/var/lib/rancher/k3s/server/cred/kubeconfig-system.yaml --leader-elect=false INFO[2019-04-25T12:40:09.090502538+08:00] Running kube-controller-manager --service-account-private-key-file=/var/lib/rancher/k3s/server/tls/service.key --cluster-cidr=10.42.0.0/16 --leader-elect=false --port=10252 --bind-address=127.0.0.1 --kubeconfig=/var/lib/rancher/k3s/server/cred/kubeconfig-system.yaml --allocate-node-cidrs=true --secure-port=0 --root-ca-file=/var/lib/rancher/k3s/server/tls/token-ca.crt INFO[2019-04-25T12:40:09.145904212+08:00] Creating CRD listenerconfigs.k3s.cattle.io INFO[2019-04-25T12:40:09.152957461+08:00] Creating CRD addons.k3s.cattle.io INFO[2019-04-25T12:40:09.154392621+08:00] Creating CRD helmcharts.k3s.cattle.io INFO[2019-04-25T12:40:09.156945476+08:00] Waiting for CRD addons.k3s.cattle.io to become available INFO[2019-04-25T12:40:09.658692897+08:00] Done waiting for CRD addons.k3s.cattle.io to become available INFO[2019-04-25T12:40:09.658713767+08:00] Waiting for CRD helmcharts.k3s.cattle.io to become available INFO[2019-04-25T12:40:10.258677692+08:00] Done waiting for CRD helmcharts.k3s.cattle.io to become available INFO[2019-04-25T12:40:10.258696119+08:00] Waiting for CRD listenerconfigs.k3s.cattle.io to become available INFO[2019-04-25T12:40:10.760966434+08:00] Done waiting for CRD listenerconfigs.k3s.cattle.io to become available INFO[2019-04-25T12:40:10.763037095+08:00] Listening on :6443 INFO[2019-04-25T12:40:11.701810882+08:00] Node token is available at /var/lib/rancher/k3s/server/node-token INFO[2019-04-25T12:40:11.701832039+08:00] To join node to cluster: k3s agent -s https://192.168.241.128:6443 -t ${NODE_TOKEN} INFO[2019-04-25T12:40:11.708719366+08:00] Writing static file: /var/lib/rancher/k3s/server/static/charts/traefik-1.64.0.tgz INFO[2019-04-25T12:40:11.709028046+08:00] Writing manifest: /var/lib/rancher/k3s/server/manifests/coredns.yaml INFO[2019-04-25T12:40:11.709196532+08:00] Writing manifest: /var/lib/rancher/k3s/server/manifests/traefik.yaml INFO[2019-04-25T12:40:11.760150852+08:00] Wrote kubeconfig /etc/rancher/k3s/k3s.yaml INFO[2019-04-25T12:40:11.760193829+08:00] Run: k3s kubectl INFO[2019-04-25T12:40:11.760198837+08:00] k3s is up and running
这样服务端就启动起来了。
启动客户端
刚才启动服务端的时候,有这一条日志,如下:
INFO[2019-04-25T12:40:11.701810882+08:00] Node token is available at /var/lib/rancher/k3s/server/node-token
这里存的是客户端启动时的token,内容如下:
[rancher@rancher opt]# more /var/lib/rancher/k3s/server/node-token K10340a7e4e2091370765ca91fffc9e798e958ab6c50d9e9fde2a0c56678b444970::node:64c0b3fdb9af52efe77c5ba7e535186b
现在我们到130上,启动客户端,如下:
./k3s agent -s https://192.168.241.128 --token=K10340a7e4e2091370765ca91fffc9e798e958ab6c50d9e9fde2a0c56678b444970::node:64c0b3fdb9af52efe77c5ba7e535186b
然后我们不熟一个nginx试试,如下:
[rancher@rancher opt]$ ./k3s kubectl create -f https://kubernetes.io/docs/user-guide/nginx-deployment.yaml --record deployment.apps/nginx-deployment created
查看子节点:
[root@rancher opt]# ./k3s kubectl get node NAME STATUS ROLES AGE VERSION rancher Ready <none> 24m v1.14.1-k3s.4
查看接口:
浏览器访问:s://192.168.241.132:6443
如下:
- 安卓客户端下载
- 微信扫一扫
- 微信公众号
- 微信公众号扫一扫