File tree Expand file tree Collapse file tree 4 files changed +5
-4
lines changed Expand file tree Collapse file tree 4 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ kubectl port-forward nginx-pod 4000:80
287287` kubectl exec -it` 可以用来进入 Pod 内容器的 Shell。通过命令下面的命令来配置 `nginx` 的首页内容。
288288
289289` ` ` shell
290- kubectl exec -it nginx-pod /bin/bash
290+ kubectl exec -it nginx-pod -- /bin/bash
291291
292292echo "hello kubernetes by nginx!" > /usr/share/nginx/html/index.html
293293
@@ -934,7 +934,7 @@ kubectl get service
934934# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
935935# service-hellok8s-clusterip ClusterIP 10.104.96.153 <none> 3000/TCP 10s
936936
937- kubectl exec -it nginx-pod /bin/bash
937+ kubectl exec -it nginx-pod -- /bin/bash
938938# root@nginx-pod:/# curl 10.104.96.153:3000
939939# [v3] Hello, Kubernetes!, From host: hellok8s-deployment-5d5545b69c-9gm8r
940940# root@nginx-pod:/# curl 10.104.96.153:3000
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ kubectl delete -f nginx.yaml
8585# pod "nginx" deleted
8686` ` `
8787
88- 最后,根据我们在 `container` 的那节构建的 `hellok8s:v1` 的镜像,同时参考 `nginx` pod 的资源定义,你能独自编写出 `hellok8s:v1` Pod 的资源文件吗。 并通过 `port-forward` 到本地的 `3000` 端口进行访问,最终得到字符串 `[v1] Hello, Kubernetes!`。
88+ 最后,根据我们在 `container` 的那节构建的 `hellok8s:v1` 的镜像,同时参考 `nginx` pod 的资源定义,你能独自编写出 `hellok8s:v1` Pod 的资源文件吗? 并通过 `port-forward` 到本地的 `3000` 端口进行访问,最终得到字符串 `[v1] Hello, Kubernetes!`。
8989
9090` hellok8s:v1` Pod 资源定义和相应的命令如下所示:
9191
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ docker run hello-world
7878这一步是可选的,如果不安装的话,后续所有 ` kubectl ` 相关的命令,使用 ` minikube kubectl ` 命令替代即可。
7979
8080如果你不想使用 ` minikube kubectl ` 或者配置相关环境变量来进行下面的教学的话,可以考虑直接安装 ` kubectl ` 。
81+ 以下为 MacOS 的安装方式,Linux & Windows 操作系统可以参考[ 官方文档] ( https://kubernetes.io/zh-cn/docs/tasks/tools/ ) 快速安装。
8182
8283``` shell
8384brew install kubectl
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ kubectl get service
138138# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
139139# service-hellok8s-clusterip ClusterIP 10.104.96.153 <none> 3000/TCP 10s
140140
141- kubectl exec -it nginx-pod /bin/bash
141+ kubectl exec -it nginx-pod -- /bin/bash
142142# root@nginx-pod:/# curl 10.104.96.153:3000
143143# [v3] Hello, Kubernetes!, From host: hellok8s-deployment-5d5545b69c-9gm8r
144144# root@nginx-pod:/# curl 10.104.96.153:3000
You can’t perform that action at this time.
0 commit comments