File tree Expand file tree Collapse file tree 2 files changed +114
-0
lines changed Expand file tree Collapse file tree 2 files changed +114
-0
lines changed Original file line number Diff line number Diff line change
1
+ # 快速入门指南
2
+
3
+ 本指南旨在帮助您在 Kubernetes 中部署基于 ` wcjiang/linux-command ` 镜像的 ` linux-command ` 应用。该应用提供了一套 ` Deployment ` ,并通过 ` Service ` 对外暴露服务端口。
4
+
5
+ ## 前提条件
6
+
7
+ - 已安装并配置好的 Kubernetes 集群
8
+ - 安装并配置好的 ` kubectl ` ,并连接至你的 Kubernetes 集群
9
+
10
+ ## 安装步骤
11
+
12
+ 我们将使用此存储库中的` kubectl ` 应用 YAML 文件,该文件将安装 ` linux-command ` 应用。
13
+
14
+ ``` bash
15
+ $ kubectl apply -f https://raw.githubusercontent.com/jaywcjlove/linux-command/master/deploy/yamls/linux-command.yaml
16
+ ```
17
+
18
+ 检查 ` Deployment ` 状态:
19
+
20
+ ``` bash
21
+ $ kubectl get deployments -n linux-command
22
+ NAME READY UP-TO-DATE AVAILABLE AGE
23
+ linux-command 1/1 1 1 17m
24
+ ```
25
+
26
+ 你可以查看 ` Pod ` 的状态以确保其正常运行:
27
+
28
+ ``` bash
29
+ $ kubectl get pods -n linux-command
30
+ NAME READY STATUS RESTARTS AGE
31
+ linux-command-fff454654-427zp 1/1 Running 0 12m
32
+ ```
33
+
34
+ 验证 ` Service ` 是否成功创建并获取暴露的端口:
35
+
36
+ ```
37
+ $ kubectl get services -n linux-command
38
+ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
39
+ linux-command-service NodePort 10.96.2.225 <none> 9665:30204/TCP 18m
40
+ ```
41
+
42
+ ## 访问应用
43
+
44
+ 通过获取 ` NodePort ` 的端口来访问应用。以下是获取 ` NodePort ` 服务信息的命令:
45
+
46
+ ```
47
+ $ kubectl get svc linux-command-service -n linux-command
48
+ ```
49
+
50
+ 根据输出,使用 ` EXTERNAL-IP:PORT ` 访问服务。例如:
51
+
52
+ ```
53
+ http://<Node-IP>:<NodePort>
54
+ ```
55
+
56
+ ## 卸载应用
57
+
58
+ 如果需要删除已部署的资源,可以按以下顺序操作:
59
+
60
+ ```
61
+ kubectl delete -f linux-command.yaml
62
+ ```
63
+
64
+ 这将会清理所有创建的 Kubernetes 资源。
Original file line number Diff line number Diff line change
1
+ ---
2
+ apiVersion : v1
3
+ kind : Namespace
4
+ metadata :
5
+ name : linux-command
6
+ ---
7
+ apiVersion : apps/v1
8
+ kind : Deployment
9
+ metadata :
10
+ name : linux-command
11
+ namespace : linux-command
12
+ labels :
13
+ app : linux-command
14
+ spec :
15
+ replicas : 1
16
+ selector :
17
+ matchLabels :
18
+ app : linux-command
19
+ template :
20
+ metadata :
21
+ labels :
22
+ app : linux-command
23
+ spec :
24
+ containers :
25
+ - name : linux-command-container
26
+ image : wcjiang/linux-command:latest
27
+ imagePullPolicy : IfNotPresent
28
+ ports :
29
+ - containerPort : 3000
30
+ resources :
31
+ requests :
32
+ cpu : " 100m"
33
+ memory : " 50Mi"
34
+ limits :
35
+ cpu : " 100m"
36
+ memory : " 50Mi"
37
+ ---
38
+ apiVersion : v1
39
+ kind : Service
40
+ metadata :
41
+ name : linux-command-service
42
+ namespace : linux-command
43
+ spec :
44
+ selector :
45
+ app : linux-command
46
+ ports :
47
+ - protocol : TCP
48
+ port : 9665
49
+ targetPort : 3000
50
+ type : NodePort
You can’t perform that action at this time.
0 commit comments