标签:space lan 空间 visio services pre osc 自动 cas
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: xiaoqu
注意
获取所有namesapce
注意
管理pod的扩容和收缩。pod的生死归Deployments管。
services 本质上是通过pod的上的label selector 对一组pod进行汇总,路由分发,负载均衡等操作。
通过yaml创建的pod 不可通过修改yaml,修改pod的属性,只能删除pod,然后再去apply yaml 创建新的。
## 扩容
kubectl scale deployment nginx-deployment --replicas 10
## 自动拓展
kubectl autoscale deployment nginx-deployment --min=10 --max=15 --cpu-percent=80
## 更新镜像 还可以更新其他东西比如ENV,
kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1
## 回滚 可通过 --to-revision 指定版本
kubectl rollout undo deployment/nginx-deployment
## 查看版本记录
kubectl rollout history deployment
## 获取pods带着label
kubectl get pods --show-labels
## 获取运行着的service的yaml
kubectl get service hello-kube -o yaml
## pod 更新策略
kubectl get rs
apiVersion: v1
kind: Service
metadata:
name: hello-kube-d
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
selector:
app: hello-kube-d
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-kube-d
spec:
replicas: 1
selector:
matchLabels:
app: hello-kube-d
template:
metadata:
labels:
app: hello-kube-d
spec:
containers:
- name: hello-kube-d
image: paulbouwer/hello-kubernetes:1.8
ports:
- containerPort: 8080
env:
- name: MESSAGE
value: hello-kube-d
apiVersion: v1
kind: Pod
metadata:
name: hello-kube
spec:
hostNetwork: true
containers:
- name: hello-kube
image: paulbouwer/hello-kubernetes:1.8
ports:
- containerPort: 8080
env:
- name: MESSAGE
value: "hello-kube"
apiVersion: v1
kind: Namespace
metadata:
name: xiaoqu
apiVersion: v1
kind: ConfigMap
metadata:
name: hello-kube-config
labels:
name: hello
data:
MESSAGE: "message"
name: "hello"
标签:space lan 空间 visio services pre osc 自动 cas
原文地址:https://www.cnblogs.com/qulianqing/p/13404218.html