github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/docs/setup/kubeedge_configure.md (about)

     1  # KubeEdge Configuration
     2  
     3  KubeEdge requires configuration on both [Cloud side (KubeEdge Master)](#configuration-cloud-side-kubeedge-master) and [Edge side (KubeEdge Worker Node)](#configuration-edge-side-kubeedge-worker-node)
     4  
     5  ## Configuration Cloud side (KubeEdge Master)
     6  
     7  Setting up cloud side requires two steps
     8  
     9  1. [Modification of the configuration files](#modification-of-the-configuration-file)
    10  2. Edge node will be auto registered by default. [Users can still choose to register manually](#adding-the-edge-nodes-kubeedge-worker-node-on-the-cloud-side-kubeedge-master).
    11  
    12  ### Modification of the configuration file
    13  
    14  Cloudcore requires changes in `cloudcore.yaml` configuration file.
    15  
    16  Create and set cloudcore config file
    17  
    18  Create the `/etc/kubeedge/config` folder
    19  
    20  ```shell
    21  # the default configuration file path is '/etc/kubeedge/config/cloudcore.yaml'
    22  # also you can specify it anywhere with '--config'
    23  mkdir -p /etc/kubeedge/config/
    24  ```
    25  
    26  Either create a minimal configuration with command `~/kubeedge/cloudcore --minconfig`
    27  
    28  ```shell
    29  
    30  ~/kubeedge/cloudcore --minconfig > /etc/kubeedge/config/cloudcore.yaml
    31  ```
    32  
    33  or a full configuration with command `~/kubeedge/cloudcore --defaultconfig`
    34  
    35  ```shell
    36  ~/kubeedge/cloudcore --defaultconfig > /etc/kubeedge/config/cloudcore.yaml
    37  ```
    38  
    39  Edit the configuration file
    40  
    41  ```shell
    42  vim /etc/kubeedge/config/cloudcore.yaml
    43  ```
    44  
    45  Verify the configurations before running `cloudcore`
    46  
    47  #### Modification in cloudcore.yaml
    48  
    49  In the cloudcore.yaml, modify the below settings.
    50  
    51  1. Either `kubeAPIConfig.kubeConfig` or `kubeAPIConfig.master` : This would be the path to your kubeconfig file. It might be either
    52  
    53      ```shell
    54      /root/.kube/config
    55      ```
    56  
    57      or
    58  
    59      ```shell
    60      /home/<your_username>/.kube/config
    61      ```
    62  
    63      depending on where you have setup your kubernetes by performing the below step:
    64  
    65      ```shell
    66      To start using your cluster, you need to run the following as a regular user:
    67  
    68      mkdir -p $HOME/.kube
    69      sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    70      sudo chown $(id -u):$(id -g) $HOME/.kube/config
    71      ```
    72  
    73      By default, cloudcore use https connection to Kubernetes apiserver. If `master` and `kubeConfig` are both set, `master` will override any value in kubeconfig.
    74  
    75  2. Check whether the cert files for `modules.cloudhub.tlsCAFile`, `modules.cloudhub.tlsCertFile`,`modules.cloudhub.tlsPrivateKeyFile` exists.
    76  
    77  ### Adding the edge nodes (KubeEdge Worker Node) on the Cloud side (KubeEdge Master)
    78  
    79  Node registration can be completed in two ways:
    80  
    81  1. Node - Automatic Registration
    82  2. Node - Manual Registration
    83  
    84  #### Node - Automatic Registration
    85  
    86  Edge node can be registered automatically if the value of field `modules.edged.registerNode` in edgecore's config [edgecore config file](https://github.com/kubeedge/kubeedge/blob/master/docs/setup/kubeedge_configure.md#create-and-set-edgecore-config-file) is set to true.
    87  
    88  ```yaml
    89  modules:
    90    edged:
    91      registerNode: true
    92  ```
    93  
    94  #### Node - Manual Registration
    95  
    96  Refer [here](deploy-edge-node.md) to add edge nodes.
    97  
    98  #### Check the existence of certificates (cloud side)
    99  
   100  RootCA certificate and a cert/key pair is required to have a setup for KubeEdge. Same cert/key pair can be used in both cloud and edge.
   101  
   102  cert/key should exist in /etc/kubeedge/ca and /etc/kubeedge/certs. Otherwise please refer to [generate certs](https://github.com/kubeedge/kubeedge/blob/master/docs/setup/kubeedge_install_source.md#generate-certificates) to generate them.
   103  You need to copy these files to the corresponding directory on edge side.
   104  
   105  Create the `certs.tgz` by
   106  
   107  ```shell
   108  cd /etc/kubeedge
   109  tar -cvzf certs.tgz certs/
   110  ```
   111  
   112  #### Transfer certificate file from the cloud side to edge side
   113  
   114  Transfer certificate files to the edge node, because `edgecore` uses these certificate files to connect to `cloudcore`
   115  
   116  This can be done by utilising scp
   117  
   118  ```shell
   119  cd /etc/kubeedge/
   120  scp certs.tgz username@destination:/etc/kubeedge
   121  ```
   122  
   123  Here, we are copying the certs.tgz from the cloud side to the edge node in the /etc/kubeedge directory. You may copy in any directory and then move the certs to /etc/kubeedge folder.
   124  
   125  At this point we have completed all configuration changes related to cloudcore.
   126  
   127  ## Configuration Edge side (KubeEdge Worker Node)
   128  
   129  ### Manually copy certs.tgz from cloud host to edge host(s)
   130  
   131  On edge host
   132  
   133  ```shell
   134  mkdir -p /etc/kubeedge
   135  ```
   136  
   137  On edge host untar the certs.tgz file
   138  
   139  ```shell
   140  cd /etc/kubeedge
   141  tar -xvzf certs.tgz
   142  ```
   143  
   144  ### Create and set edgecore config file
   145  
   146  Create the `/etc/kubeedge/config` folder
   147  
   148  ```shell
   149  
   150      # the default configration file path is '/etc/kubeedge/config/edgecore.yaml'
   151      # also you can specify it anywhere with '--config'
   152      mkdir -p /etc/kubeedge/config/
   153  ```
   154  
   155  Either create a minimal configuration with command `~/kubeedge/edgecore --minconfig`
   156  
   157  ```shell
   158      ~/kubeedge/edgecore --minconfig > /etc/kubeedge/config/edgecore.yaml
   159  ```
   160  
   161  or a full configuration with command `~/kubeedge/edgecore --defaultconfig`
   162  
   163  ```shell
   164  ~/kubeedge/edgecore --defaultconfig > /etc/kubeedge/config/edgecore.yaml
   165  ```
   166  
   167  Edit the configuration file
   168  
   169  ```shell
   170      vim /etc/kubeedge/config/edgecore.yaml
   171  ```
   172  
   173  Verify the configurations before running `edgecore`
   174  
   175  #### Modification in edgecore.yaml
   176  
   177  1. Check `modules.edged.podSandboxImage` : This is very important and must be set correctly.
   178  
   179     To check the architecture of your machine run the following
   180  
   181      ```shell
   182      getconf LONG_BIT
   183      ```
   184  
   185      + `kubeedge/pause-arm:3.1` for arm arch
   186      + `kubeedge/pause-arm64:3.1` for arm64 arch
   187      + `kubeedge/pause:3.1` for x86 arch
   188  
   189  2. Check whether the cert files for `modules.edgehub.tlsCaFile` and `modules.edgehub.tlsCertFile` and `modules.edgehub.tlsPrivateKeyFile` exists. If those files not exist, you need to copy them from cloud side.
   190  
   191  3. Update the IP address and port of the KubeEdge CloudCore in the `modules.edgehub.websocket.server` and `modules.edgehub.quic.server` field. You need set cloudcore ip address.
   192  
   193  4. Configure the desired container runtime to be used as either docker or remote (for all CRI based runtimes including containerd). If this parameter is not specified docker runtime will be used by default
   194  
   195      ```yaml
   196      runtimeType: docker
   197      ```
   198  
   199      or
   200  
   201      ```yaml
   202      runtimeType: remote
   203      ```
   204  
   205  5. If your runtime-type is remote, specify the following parameters for remote/CRI based runtimes
   206  
   207      ```yaml
   208      remoteRuntimeEndpoint: /var/run/containerd/containerd.sock
   209      remoteImageEndpoint: /var/run/containerd/containerd.sock
   210      runtimeRequestTimeout: 2
   211      podSandboxImage: k8s.gcr.io/pause
   212      kubelet-root-dir: /var/run/kubelet/
   213      ```
   214  
   215  #### Configuring MQTT mode
   216  
   217  The Edge part of KubeEdge uses MQTT for communication between deviceTwin and devices. KubeEdge supports 3 MQTT modes (`internalMqttMode`, `bothMqttMode`, `externalMqttMode`), set `mqttMode` field in edgecore.yaml to the desired mode.
   218  + internalMqttMode: internal mqtt broker is enabled (`mqttMode`=0).
   219  + bothMqttMode: internal as well as external broker are enabled (`mqttMode`=1).
   220  + externalMqttMode: only external broker is enabled (`mqttMode`=2).
   221  
   222  To use KubeEdge in double mqtt or external mode, you need to make sure that mosquitto or emqx edge is installed on the edge node as an MQTT Broker.
   223  
   224  At this point we have completed all configuration changes related to edgecore.