本环境用于验证k8s+virtual-kubelet+openstack zun
k8s集群有3个master,一个普通node,两个virtual-kubenet node
# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-m1 Ready master 23d v1.17.0 192.168.1.172 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://19.3.5
k8s-m2 Ready master 23d v1.17.0 192.168.1.151 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://19.3.5
k8s-m3 Ready master 23d v1.17.0 192.168.1.235 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://19.3.5
k8s-n1 Ready <none> 23d v1.17.0 192.168.1.59 <none> CentOS Linux 7 (Core) 3.10.0-1062.el7.x86_64 docker://19.3.5
virtual-kubelet Ready agent 2d20h v1.14.3-vk-openstack-zun-781b46a-dev <none> <none> <unknown> <unknown> <unknown>
virtual-kubelet1 Ready agent 20h v1.14.3-vk-openstack-zun-781b46a-dev <none> <none> <unknown> <unknown> <unknown>
通过openstack-cloud-controller-manager插件对接OpenStack cinder,用于为pod创建cinder pv
# kubectl apply -f sc.yaml
# cat sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: standard
provisioner: kubernetes.io/cinder
# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
standard kubernetes.io/cinder Delete Immediate false 23d
[root@k8s-m1 test]# kubectl describe sc standard
Name: standard
IsDefaultClass: No
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"standard"},"provisioner":"kubernetes.io/cinder"}
Provisioner: kubernetes.io/cinder
Parameters: <none>
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: Immediate
Events: <none>
# kubectl apply -f testpvc.yaml
# cat testpvc.yaml
apiVersion: v1
kind: Pod
metadata:
name: testpvcpod
spec:
containers:
- name: busybox-pvc
image: busybox
imagePullPolicy: IfNotPresent
volumeMounts:
- name: testpv
mountPath: /home
volumes:
- name: testpv
persistentVolumeClaim:
claimName: testpvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: testpvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
storageClassName: standard
pod已经创建成功
# kubectl get pods
NAME READY STATUS RESTARTS AGE
testpvcpod 1/1 Running 0 4m29s
pv和pvc状态正常
# kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-c9e46b6b-cd52-474d-9835-8f5757ac5ec7 2Gi RWO Delete Bound default/te stpvc standard 8m29s
# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
testpvc Bound pvc-c9e46b6b-cd52-474d-9835-8f5757ac5ec7 2Gi RWO standard 26m
openstack volume信息
# openstack volume list
+--------------------------------------+----------------------------------------------------------------- ------------------------------+-----------+------+------------------------------------------------------- --------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+----------------------------------------------------------------- ------------------------------+-----------+------+------------------------------------------------------- --------+
| 9ac04a59-146c-4300-9030-58c1e153c2f1 | kubernetes-dynamic-pvc-c9e46b6b-cd52-474d-9835-8f5757ac5ec7 | available | 2 |