创建namesapce
kubectl create namespace {name}
注意:name只能为小写字母、数字和-的组合,且开头结尾为字母,一般格式为my-name 123-abc等。
创建deployments
(1)利用文件创建deployment
编辑deployment.yml文件
kubectl create -f deployment.yml
deployment的格式为
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
namespace: namespace
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
查询
kubectl get deployments -n=taskmanger-beta
kubectl get pods -n=taskmanager-beta
kubectl exec -it manager-3459460258-hsbkr /bin/bash -n=taskmanager-beta
YAML中的kind种类
Deployments
Service
Ingress
Secret
Pod