---
# System prepended metadata

title: Untitled

---

在host cluster上装kubeedge的cloudcore，然后 用real node all的模式启动一个vcluster，然后往host上添加边缘节点，看看vcluster里面能不能看到添加的边缘节点，能看到的话，能不能往边缘节点上调度一个niginx

下载vcluster
```

curl -L -o vcluster "https://github.com/loft-sh/vcluster/releases/latest/download/vcluster-linux-amd64" && sudo install -c -m 0755 vcluster /usr/local/bin
```
看一下vcluster有哪些
```
root@kubeedge:~# vcluster list

 NAME          NAMESPACE              STATUS    CONNECTED   CREATED                         AGE
 my-vcluster   vcluster-my-vcluster   Running               2022-10-18 15:35:21 +0800 CST   48h42m3s


```
删除原来的vcluster

```
vcluster disconnect

vcluster delete my-vcluster
```
新建value.yaml
```
sync:
  nodes:
    enabled: true
    syncAllNodes: true
  persistentvolumes:
    enabled: true
  # If you want to create custom storage classes
  # inside the vcluster.
  storageclasses:
    enabled: true

```
创建vcluster集群
```
vcluster create my-vcluster --kubernetes-version v1.21 --distro k8s  -f values.yaml
```
在vcluster集群中：

```
root@vrcluster:~# kubectl get pods -A
NAMESPACE     NAME                       READY   STATUS    RESTARTS   AGE
kube-system   coredns-749456dcbf-vfz9s   1/1     Running   0          8m41s

```
在这里部署sc，这里需要name和外部sc一致。其实vcluster中sc本质上还是使用外部的sc，所以其他配置选项都可以随便填，我这里导出的是host集群的sc。主要是为了ks-installer中检测sc是否存在，防止安装失败
```
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    cas.openebs.io/config: |
      - name: StorageType
        value: "hostpath"
      - name: BasePath
        value: "/var/openebs/local/"
    openebs.io/cas-type: local
    storageclass.beta.kubernetes.io/is-default-class: "true"
    storageclass.kubernetes.io/is-default-class: "true"
    storageclass.kubesphere.io/supported-access-modes: '["ReadWriteOnce"]'
  creationTimestamp: "2022-10-24T07:09:18Z"
  name: local
  resourceVersion: "433221"
  uid: 595cda9a-f85d-4dfc-a83c-fcb9e63a6a02
provisioner: openebs.io/local
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer

```
部署ks

```
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.0/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.0/cluster-configuration.yaml
```

```
kubectl edit cc -n kubesphere-system
```
把这个端口改一下，因为是nodeport，要不然sync会显示端口被占用。
```
common:
    core:
      console:
        enableMultiLogin: true
        port: 30885
        type: NodePort

```
这是可以通过ip:30885访问vcluster的集群了。


部署边缘节点，进入vcluster集群,可以看到node节点（注意vrcluster是host集群的，边缘是1.21）

```
NAME            STATUS   ROLES                         AGE    VERSION
edgenode-z1h8   Ready    agent,edge                    114s   v1.21.4-kubeedge-v1.9.2
vrcluster       Ready    control-plane,master,worker   70m    v1.22.10
```

部署一个nginx

```
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
  nodeName: edgenode-z1h8

```
```

root@vrcluster:~# kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          119m

```


在vcluster集群中，查看pod，并没有该边缘节点pod

```
root@vrcluster:~# kubectl get pods -A
NAMESPACE                      NAME                                               READY   STATUS    RESTARTS   AGE
kube-system                    coredns-749456dcbf-qnx85                           1/1     Running   0          3h23m
kube-system                    snapshot-controller-0                              1/1     Running   0          3h18m
kubesphere-controls-system     default-http-backend-5bf68ff9b8-k5vdp              1/1     Running   0          3h11m
kubesphere-controls-system     kubectl-admin-6667774bb-f279l                      1/1     Running   0          3h2m
kubesphere-monitoring-system   alertmanager-main-0                                2/2     Running   0          3h5m
kubesphere-monitoring-system   kube-state-metrics-7bdc7484cf-v825t                3/3     Running   0          3h5m
kubesphere-monitoring-system   node-exporter-vlbvm                                0/2     Pending   0          3h5m
kubesphere-monitoring-system   notification-manager-deployment-78664576cb-2cpvs   2/2     Running   0          3h3m
kubesphere-monitoring-system   notification-manager-operator-7d44854f54-8xxpk     2/2     Running   1          3h4m
kubesphere-monitoring-system   prometheus-k8s-0                                   2/2     Running   0          3h5m
kubesphere-monitoring-system   prometheus-operator-8955bbd98-6zzrr                2/2     Running   0          3h5m
kubesphere-system              ks-apiserver-7c8c448bbb-gqwp5                      1/1     Running   0          3h11m
kubesphere-system              ks-console-54bd5bcbc6-58qwj                        1/1     Running   0          3h11m
kubesphere-system              ks-controller-manager-bdbb456f4-jvrhd              1/1     Running   2          3h11m
kubesphere-system              ks-installer-6976cf49f5-h5vr8                      1/1     Running   0          3h19m


```


总结：在host cluster上装kubeedge的cloudcore，然后 用real node all的模式启动一个vcluster，然后往host上添加边缘节点，vcluster里面可以看到添加的边缘节点，但不能查看到边缘节点的pod


环境地址：
http://172.31.73.206:30880/clusters/default/edgenodes
账号admin
密码 P@88w0rd

