Kubernetes(k8s)存储资源的emptyDir Volume类型

1.部署一个redis的pod类型

# vi redis.yml

apiVersion: v1
kind: Pod
metadata:
  name: redis
spec:
  containers:
  - name: redis
    image: redis
    volumeMounts:
    - name: redis-storage
      mountPath: /data/redis
  volumes:
  - name: redis-storage
    emptyDir: {}


# kubectl apply -f redis.yml 

#以下是查看部署redis的等待时间
# kubectl get pod redis --watch
NAME    READY   STATUS              RESTARTS   AGE
redis   0/1     ContainerCreating   0          9s
redis   1/1     Running             0          19s

2.进入redis容器里面

# kubectl exec -it redis -- /bin/bash
root@redis:/data#

3.切换到 /data/redis 目录下,然后创建一个文件

root@redis:/data# cd /data/redis/
root@redis:/data/redis# echo Hello > test-file

4.更换国内镜像源

root@redis:/data/redis#cat >  /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian-security buster/updates main
deb-src http://mirrors.aliyun.com/debian-security buster/updates main
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
EOF


root@redis:/data/redis# apt-get update
Get:1 http://mirrors.aliyun.com/debian buster InRelease [122 kB]
Get:2 http://mirrors.aliyun.com/debian-security buster/updates InRelease [65.4 kB]
Get:3 http://mirrors.aliyun.com/debian buster-updates InRelease [49.3 kB]
Get:4 http://mirrors.aliyun.com/debian buster-backports InRelease [46.7 kB]
Get:5 http://mirrors.aliyun.com/debian buster/non-free Sources [86.3 kB]
Get:6 http://mirrors.aliyun.com/debian buster/contrib Sources [43.1 kB]
Get:7 http://mirrors.aliyun.com/debian buster/main Sources [7832 kB]
Get:8 http://mirrors.aliyun.com/debian buster/non-free amd64 Packages [88.0 kB]                                                               
Get:9 http://mirrors.aliyun.com/debian buster/main amd64 Packages [7907 kB]                                                                   
Get:10 http://mirrors.aliyun.com/debian buster/contrib amd64 Packages [51.0 kB]                                                               
Get:11 http://mirrors.aliyun.com/debian-security buster/updates/main Sources [102 kB]                                                         
Get:12 http://mirrors.aliyun.com/debian-security buster/updates/main amd64 Packages [177 kB]                                                  
Get:13 http://mirrors.aliyun.com/debian buster-updates/main Sources [2544 B]                                                                  
Get:14 http://mirrors.aliyun.com/debian buster-updates/main amd64 Packages [5792 B]                                                           
Get:15 http://mirrors.aliyun.com/debian buster-backports/non-free Sources [4160 B]                                                            
Get:16 http://mirrors.aliyun.com/debian buster-backports/contrib Sources [2372 B]                                                             
Get:17 http://mirrors.aliyun.com/debian buster-backports/main Sources [174 kB]                                                                
Get:18 http://mirrors.aliyun.com/debian buster-backports/contrib amd64 Packages [5232 B]                                                      
Get:19 http://mirrors.aliyun.com/debian buster-backports/main amd64 Packages [210 kB]                                                         
Get:20 http://mirrors.aliyun.com/debian buster-backports/non-free amd64 Packages [13.7 kB]                                                    
Fetched 17.0 MB in 17s (1019 kB/s)                                                                                                            
Reading package lists... Done

5.安装procps进程命令包,然后查看进程

root@redis:/data/redis#  apt-get install procps -y

root@redis:/data/redis#  ps aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
redis         1  0.3  0.1  40696 10128 ?        Ssl  14:19   0:11 redis-server *:6379
root        137  0.0  0.0   3856  2012 pts/0    Ss   15:09   0:00 /bin/bash
root        530  0.0  0.0   7628  1400 pts/0    R+   15:14   0:00 ps aux

 

你可能感兴趣的:(Kubernetes的学习)