apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox1
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
      - args:
        - "36000"
        command:
        - sleep
        image: alpine
        imagePullPolicy: IfNotPresent
        name: busybox
      dnsPolicy: ClusterFirst

 容器里有ping和nslookup功能

 

优化:挂载版,可以执行mc、psql等命令

apiVersion: v1
kind: PersistentVolume
metadata:
  name: databasebak
spec:
  capacity:
    storage: 800G
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /opt/databasebak  # 宿主机上的目录
    type: DirectoryOrCreate  # 如果目录不存在,则创建它

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: databasebak
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 800G

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: databak
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
      - args:
        - "36000"
        command:
        - sleep
        image: registry.cn-hangzhou.aliyuncs.com/mytest_docker123/busybox:mc-pg
        imagePullPolicy: IfNotPresent
        name: busybox
        volumeMounts:
        - mountPath: /dabasebak
          name: databasebak
      dnsPolicy: ClusterFirst
      volumes:
      - name: databasebak
        persistentVolumeClaim:
          claimName: databasebak
View Code

 

注:镜像拉不动,用:

registry.cn-hangzhou.aliyuncs.com/mytest_docker123/alpine
 registry.cn-hangzhou.aliyuncs.com/mytest_docker123/busybox:mc-pg