denverdino / lxcfs-admission-webhook

Apache License 2.0
159 stars 81 forks source link

安装部署完成,但没有成功,free依然是获得宿主机资源 #21

Open fjibj opened 2 years ago

fjibj commented 2 years ago

kubectl get po

NAME READY STATUS RESTARTS AGE centosvnc-4-0 1/1 Running 0 58m centosvnc-5-0 1/1 Running 0 58m centosvnc-6-0 1/1 Running 0 58m lxcfs-mlwnz 1/1 Running 1 3h lxcfs-p9sk9 1/1 Running 0 3h lxcfs-pnkzd 1/1 Running 0 3h

kubectl exec -it lxcfs-mlwnz sh

sh-4.2# free total used free shared buff/cache available Mem: 16431920 14309100 429176 393920 1693644 1293868 Swap: 0 0 0 sh-4.2#

arsenalpoll commented 2 years ago

@fjibj
你label 打了吗? 还有镜像的操作系统是啥。有的操作系统是无效的~

fjibj commented 2 years ago

k8s v1.19.0,containerd运行时.,直接跑的你这个项目的例子

[root@k8s-master01 lxcfs-admission-webhook]# kubectl label namespace default lxcfs-admission-webhook=enabled
namespace/default labeled

[root@k8s-master01 lxcfs-admission-webhook]# kubectl apply -f deployment/lxcfs-daemonset.yaml
daemonset.apps/lxcfs created

[root@k8s-master01 lxcfs-admission-webhook]# deployment/install.sh
creating certs in tmpdir /tmp/tmp.N2rVxHU1n1 
Generating RSA private key, 2048 bit long modulus
.........................+++
......+++
e is 65537 (0x10001)
Warning: certificates.k8s.io/v1beta1 CertificateSigningRequest is deprecated in v1.19+, unavailable in v1.22+; use certificates.k8s.io/v1 CertificateSigningRequest
certificatesigningrequest.certificates.k8s.io/lxcfs-admission-webhook-svc.default created
NAME                                  AGE   SIGNERNAME                     REQUESTOR          CONDITION
lxcfs-admission-webhook-svc.default   0s    kubernetes.io/legacy-unknown   kubernetes-admin   Pending
certificatesigningrequest.certificates.k8s.io/lxcfs-admission-webhook-svc.default approved
W0309 14:43:25.647581    9987 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
secret/lxcfs-admission-webhook-certs created
NAME                            TYPE     DATA   AGE
lxcfs-admission-webhook-certs   Opaque   2      0s
deployment.apps/lxcfs-admission-webhook-deployment created
service/lxcfs-admission-webhook-svc created
Warning: admissionregistration.k8s.io/v1beta1 MutatingWebhookConfiguration is deprecated in v1.16+, unavailable in v1.22+; use admissionregistration.k8s.io/v1 MutatingWebhookConfiguration
mutatingwebhookconfiguration.admissionregistration.k8s.io/mutating-lxcfs-admission-webhook-cfg created

[root@k8s-master01 lxcfs-admission-webhook]# kubectl apply -f deployment/web.yaml
deployment.apps/web created

[root@k8s-master01 lxcfs-admission-webhook]# kubectl get pod -o wide
NAME                                                 READY   STATUS    RESTARTS   AGE     IP             NODE           NOMINATED NODE   READINESS GATES
lxcfs-admission-webhook-deployment-845cdc8c6-fbj54   1/1     Running   0          7m8s    10.244.1.22    k8s-node02     <none>           <none>
lxcfs-c8x2q                                          1/1     Running   0          9m39s   10.244.1.21    k8s-node02     <none>           <none>
lxcfs-mj7t4                                          1/1     Running   0          9m39s   10.244.0.4     k8s-master01   <none>           <none>
lxcfs-w7hwj                                          1/1     Running   0          9m39s   10.244.2.126   k8s-node01     <none>           <none>
simple                                               1/1     Running   0          12d     10.244.1.18    k8s-node02     <none>           <none>
web-fdf588795-bv2xd                                  1/1     Running   0          95s     10.244.2.127   k8s-node01     <none>           <none>
web-fdf588795-mj5g8                                  1/1     Running   0          95s     10.244.1.23    k8s-node02     <none>           <none>

[root@k8s-master01 lxcfs-admission-webhook]# kubectl exec -ti web-fdf588795-bv2xd sh
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
# free
             total       used       free     shared    buffers     cached
Mem:    16400240    6959996    9440244       1976       3336    4781588
-/+ buffers/cache:    2175072   14225168
Swap:            0          0          0
# 

容器内部显示的仍然是宿主机的内存信息,什么问题?

fjibj commented 2 years ago

换了个k8s v1.15.12的环境,直接用首页的sample,顺利通过。