站长博客
站长博客随手笔记
Toggle navigation
站长博客
Home
MacOS
Database
Linux
PHP
Git
Golang
About Me
Archives
Tags
Kubernetes
2022-06-10 10:40:04
248
0
0
admin
### CURD 0. Kubernetes 对象: https://kubernetes.io/zh/docs/concepts/overview/working-with-objects/kubernetes-objects/ 1. 创建一个服务对象来暴露 Deployment: `kubectl expose deployment/nginx-deployment --type=NodePor` 2. 展示 Service 信息: `kubectl describe services nginx-deployment` 注意服务中的 NodePort 值。 3. 使用节点地址和 node port 来访问: curl http://`<public-node-ip>`:`<node-port>` 或者 curl http://127.0.0.1:`<node-port>` 4. 删除服务: `kubectl delete services nginx-deployment` 5. 删除部署 `kubectl delete deployment nginx-deployment` https://kubernetes.io/zh/docs/tasks/access-application-cluster/service-access-application-cluster/ ### 常用查询命令 * 查询node: `kubectl get nodes -o wide` * 查询pod: `kubectl get pods -o wide` * 查询部署状态: `kubectl get deploy` * 查询服务状态: `kubectl get service` * 查询敏感数据状态: `kubectl get secret` * 查询上线状态:`kubectl rollout status deployment/my-nginx-release` * 查询上线历史:`kubectl rollout history deployment/my-nginx-release` * 查询pod详情描述:`kubectl describe pod my-nginx-release-659d46fcd4-w5s8h` (可以查看镜像部署状态以及报错详细信息) ### 执行容器命令 格式如下: ``` kubectl exec -it <podName> -c <containerName> -n <namespace> -- <shell_comand> ``` 例如:创建目录 ``` kubectl exec -it spark-master-xksl -c spark-master -n spark -- mkdir -p /usr/local/spark ``` > 注意: > shell命令前,要加`--`号,不然shell命令中的参数,不能识别 ## Helm helm 文档:https://helm.sh/zh/docs/ helm Chart 文档:https://helm.sh/zh/docs/topics/charts/ * Chart:配置(定义)文件(例如:https://github.com/bitnami/charts/tree/master/bitnami/nginx) * Release:Chart 的实例 * Repository:仓库(例如:https://artifacthub.io) 参考:https://www.cnblogs.com/lyc94620/p/10945430.html 用 helm 安装 (中括号部分为可选): ```sh helm install -f customValues.yaml my-nginx-release bitnami/nginx ``` 或者 ```sh helm install my-nginx-release bitnami/nginx --set="ingress.enabled=true,ingress.hostname=localhost,autoscaling.enabled=true,autoscaling.minReplicas=3,autoscaling.maxReplicas=10" ```
Prev:
macOS 终端配置
Next:
Linux 下 的 ssh 免密登录
0
likes
248
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Table of content