k8s combat micro injection configuration information aspnetcore.webapi service - kubernetes

1. On k8s configuration information


  • Secret()

     Stored as encrypted data it can be used to store sensitive information, such as: OAuth tokens, private keys, passwords, database connection, the event bus connections, and so require secure storage of private data.

  • configMap

    The data stored in the form of plain text, can be used to hold some of the non-sensitive information, such as: configuration information of the application.

     k8s provide for the Secret and ConfigMap four ways to create a (literal, files, environment files, yaml), in fact categorized view is created in two ways, literal and files.

   1.1 How injected into the micro-service application?

     k8s already provides two ways for us, that is injected through the storage volume (volume) and the way the environment variables to the micro-service applications.

2, the real purpose


      Environmentally variables will k8s ConfigMap in the application configuration information stored in the micro-injected into the service. This is Microsoft's micro Services sample application (eshopOnContainer) methods used. Otherwise, I hope you go on your own combat.

3, the preparation of the resource file yaml


     ConfigMap resource file, appsetting.yml as follows:

     

       Above the red mark of what we need to configure the information injection.

       hello-world-deployment-with-settings.yml如下:

             

4. Create a resource object k8s   


 By dashboard view the cluster profile, Deployment resource object as follows:

ConfigMap resource object as follows:

 

5, run the micro-service check injection results


 

Can be seen from the above, the injection success! ! !

6, Postscript


         When we use the micro-service architecture to develop our application, how to manage these huge configuration information? How to achieve non-stop dynamic information to the micro-injection service? How to use configuration information and data storage mechanism k8s to decouple the configuration information with the micro-service applications? Stay tuned, we will examine each combat.

 

Next, we will combat how to make micro-aware service applications dynamically change the configuration information k8s management.

源码参考:https://github.com/justmine66/k8s.ecoysystem.apps

 

Guess you like

Origin www.cnblogs.com/webenh/p/11764999.html