From a0b9cda6c6a064d3244e5f00992aafe9f52b22b7 Mon Sep 17 00:00:00 2001 From: libm Date: Sat, 14 Dec 2024 17:11:38 +0800 Subject: [PATCH 1/3] fix: fix typo --- docs/pod.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pod.md b/docs/pod.md index 3d376de..7f4a024 100644 --- a/docs/pod.md +++ b/docs/pod.md @@ -85,7 +85,7 @@ kubectl delete -f nginx.yaml # pod "nginx" deleted ``` -最后,根据我们在 `container` 的那节构建的 `hellok8s:v1` 的镜像,同时参考 `nginx` pod 的资源定义,你能独自编写出 `hellok8s:v1` Pod 的资源文件吗。并通过 `port-forward` 到本地的 `3000` 端口进行访问,最终得到字符串 `[v1] Hello, Kubernetes!`。 +最后,根据我们在 `container` 的那节构建的 `hellok8s:v1` 的镜像,同时参考 `nginx` pod 的资源定义,你能独自编写出 `hellok8s:v1` Pod 的资源文件吗?并通过 `port-forward` 到本地的 `3000` 端口进行访问,最终得到字符串 `[v1] Hello, Kubernetes!`。 `hellok8s:v1` Pod 资源定义和相应的命令如下所示: From 474c17f622e586a5003b66a121a87cb0d28ccdcf Mon Sep 17 00:00:00 2001 From: libm Date: Sun, 15 Dec 2024 20:05:13 +0800 Subject: [PATCH 2/3] fix: exec [POD] [COMMAND] is not supported anymore. Use exec [POD] -- [COMMAND] instead --- README.md | 4 ++-- docs/service.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02c299a..31656a2 100644 --- a/README.md +++ b/README.md @@ -287,7 +287,7 @@ kubectl port-forward nginx-pod 4000:80 `kubectl exec -it` 可以用来进入 Pod 内容器的 Shell。通过命令下面的命令来配置 `nginx` 的首页内容。 ```shell -kubectl exec -it nginx-pod /bin/bash +kubectl exec -it nginx-pod -- /bin/bash echo "hello kubernetes by nginx!" > /usr/share/nginx/html/index.html @@ -934,7 +934,7 @@ kubectl get service # NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE # service-hellok8s-clusterip ClusterIP 10.104.96.153 3000/TCP 10s -kubectl exec -it nginx-pod /bin/bash +kubectl exec -it nginx-pod -- /bin/bash # root@nginx-pod:/# curl 10.104.96.153:3000 # [v3] Hello, Kubernetes!, From host: hellok8s-deployment-5d5545b69c-9gm8r # root@nginx-pod:/# curl 10.104.96.153:3000 diff --git a/docs/service.md b/docs/service.md index 422214f..57b425b 100644 --- a/docs/service.md +++ b/docs/service.md @@ -138,7 +138,7 @@ kubectl get service # NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE # service-hellok8s-clusterip ClusterIP 10.104.96.153 3000/TCP 10s -kubectl exec -it nginx-pod /bin/bash +kubectl exec -it nginx-pod -- /bin/bash # root@nginx-pod:/# curl 10.104.96.153:3000 # [v3] Hello, Kubernetes!, From host: hellok8s-deployment-5d5545b69c-9gm8r # root@nginx-pod:/# curl 10.104.96.153:3000 From 186eeb2964d29d8f652c8127f7a1987cde67b7bb Mon Sep 17 00:00:00 2001 From: libm Date: Sun, 15 Dec 2024 20:10:19 +0800 Subject: [PATCH 3/3] fix: Add description for official installation of kubectl --- docs/pre.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/pre.md b/docs/pre.md index 6448fbf..5217bfd 100644 --- a/docs/pre.md +++ b/docs/pre.md @@ -78,6 +78,7 @@ docker run hello-world 这一步是可选的,如果不安装的话,后续所有 `kubectl` 相关的命令,使用 `minikube kubectl` 命令替代即可。 如果你不想使用 `minikube kubectl` 或者配置相关环境变量来进行下面的教学的话,可以考虑直接安装 `kubectl`。 +以下为 MacOS 的安装方式,Linux & Windows 操作系统可以参考[官方文档](https://kubernetes.io/zh-cn/docs/tasks/tools/)快速安装。 ```shell brew install kubectl