赞
踩
资源对象管理实践
手工方式:
kubectl run pod名称 --image=image地址
资源清单方式:
apiVersion: v1
kind: Pod
metadata:
labels:
run: my-pod
name: my-pod
spec:
containers:
- image: kubernetes-register.sswang.com/sswang/nginx
name: my-pod
deployment资源实践
nginx-proxy应用的配置清单文件 apiVersion: apps/v1 kind: Deployment metadata: name: sswang-nginx-proxy labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: kubernetes-register.sswang.com/sswang/nginx ports: - containerPort: 80
nginx-web 的资源清单文件 apiVersion: apps/v1 kind: Deployment metadata: name: sswang-nginx-web labels: app: nginx-web spec: replicas: 1 selector: matchLabels: app: nginx-web template: metadata: labels: app: nginx-web spec: containers: - name: nginx image: kubernetes-register.sswang.com/sswang/nginx_web:v0.1 ports: - containerPort: 80
tomcat-web 的资源清单文件 apiVersion: apps/v1 kind: Deployment metadata: name: sswang-tomcat-web labels: app: tomcat-web spec: replicas: 1 selector: matchLabels: app: tomcat-web template: metadata: labels: app: tomcat-web spec: containers: - name: tomcat image: kubernetes-register.sswang.com/sswang/tomcat_web:v0.1 ports: - containerPort: 8080
namespace资源对象实践 apiVersion: v1 kind: Namespace metadata: name: my-ns --- apiVersion: apps/v1 kind: Deployment metadata: name: sswang-tomcat-web namespace: my-ns labels: app: tomcat-web spec: replicas: 1 selector: matchLabels: app: tomcat-web template: metadata: labels: app: tomcat-web spec: containers: - name: tomcat image: kubernetes-register.sswang.com/sswang/tomcat_web:v0.1 ports: - containerPort: 8080
资源对象扩缩容
kubectl scale deployment 资源对象名称 --replicas=目标数量 deployment/mysql
修改应用镜像版本
kubectl set image deployment 资源对象名称 容器名称=镜像名称
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。