kubernetes 知识点及常用命令
一、附上一个Deployment文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.8
ports:
- containerPort: 80
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: nginx-vol
volumes:
- name: nginx-vol
emptyDir: {}
kubernetes常用命令
- 创建一个资源
- kubectl creat -f 配置文件.yaml
- kubectl apply -f 配置文件.yaml (不明白这两个有什么区别)
- 查看当前pod的信息
- kubctl get pods
- kubectl get pods -l app=nginx
- 查看详细信息
- kubectl describe pod pod名
- 进入当前pod(即容器的namespace)
- kubectl exec -it pod名 -- /bin/sh
- 删除当前Deployment
- kubectl delete -f nginx.yaml