kubectl api-resources
查看资源名称和对应的缩写。如namespaces的简写是ns,nodes的简写是no。
ReplicaSet
创建一个replicaset.yaml文件,以yaml的方式启动一个ReplicaSet。
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
#modify replicas according to your case
replicas: 4
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: nginx:1.7.9
spec.replicas属性设置了创建pod的数量。
kubectl scale --replicas=3 -f replicaset.yaml
scale用于扩容和缩容。
kubectl describe rs frontend
查看ReplicaSet的描述信息。