1 应用管理解读
2 应用部署实践
资源对象管理关系
资源对象管理实践
手工方式:
kubectl run pod名称 --image=image地址
资源清单方式:
apiVersion: v1
kind: Pod
metadata:labels:run: my-podname: my-pod
spec:containers:- image: kubernetes-register.sswang.com/sswang/nginxname: my-pod
deployment资源实践
nginx-proxy应用的配置清单文件
apiVersion: apps/v1
kind: Deployment
metadata:name: sswang-nginx-proxylabels:app: nginx
spec:replicas: 1selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: kubernetes-register.sswang.com/sswang/nginxports:- containerPort: 80
nginx-web 的资源清单文件
apiVersion: apps/v1
kind: Deployment
metadata:name: sswang-nginx-weblabels:app: nginx-web
spec:replicas: 1selector:matchLabels:app: nginx-webtemplate:metadata:labels:app: nginx-webspec:containers:- name: nginximage: kubernetes-register.sswang.com/sswang/nginx_web:v0.1ports:- containerPort: 80
tomcat-web 的资源清单文件
apiVersion: apps/v1
kind: Deployment
metadata:name: sswang-tomcat-weblabels:app: tomcat-web
spec:replicas: 1selector:matchLabels:app: tomcat-webtemplate:metadata:labels:app: tomcat-webspec:containers:- name: tomcatimage: kubernetes-register.sswang.com/sswang/tomcat_web:v0.1ports:- containerPort: 8080
3 应用管理实践
资源对象隔离
namespace资源对象实践
apiVersion: v1
kind: Namespace
metadata:name: my-ns
---
apiVersion: apps/v1
kind: Deployment
metadata:name: sswang-tomcat-webnamespace: my-nslabels:app: tomcat-web
spec:replicas: 1selector:matchLabels:app: tomcat-webtemplate:metadata:labels:app: tomcat-webspec:containers:- name: tomcatimage: kubernetes-register.sswang.com/sswang/tomcat_web:v0.1ports:- containerPort: 8080
资源对象的扩缩容
资源对象扩缩容
kubectl scale deployment 资源对象名称 --replicas=目标数量 deployment/mysql修改应用镜像版本
kubectl set image deployment 资源对象名称 容器名称=镜像名称