K8s简单yaml文件运行例子deployment
生活随笔
收集整理的這篇文章主要介紹了
K8s简单yaml文件运行例子deployment
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
kubectl run
- 創建并運行一個或多個容器鏡像。
- 創建一個deployment?或job?來管理容器。
kubectl run 語法:
$ run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]
?
運行一個deployment:
kubectl? run? nginx-deployment? --image=nginx:1.7.9? --replicas=2
查看:
kubectl describe deployment nginx-deployment
?
基本例子:
nginx-test.yaml
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | apiVersion: extensions/v1beta1???#當前格式的版本 kind: Deployment?????????????????#當前創建資源的類型, 當前類型是Deployment metadata:????????????????????????#當前資源的元數據 ??name: nginx-test???????????????#當前資源的名字 是元數據必須的項 spec:????????????????????????????#是當前Deployment的規格說明 ??replicas:??????????????????????#指當前創建的副本數量 默認不填 默認值就為‘1’ ??template:??????????????????????#定義pod的模板 ????metadata:????????????????????#當前pod的元數據 ??????labels:????????????????????#至少頂一個labels標簽,可任意創建一個 key:value ????????app: web_server ????spec:????????????????????????#當前pod的規格說明 ??????containers:????????????????#容器 ??????- name: nginx??????????????#是容器的名字容器名字是必須填寫的 ????????image: nginx:latest??????#鏡像 鏡像的名字和版本 |
?
使用yaml文件創建資源:
kubectl apply -f nginx-test.yaml
刪除yaml文件創建的資源:
kubectl delete -f nginx-test.yaml
?
轉載于:https://www.cnblogs.com/wjoyxt/p/9988158.html
總結
以上是生活随笔為你收集整理的K8s简单yaml文件运行例子deployment的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DataX 安装和使用
- 下一篇: Alpha冲刺 - (5/10)