Confronta commit

...

1 Commit

Autore SHA1 Messaggio Data
  wangyu f51fb1d9d9 增加补充说明 4 anni fa
10 ha cambiato i file con 42 aggiunte e 11 eliminazioni
  1. BIN
      .DS_Store
  2. +42
    -11
      Assignment8.md
  3. BIN
      file/.DS_Store
  4. BIN
      file/assignment2/.DS_Store
  5. BIN
      img/.DS_Store
  6. BIN
      img/assignment2/.DS_Store
  7. BIN
      img/assignment8/apply_config.png
  8. BIN
      img/assignment8/k8s_master_ip.png
  9. BIN
      img/assignment8/master_yml.png
  10. BIN
      img/assignment8/ucloud_key.png

BIN
.DS_Store Vedi File


+ 42
- 11
Assignment8.md Vedi File

@ -65,7 +65,7 @@
#### 2)登录云主机,安装kubectl
```
```bash
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/ (root用户:mv kubectl /usr/bin/)
@ -102,7 +102,7 @@ kubectl version -o json
#### 6)尝试几个基本命令
```
```bash
kubectl cluster-info //打印集群信息
kubectl get nodes //打印节点信息
kubectl get pods //打印pod信息
@ -116,7 +116,7 @@ kubectl get services //打印service信息
#### 1)运行以下命令,部署一个assignment2中的静态网页app
```
```bash
kubectl create deployment webapp --image=uhub-edu.service.ucloud.cn/cloud_computing/static_site
```
@ -131,7 +131,7 @@ kubectl create deployment webapp --image=uhub-edu.service.ucloud.cn/cloud_comput
#### 3)这时我们需要用kubectl创建一个代理,使得从云主机可以访问集群(从而访问pod)。打开一个新的Terminal或者XShell窗口,登录云主机。
```
```bash
echo -e "\n\e[92mStarting Proxy. After starting it will not output a response. Please click the first Terminal Tab\n"; kubectl proxy
```
@ -140,7 +140,7 @@ echo -e "\n\e[92mStarting Proxy. After starting it will not output a response. P
#### 4)访问webapp应用(访问pod)
```
```bash
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n}}{{end}}')
echo Name of the Pod: $POD_NAME //如果这一步没有输出,说明$POD_NAME没有获得pod名称,可以把kubectl get pods得到的pod名字直接赋给$POD_NAME。
curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/
@ -156,7 +156,7 @@ curl http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy/
#### 1)查看pod当前副本信息
```
```bash
kubectl get rs
```
@ -165,7 +165,7 @@ kubectl get rs
#### 2)查看pod的详细信息
```
```bash
kubectl get pods -o wide
```
@ -179,7 +179,7 @@ kubectl get pods -o wide
#### 3)现在让我们用一行命令将副本scale到10个,然后再次查看pod详细信息
```
```bash
kubectl scale deployments/webapp --replicas=10
kubectl get pods -o wide
```
@ -193,13 +193,13 @@ kubectl get pods -o wide
#### 1)创建一个负载均衡service,将webapp暴露给外网
```
```bash
kubectl expose deployment webapp --type=LoadBalancer --port=80
```
#### 2)查看当前的service,你可以找到负载均衡服务的外网ip地址
```
```bash
kubectl get services
```
<kbd>
@ -208,12 +208,43 @@ kubectl get services
#### 3)在你自己的电脑上,打开浏览器,访问http://负载均衡服务的外网ip地址
***************** 关于负载均衡获取不到ip 一直处于pending的暂时解决方案***********
##### a. 使用 `kubectl get nodes ` 命令获取 `master`节点的ip
#####  <img src="img/assignment8/k8s_master_ip.png">
##### b. 在当前云主机终端使用`ssh root@ip` 登陆`master`节点
##### c. 修改 `/etc/kubernetes/yaml/userdata.yaml` 文件的内容,补全密钥信息,密钥信息可以在`ucloud控制台获取`
<kbd> <img src="img/assignment8/ucloud_key.png"></kbd>
> 补充完整的配置文件应该如下所示:
<kbd><img src="img/assignment8/master_yml.png">/kbd>
##### d. 运行如下命令:
```bash
kubectl apply -f /etc/kubernetes/yaml/userdata.yaml
```
<kbd><img src="img/assignment8/apply_config.png"></kbd>
##### e. 退出当前`master`节点,回退到云主机,稍等片刻,`ip`将会自动分配
## `**************作业5:请将kubectl get services输出信息截图、并将浏览器地址栏和网页内容一起截图,并插入实验报告***************`
#### 4)删除service,删除所有pod,最后在网页上删除集群,删除云主机(包括K8S没有自动删除的云主机)。
```
```bash
kubectl delete service webapp
kubectl delete deployment webapp
```

BIN
file/.DS_Store Vedi File


BIN
file/assignment2/.DS_Store Vedi File


BIN
img/.DS_Store Vedi File


BIN
img/assignment2/.DS_Store Vedi File


BIN
img/assignment8/apply_config.png Vedi File

Prima Dopo
Larghezza: 559  |  Altezza: 55  |  Dimensione: 39 KiB

BIN
img/assignment8/k8s_master_ip.png Vedi File

Prima Dopo
Larghezza: 544  |  Altezza: 289  |  Dimensione: 224 KiB

BIN
img/assignment8/master_yml.png Vedi File

Prima Dopo
Larghezza: 666  |  Altezza: 263  |  Dimensione: 167 KiB

BIN
img/assignment8/ucloud_key.png Vedi File

Prima Dopo
Larghezza: 387  |  Altezza: 480  |  Dimensione: 45 KiB

Caricamento…
Annulla
Salva