高级
Nocalhost's development configuration supports multiple developing ways, such as ConfigMap, Annotations, etc.
In fact, these configuration methods also suit for deployment configuration. Buts some functions need to be implemented through the K8s Admission WebHook. In Nocalhost, a component called Nocalhost-Dep
plays this role, and Nocalhost Server
will automatically deploy this component for you.
if you do not use Nocalhost Server
, then additional deployment of Nocalhost Dep
is required.
info
What deployment configurations does Nocalhost provide? introduces which deployment configurations require additional deployment of Nocalhost Dep
.
#
使用 ConfigMap 配置部署配置To make a simple deployment configuration is mentioned in Introduction to Deployment Configuration --- Nocalhost Basic Deployment Configuration. Combining with What configuration methods are supported by Nocalhost-place the configuration in configmap, we can get the configuration:
We have prepared an demo for this, which will automatically deploy Nocalhost Dep
, and use the way of ConfigMap to make the deployment configuration.
Using the following commands to try out this demo (trying the Chart package requires ClusterAdmin)
Then use Helm to install:
The content of the deployment configuration itself will not be repeated here. let's take a look at charts/bookinfo/templates/nocalhost-app-config.yaml
.
danger
This ConfigMap requires to apply to Api Server first. For example, in the Helm application scenario, it should be declared as pre-install
.
It introduces .Values.nocalhost.config.path
to render the main body of the deployment configuration. The configuration is actually declared in ./charts/bookinfo/example/config-from-cm/nocalhost-full-config.yaml
, which is a standard Nocalhost deployment configuration without any additional modification:
#
使用 Annotations 配置部署配置The method of usage is exactly the same as Which configuration methods Nocalhost supports-place the configuration in annotations.
Extra attention
Since Annotations closely follow the workload, some configurations at the application level are not supported. Only the configurations under application.services
is supported.
Again, use the same demo project:
Use the following commands to get and try out this project (trying the Chart package requires ClusterAdmin)
Then use Helm to install:
We specified values-annotation-config.yaml
as Values.yaml, which specifies the rendering of the local configuration file to the Annotations of the workload. Take ./charts/bookinfo/templates/microservice-details.yaml
as an example:
Helm will render the path configured by .Values.nocalhost.annotations.path.details
into yaml, whose content is as follows, that is, ./charts/bookinfo/example/config-from-annotations/details.yaml
specified in Values :
Nocalhost Dep
#
如何部署 We recommend using Nocalhost Server
to get all the functions of Nocalhost Dep
.
danger
COMING SOON