1、环境信息

本环境用于验证k8s+virtual-kubelet+openstack zun

1.1、kubernetes集群信息

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>

1.2、ccm插件

通过openstack-cloud-controller-manager插件对接OpenStack cinder,用于为pod创建cinder pv

2、创建storageclass

2.1、创建sc

# kubectl apply -f sc.yaml
# cat sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard
provisioner: kubernetes.io/cinder

2.2、查看sc信息

# 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>

3、创建带动态pv的pod

3.1、部署pod

# 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

3.2、查看信息

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 |  
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐