文章摘要: 摘要内容。
创建Kubernetes对象时,必须提供对象的规定和约束,用来描述该对象的期望状态,以及对象的一些基本信息。
属性
apiVersion:创建该对象所使用的kubernetes API的版本。kind:创建的对象的类别。Metadata:描述对象的唯一性标识。Spec:该对象的期望状态。
案例
Kubernetes应用编排与管理
Deployment管理
创建一个例如nginx.yaml的yaml文件,并编写相关属性。
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
从yaml文件创建deployment对象
kubectl apply -f nginx.yaml