Rancher 2+Kubernetes集群部署

Coding Alan 3年前 (2021-04-24) 2802次浏览 0个评论 扫描二维码

安装

Golang容器编译程序

Docker API

官方 SDK说明:https://docs.docker.com/engine/api/sdk/

Vagrant

允许密码登录

Nginx

在线生成配置文件:

安装Rancher

Rancher 有两个版本:1.x和2.x,其中1.x 主攻容器编排,2.x 主攻 K8S 集群部署相关:

https://rancher.com/docs/rancher/v2.x/zh/

Rancher 1.x 文档:https://rancher.com/docs/rancher/v1.6/zh/

多主机添加 host时第一个主机(本机)可能需自行添加-e CATTLE_AGENT_IP=xx.xx.xx.xx

一些准备工作:

这里在主机上使用了8080和8443端口进行映射,如果该主机仅用作部署 Rancher,可以直接使用80和443端口:

 

在 Rancher 内创建一个集群以供测试,首次创建会需要花费几分钟。通过所创建的集群拷贝配置内容(点击图中 Kubeconfig File),添加至~/.kube/config或在其它路径中创建配置文件并通过KUBECOFIG环境变量进行指定:

Rancher 2+Kubernetes集群部署

创建集群过程中如出现 etcd 关于证书的报错(tls: failed to verify client’s certificate: x509 etcd rancher),可删除重建。

nfs

  • root_squash(默认):将来访的root用户映射为匿名用户或用户组;
  • no_root_squash:来访的root用户保持root帐号权限 ;
  • no_all_squash(默认):访问用户先与本机用户匹配,匹配失败后再映射为匿名用户或用户组;
  • all_squash:将来访的所有用户映射为匿名用户或用户组;
  • secure(默认):限制客户端只能从小于1024的tcp/ip端口连接服务器;
  • insecure:允许客户端从大于1024的tcp/ip端口连接服务器;
  • anonuid:匿名用户的UID值,通常是nobody或nfsnobody,可以在此处自行设定;
  • anongid:匿名用户的GID值;
  • no_subtree_check:如果NFS输出的是一个子目录,则无需检查其父目录的权限(可以提高效率)

kuberctl

以1.20在Linux 上的安装为例,访问 GitHub下载对应版本

kubelet api命令 操作

/healthz 之外还有/pods, /stats/summary, /metrics等API

常见问题

1.Invalid username or password. Please try again.

2.Unable to authenticate the request due to an error: x509: certificate has expired or is not yet valid

这一问题网上的解决方案颇多,主要原因为证书实际有效期为一年,官网对于2.4+有一个解决方案在2.5.x 中实测有效,注意其中一次对服务的重启

2.6版本未实测,解决方案为:

3.certificate signed by unknown authority (possibly because of \”crypto/rsa: verification

4.拉取私有仓库报错:repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied

5.curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it

curl命令添加参数-k

 

喜欢 (1)
[]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址