This commit is contained in:
yinkanglong
2023-08-13 16:09:29 +08:00
parent f068be44c3
commit 4c7ee762dc
47 changed files with 1564 additions and 444 deletions

View File

@@ -89,8 +89,7 @@ k8s.gcr.io/etcd:3.5.3-0=gotok8s/etcd:3.5.3-0
```
然后执行`./load_images.sh `即可下载k8s依赖的镜像随后打开`Docker`,进入设置界面,勾选`Enable Kubernetes`即可:
![fS12Nk](https://images-1252557999.file.myqcloud.com/uPic/fS12Nk.png)
![](image/2023-08-09-14-11-04.png)
不出意外,界面左下角会出现`Kubernetes running`的提示,这样就安装成功了。
@@ -540,6 +539,9 @@ kubectl expose po hello --port=5000 --target-port=5000 --type=NodePort --name h
kubectl get services
```
## MINIKUBE
https://minikube.sigs.k8s.io/docs/start/
## 参考
本部分内容有参考如下文章:

View File

@@ -1,4 +1,4 @@
cd# 基础概念介绍
# 基础概念介绍
![guitars-2912447_1920](https://images-1252557999.file.myqcloud.com/uPic/guitars-2912447_1920.jpg)

View File

@@ -178,7 +178,7 @@ switched to db test_data
持久卷由管理员创建(各种配置信息),然后用户创建持久卷声明,提交后`k8s`就会找到匹配的持久卷并将其绑定到持久卷声明。
![image-20210305175203591](https://images-1252557999.file.myqcloud.com/uPic/image-20210305175203591.png)
![](image/2023-08-09-16-49-09.png)
这样做的好处在于对于用户只需要关注声明一下需要多大的存储、需要什么权限读写然后pod通过其中一个卷的名称来引用声明就可以了将细节完美地进行了隐藏。

View File

@@ -121,7 +121,7 @@ root 1634 1607 0 06:31 pts/0 00:00:00 ps -ef
我们直接使用书中的例子:`vim fortune-pod-env.yaml`
```shell
```yaml
apiVersion: v1
kind: Pod
metadata:
@@ -200,7 +200,7 @@ PWD=/
`ConfigMap`是不需要被读取的,它映射的内容通过环境变量或者卷文件的形式传给容器。一般直接在`pod`的定义里面就可以声明`ConfigMap`,这样就可以根据不同的环境创建不同的配置,流程交互如下图所示:
![image-20210316203507993](https://images-1252557999.file.myqcloud.com/uPic/image-20210316203507993.png)
![](image/2023-08-09-16-55-18.png)
### 创建

View File

@@ -280,17 +280,22 @@ kubectl attach -it nginx -c shell
-t tty表示窗口链接
-c 容器container名称
● 进入指定的容器中执行特定的命令
```sh
kubectl exec -it mongodb mongo
kubectl exec -it pod_name -c container_name -- /bin/sh
```
● 暂时服务化一个容器,将本机的端口映射到容器中某个服务的端口。
kubectl port-forward fortune 8080:80
● 永久服务化,创建一个持久化的服务
```sh
# 创建一个服务对象
# NodePort 在所有节点(虚拟机)上开放一个特定端口,任何发送到该端口的流量都被转发到对应服务
kubectl expose pod nginx --port=80 --target-port=80 --type=NodePort --name nginx-http
```
● 删除所有的pod和所有的资源
```
kubectl delete pod --all -n custom-namespace
kubectl delete all --all -n custom-namespace2
kubectl delete ns --all
```
## kubectl错误排查的步骤

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB