File tree 1 file changed +40
-2
lines changed
ping-tai-gong-cheng-xun-lian-ying-yi-qi/ansible-jiao-cheng
1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,28 @@ Kubespray 是一个开源项目,旨在帮助用户在多云环境中部署和
23
23
24
24
### 安装
25
25
26
- #### 克隆代码
26
+ #### 1. 设置免密登录
27
+
28
+ 首先在你的 Ansible 节点上为你的本地用户生成 SSH 密钥:
29
+
30
+ ```
31
+ $ ssh-keygen
32
+ ```
33
+
34
+ 使用 ` ssh-copy-id ` 命令复制 SSH 密钥:
35
+
36
+ ```
37
+ $ ssh-copy-id -i ~/.ssh/{rsa.pub} {username}@{192.168.1.241}
38
+ $ ssh-copy-id -i ~/.ssh/{rsa.pub} {username}@{192.168.1.242}
39
+ ```
40
+
41
+ #### 2. 克隆代码
27
42
28
43
```
29
44
git clone [email protected] :kubernetes-sigs/kubespray.git
30
45
```
31
46
32
- #### 安装 ansible
47
+ #### 3. 安装 ansible
33
48
34
49
需要提前安装下 python 和 pip , 以下命令主要是创建一个 python 虚拟环境,并安装依赖,复制命令执行即可
35
50
@@ -56,3 +71,26 @@ cp -r inventory/sample inventory/mycluster
56
71
57
72
<figure ><img src =" ../../.gitbook/assets/1734748395130.png " alt =" " ><figcaption ></figcaption ></figure >
58
73
74
+ ### 安装集群
75
+
76
+ ```
77
+ ansible-playbook -i inventory/mycluster/inventory.ini cluster.yml -b -v \
78
+ --private-key=~/.ssh/private_key -u xx -e ansible_become_pass=xxxx
79
+ ```
80
+
81
+ ### 访问集群
82
+
83
+ ` kubectl_localhost: true ` 和` kubeconfig_localhost: true `   ;
84
+
85
+ 如果启用了` kubectl_localhost ` , ` kubectl ` 将下载到` /usr/local/bin/ ` ,还会生成一个` inventory/mycluster/artifacts/kubectl.sh ` 脚本
86
+
87
+ 如果` kubeconfig_localhost ` 启用了` admin.conf ` 会出现在 ` inventory/mycluster/artifacts/ `
88
+
89
+ 注意:admin.conf 文件中的控制器主机名可能是私有 IP。如果是这样,请将其更改为使用控制器的公共 IP 或集群的负载均衡器。  ;
90
+
91
+ 您可以通过运行以下命令查看节点列表:
92
+
93
+ ```
94
+ cd inventory/mycluster/artifacts
95
+ ./kubectl.sh get nodes
96
+ ```
You can’t perform that action at this time.
0 commit comments