github.com/oam-dev/kubevela@v1.9.11/docs/examples/traits/control-plane-only-usecase/README.md (about)

     1  # How to use controlPlaneOnly
     2  
     3  In this section, I'll illustrate by an example how to controlPlaneOnly.
     4  
     5  ## Prerequisites
     6  
     7  1. You have installed KubeVela
     8  2. You can access several Kubernetes cluster(remotely or locally like `kind` or `minikube`) via `vela cluster join xxx`
     9  
    10  ## Steps
    11  
    12  ### Apply trait with controlPlaneOnly
    13  
    14  In [control-plane-only-usecase.cue](./control-plane-only-usecase.cue), you'll see a `controlPlaneOnly` field in `attributes`, which shows that whether resources generated by trait are dispatched to the hubcluster `local`.
    15  
    16  apply the cue file in cluster
    17  
    18  ```shell
    19  vela def apply control-plane-only-usecase.cue
    20  ```
    21  
    22  ### Apply the application
    23  In [app-with-control-plane-only-usecase.yaml](./app-with-control-plane-only-usecase.yaml), you'll see a application with trait `hubcluster`
    24  
    25  Just apply the file in cluster.
    26  ```shell
    27  kubectl apply -f app-with-control-plane-only-usecase.yaml
    28  ```
    29  
    30  ### Check the application
    31  
    32  the application in the cluster is rendered into resources like `pod`, `hpa`.
    33  
    34  Try to describe the pod in `cluster01`:
    35  ```shell
    36  $ kubectl get pod
    37  NAME                                                        READY   STATUS    RESTARTS   AGE
    38  app-with-control-plane-only-component-01-66bd996fd7-xlwsh   1/1     Running   0          18s
    39  ```
    40  
    41  Try to describe the pod in `cluster02`:
    42  ```shell
    43  $ kubectl get pod
    44  NAME                                                        READY   STATUS    RESTARTS   AGE
    45  app-with-control-plane-only-component-01-66bd996fd7-p66rv   1/1     Running   0          18s
    46  ```
    47  
    48  Try to describe the hpa in `local`:
    49  ```shell
    50  $ kubectl get hpa
    51  NAME                                       READY   STATUS    RESTARTS   AGE
    52  app-with-control-plane-only-component-01   1/1     Running   0          18s
    53  ```
    54  
    55  You'll see the pod is running without any errors and hpa is running in `local`.