Integrating the Apollo configuration center in the kubernetes cluster

productive practice

1. iteration of new requirements / bug repair (code -- > git)

2. test environment release and testing (applications are released to the test namespace through compilation and packaging)

3. pass the test and go online (the application image is directly published to the prod namespace)

system architecture

(1) Physical architecture

host name role IP address
mfyxw10.mfyxw.com ZK test (test environment) 192.168.80.10
mfyxw20.mfyxw.com ZK prod (production environment prod) 192.168.80.20
mfyxw30.mfyxw.com kubernetes operation node 192.168.80.30
mfyxw40.mfyxw.com kubernetes operation node 192.168.80.40
mfyxw50.mfyxw.com Operation and maintenance host, harbor warehouse 192.168.80.50

(2) System architecture in k8s

environment Namespace application
Test environment (TEST) test apollo-config, apollo-admin
Test environment (TEST) test dubbo-demo-service, dubbo-demo-web
Production environment (PROD) prod apollo-config, apollo-admin
Production environment (PROD) prod dubbo-demo-service, dubbo-demo-web
OPS environment (infra) infra jenkins, dubbo-monitor, apollo-portal

Note: the principle of Apollo sub environment:

1. to use Apollo, the portal service can share one set in each environment

2.adminservice and configservice each environment needs to deploy one set and the databases are different

3. the portal, adminservice and configservice have been created before the environment is divided. It is recommended to delete or use dashboard and set it to 0. If they have not been created, this can be ignored

1. add domain name resolution

In mfyxw10 Mfyxw Operation on COM host

(1) Add DNS domain name resolution

[root@mfyxw10 ~]# cat > /var/named/od.com.zone << EOF
\$ORIGIN od.com.
\$TTL 600   ; 10 minutes
@       IN  SOA dns.od.com.   dnsadmin.od.com. (
                             ;Please add 1 to the serial number, which means it is newer than the previous version
                             2020031313 ; serial
                             10800          ; refresh (3 hours)
                             900              ; retry (15 minutes)
                             604800         ; expire (1 week)
                             86400          ; minimum (1 day)
                              )
                      NS   dns.od.com.
\$TTL 60 ;  1 minute
dns             A          192.168.80.10
harbor          A          192.168.80.50   ;Add harbor record
k8s-yaml        A          192.168.80.50
traefik         A          192.168.80.100
dashboard       A          192.168.80.100
zk1             A          192.168.80.10
zk2             A          192.168.80.20
zk3             A          192.168.80.30
jenkins         A          192.168.80.100
dubbo-monitor   A          192.168.80.100
demo            A          192.168.80.100
mysql           A          192.168.80.10
config          A          192.168.80.100
portal          A          192.168.80.100
zk-test         A          192.168.80.10
zk-prod         A          192.168.80.20
config-test     A          192.168.80.100
config-prod     A          192.168.80.100
demo-test       A          192.168.80.100
demo-prod       A          192.168.80.100
EOF

(2) Restart DNS Service

[root@mfyxw10 ~]# systemctl restart named

(3) Test domain name resolution

[root@mfyxw10 ~]# dig -t A config-test.od.com @192.168.80.10 +short
192.168.80.100
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A config-test.od.com @192.168.80.10 +short
192.168.80.100
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A config-prod.od.com @192.168.80.10 +short
192.168.80.100
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A zk-test.od.com @192.168.80.10 +short
192.168.80.10
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A zk-prod.od.com @192.168.80.10 +short
192.168.80.20
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A demo-test.od.com @192.168.80.10 +short
192.168.80.100
[root@mfyxw10 ~]# 
[root@mfyxw10 ~]# dig -t A demo-prod.od.com @192.168.80.10 +short
192.168.80.100

2. create a namespace in the k8s cluster and connect the secret of the private warehouse

It can be executed on any of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

(1) Creating namespaces in a k8s cluster

[root@mfyxw30 ~]# kubectl create namespace test
namespace/test created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl create namespace prod
namespace/prod created

(2) Create secret

[root@mfyxw30 ~]# kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=admin --docker-password=Harbor12345 -n test
secret/harbor created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=admin --docker-password=Harbor12345 -n prod
secret/harbor created

3. I have deployed portal, adminservice and configservice in my original environment. I will delete them first

It can be executed on any of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-w9tzw   1/1     Running   0          4m51s
apollo-configservice-5f6555448-bcx22   1/1     Running   0          4m43s
apollo-portal-57bc86966d-4w5ld         1/1     Running   0          4m59s
dubbo-monitor-6676dd74cc-9hghb         1/1     Running   22         20d
dubbo-monitor-6676dd74cc-rd86g         1/1     Running   21         20d
jenkins-b99776c69-49dnr                1/1     Running   2          44h
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl delete -f http://k8s-yaml.od.com/apollo-adminservice/deployment.yaml
deployment.extensions "apollo-adminservice" deleted
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl delete -f http://k8s-yaml.od.com/apollo-configservice/deployment.yaml
deployment.extensions "apollo-configservice" deleted
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl delete -f http://k8s-yaml.od.com/apollo-portal/deployment.yaml
deployment.extensions "apollo-portal" deleted
[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                             READY   STATUS    RESTARTS   AGE
dubbo-monitor-6676dd74cc-9hghb   1/1     Running   22         20d
dubbo-monitor-6676dd74cc-rd86g   1/1     Running   21         20d
jenkins-b99776c69-49dnr          1/1     Running   2          44h

4. import the database script and authorization of each environment respectively

In mfyxw10 Mfyxw Operation on COM host

(1) The database script of the test environment is as follows (it is recommended to copy and paste the vi /root/apolloconfigtest.sql):

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

# Create Database
# ------------------------------------------------------------
CREATE DATABASE IF NOT EXISTS ApolloConfigTestDB DEFAULT CHARACTER SET = utf8mb4;

Use ApolloConfigTestDB;

# Dump of table app
# ------------------------------------------------------------

DROP TABLE IF EXISTS `App`;

CREATE TABLE `App` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Application name',
  `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'department Id',
  `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Department name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId` (`AppId`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_Name` (`Name`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Application table';



# Dump of table appnamespace
# ------------------------------------------------------------

DROP TABLE IF EXISTS `AppNamespace`;

CREATE TABLE `AppNamespace` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'namespace Name, please note that it needs to be globally unique',
  `AppId` varchar(32) NOT NULL DEFAULT '' COMMENT 'app id',
  `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT 'annotation',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_AppId` (`AppId`),
  KEY `Name_AppId` (`Name`,`AppId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='application namespace definition';



# Dump of table audit
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Audit`;

  `EntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT 'Table name',
  `EntityId` int(10) unsigned DEFAULT NULL COMMENT 'record ID',
  `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT 'Operation type',
  `Comment` varchar(500) DEFAULT NULL COMMENT 'Remarks',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Log audit table';



# Dump of table cluster
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Cluster`;

CREATE TABLE `Cluster` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'Cluster name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_AppId_Name` (`AppId`,`Name`),
  KEY `IX_ParentClusterId` (`ParentClusterId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='colony';



# Dump of table commit
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Commit`;

CREATE TABLE `Commit` (
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `Comment` varchar(500) DEFAULT NULL COMMENT 'Remarks',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `AppId` (`AppId`(191)),
  KEY `ClusterName` (`ClusterName`(191)),
  KEY `NamespaceName` (`NamespaceName`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='commit History table';

# Dump of table grayreleaserule
# ------------------------------------------------------------

DROP TABLE IF EXISTS `GrayReleaseRule`;

CREATE TABLE `GrayReleaseRule` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `NamespaceName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name',
  `BranchName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'branch name',
  `Rules` varchar(16000) DEFAULT '[]' COMMENT 'Grayscale rule',
  `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Grayscale corresponding release',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_Namespace` (`AppId`,`ClusterName`,`NamespaceName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gray rule table';


# Dump of table instance
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Instance`;
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `AppId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `DataCenter` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Data Center Name',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_UNIQUE_KEY` (`AppId`,`ClusterName`,`Ip`,`DataCenter`),
  KEY `IX_IP` (`Ip`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Use configured application instances';



# Dump of table instanceconfig
# ------------------------------------------------------------

DROP TABLE IF EXISTS `InstanceConfig`;

CREATE TABLE `InstanceConfig` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `InstanceId` int(11) unsigned DEFAULT NULL COMMENT 'Instance Id',
  `ConfigAppId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Config App Id',
  `ConfigClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Config Cluster Name',
  `ReleaseDeliveryTime` timestamp NULL DEFAULT NULL COMMENT 'Configure acquisition time',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_UNIQUE_KEY` (`InstanceId`,`ConfigAppId`,`ConfigNamespaceName`),
  KEY `IX_ReleaseKey` (`ReleaseKey`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configuration information of application instance';



# Dump of table item
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Item`;

CREATE TABLE `Item` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `Value` longtext NOT NULL COMMENT 'Configuration item value',
  `Comment` varchar(1024) DEFAULT '' COMMENT 'annotation',
  `LineNum` int(10) unsigned DEFAULT '0' COMMENT 'Line number',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_GroupId` (`NamespaceId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configuration items';



# Dump of table namespace
# ------------------------------------------------------------

CREATE TABLE `Namespace` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId_ClusterName_NamespaceName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_NamespaceName` (`NamespaceName`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Namespace';



# Dump of table namespacelock
# ------------------------------------------------------------

DROP TABLE IF EXISTS `NamespaceLock`;

CREATE TABLE `NamespaceLock` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement id',
  `NamespaceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'colony NamespaceId',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT 'default' COMMENT 'Last modified by mailbox prefix',
  `IsDeleted` bit(1) DEFAULT b'0' COMMENT 'Soft delete',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_NamespaceId` (`NamespaceId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='namespace Edit lock for';



# Dump of table release
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Release`;

CREATE TABLE `Release` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `ReleaseKey` varchar(64) NOT NULL DEFAULT '' COMMENT 'Published Key',
  `Name` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Release name',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `Configurations` longtext NOT NULL COMMENT 'Publishing configuration',
  `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT 'Discard or not',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId_ClusterName_GroupName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_ReleaseKey` (`ReleaseKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='release';


# Dump of table releasehistory
# ------------------------------------------------------------

DROP TABLE IF EXISTS `ReleaseHistory`;

CREATE TABLE `ReleaseHistory` (
  `ClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `NamespaceName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `BranchName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Publish branch name',
  `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Associated Release Id',
  `PreviousReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Last published ReleaseId',
  `OperationContext` longtext NOT NULL COMMENT 'Publishing context information',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  KEY `IX_ReleaseId` (`ReleaseId`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Release history';


# Dump of table releasemessage
DROP TABLE IF EXISTS `ReleaseMessage`;

CREATE TABLE `ReleaseMessage` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Message` varchar(1024) NOT NULL DEFAULT '' COMMENT 'Published message content',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),




DROP TABLE IF EXISTS `ServerConfig`;

CREATE TABLE `ServerConfig` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `Key` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Configuration item Key',
  `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT 'Configuration item value',
  `Comment` varchar(1024) DEFAULT '' COMMENT 'annotation',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last modification time',
  PRIMARY KEY (`Id`),
  KEY `IX_Key` (`Key`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configure service self configuration';

# Config
# ------------------------------------------------------------
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`, `Comment`)
VALUES
    ('eureka.service.url', 'default', 'http://Localhost:8080/eureka/','eureka service Url, multiple services> are separated by English commas'),
    ('namespace.lock.switch', 'default', 'false', 'Only one person can modify the switch at a time'),
    ('item.key.length.limit', 'default', '128', 'item key Maximum length limit'),
    ('item.value.length.limit', 'default', '20000', 'item value Maximum length limit'),
    ('config-service.cache.enabled', 'default', 'false', 'ConfigService Whether the cache is enabled, which can improve performance
 Yes, but it will increase memory consumption!');

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

(2) Import database script of test environment

[root@mfyxw10 ~]# mysql -uroot -p < apolloconfigtest.sql
Enter password:                  #Enter the database password to complete the import

(3) View the created database name and table name

[root@mfyxw10 ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 63
Server version: 10.1.45-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| ApolloConfigDB     |
| ApolloConfigTestDB |
| ApolloPortalDB     |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
6 rows in set (0.01 sec)

MariaDB [(none)]> use ApolloConfigTestDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloConfigTestDB]> show tables;
+------------------------------+
| Tables_in_ApolloConfigTestDB |
+------------------------------+
| App                          |
| AppNamespace                 |
| Audit                        |
| Cluster                      |
| Commit                       |
| GrayReleaseRule              |
| Instance                     |
| InstanceConfig               |
| Item                         |
| Namespace                    |
| NamespaceLock                |
| Release                      |
| ReleaseHistory               |
| ReleaseMessage               |
| ServerConfig                 |
+------------------------------+
15 rows in set (0.00 sec)

MariaDB [ApolloConfigTestDB]> 

(4) Modify the Value of ServerConfig of ApolloConfigTestDB database

View the Value of the original ServerConfig

MariaDB [(none)]> use ApolloConfigTestDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloConfigTestDB]> 
MariaDB [ApolloConfigTestDB]> select * from ServerConfig\G
*************************** 1. row ***************************
                       Id: 1
                      Key: eureka.service.url
                  Cluster: default
                    Value: http://localhost:8080/eureka/
                  Comment: Eureka service Url,Multiple service Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 2. row ***************************
                       Id: 2
                      Key: namespace.lock.switch
                  Cluster: default
                    Value: false
                  Comment: Only one person can modify the switch at a time
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 3. row ***************************
                       Id: 3
                      Key: item.key.length.limit
                  Cluster: default
                    Value: 128
                  Comment: item key Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 4. row ***************************
                       Id: 4
                      Key: item.value.length.limit
                  Cluster: default
                    Value: 20000
                  Comment: item value Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 5. row ***************************
                       Id: 5
                      Key: config-service.cache.enabled
                  Cluster: default
                    Value: false
                  Comment: ConfigService Whether to enable the cache, which can improve performance but increase memory consumption!
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
5 rows in set (0.00 sec)

MariaDB [ApolloConfigTestDB]>

Update the Value value of ServerConfig

MariaDB [ApolloConfigTestDB]> update ApolloConfigTestDB.ServerConfig set ServerConfig.Value="http://config-test.od.com/eureka" where ServerConfig.key="eureka.service.url";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [ApolloConfigTestDB]> 

View the Value value of the updated ServerConfig

MariaDB [ApolloConfigTestDB]> select * from ServerConfig\G;
*************************** 1. row ***************************
                       Id: 1
                      Key: eureka.service.url
                  Cluster: default
                    Value: http://config-test.od.com/eureka
                  Comment: Eureka service Url,Multiple service Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:57:02
*************************** 2. row ***************************
                       Id: 2
                      Key: namespace.lock.switch
                  Cluster: default
                    Value: false
                  Comment: Only one person can modify the switch at a time
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 3. row ***************************
                       Id: 3
                      Key: item.key.length.limit
                  Cluster: default
                    Value: 128
                  Comment: item key Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 4. row ***************************
                       Id: 4
                      Key: item.value.length.limit
                  Cluster: default
                    Value: 20000
                  Comment: item value Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
*************************** 5. row ***************************
                       Id: 5
                      Key: config-service.cache.enabled
                  Cluster: default
                    Value: false
                  Comment: ConfigService Whether to enable the cache, which can improve performance but increase memory consumption!
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 22:14:48
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 22:14:48
5 rows in set (0.00 sec)

ERROR: No query specified

MariaDB [ApolloConfigTestDB]> 

(5) Authorize the ApolloConfigTestDB database

MariaDB [(none)]> grant INSERT,UPDATE,DELETE,SELECT on ApolloConfigTestDB.* to "apolloconfig"@"192.168.80.%" identified by "123456";
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 

(6) The database script of prod environment is as follows (it is recommended to copy and paste vi /root/apolloconfigprod.sql):

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

# Create Database
# ------------------------------------------------------------
CREATE DATABASE IF NOT EXISTS ApolloConfigProdDB DEFAULT CHARACTER SET = utf8mb4;

Use ApolloConfigProdDB;

# Dump of table app
# ------------------------------------------------------------

DROP TABLE IF EXISTS `App`;

CREATE TABLE `App` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Application name',
  `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'department Id',
  `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Department name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId` (`AppId`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_Name` (`Name`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Application table';



# Dump of table appnamespace
# ------------------------------------------------------------

DROP TABLE IF EXISTS `AppNamespace`;

CREATE TABLE `AppNamespace` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'namespace Name, please note that it needs to be globally unique',
  `AppId` varchar(32) NOT NULL DEFAULT '' COMMENT 'app id',
  `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT 'annotation',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_AppId` (`AppId`),
  KEY `Name_AppId` (`Name`,`AppId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='application namespace definition';



# Dump of table audit
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Audit`;

  `EntityName` varchar(50) NOT NULL DEFAULT 'default' COMMENT 'Table name',
  `EntityId` int(10) unsigned DEFAULT NULL COMMENT 'record ID',
  `OpName` varchar(50) NOT NULL DEFAULT 'default' COMMENT 'Operation type',
  `Comment` varchar(500) DEFAULT NULL COMMENT 'Remarks',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Log audit table';



# Dump of table cluster
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Cluster`;

CREATE TABLE `Cluster` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'Cluster name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_AppId_Name` (`AppId`,`Name`),
  KEY `IX_ParentClusterId` (`ParentClusterId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='colony';



# Dump of table commit
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Commit`;

CREATE TABLE `Commit` (
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `Comment` varchar(500) DEFAULT NULL COMMENT 'Remarks',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `AppId` (`AppId`(191)),
  KEY `ClusterName` (`ClusterName`(191)),
  KEY `NamespaceName` (`NamespaceName`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='commit History table';

# Dump of table grayreleaserule
# ------------------------------------------------------------

DROP TABLE IF EXISTS `GrayReleaseRule`;

CREATE TABLE `GrayReleaseRule` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
  `NamespaceName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name',
  `BranchName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'branch name',
  `Rules` varchar(16000) DEFAULT '[]' COMMENT 'Grayscale rule',
  `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Grayscale corresponding release',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_Namespace` (`AppId`,`ClusterName`,`NamespaceName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gray rule table';


# Dump of table instance
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Instance`;
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `AppId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `DataCenter` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Data Center Name',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_UNIQUE_KEY` (`AppId`,`ClusterName`,`Ip`,`DataCenter`),
  KEY `IX_IP` (`Ip`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Use configured application instances';



# Dump of table instanceconfig
# ------------------------------------------------------------

DROP TABLE IF EXISTS `InstanceConfig`;

CREATE TABLE `InstanceConfig` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `InstanceId` int(11) unsigned DEFAULT NULL COMMENT 'Instance Id',
  `ConfigAppId` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Config App Id',
  `ConfigClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Config Cluster Name',
  `ReleaseDeliveryTime` timestamp NULL DEFAULT NULL COMMENT 'Configure acquisition time',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_UNIQUE_KEY` (`InstanceId`,`ConfigAppId`,`ConfigNamespaceName`),
  KEY `IX_ReleaseKey` (`ReleaseKey`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configuration information of application instance';



# Dump of table item
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Item`;

CREATE TABLE `Item` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `Value` longtext NOT NULL COMMENT 'Configuration item value',
  `Comment` varchar(1024) DEFAULT '' COMMENT 'annotation',
  `LineNum` int(10) unsigned DEFAULT '0' COMMENT 'Line number',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `IX_GroupId` (`NamespaceId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configuration items';



# Dump of table namespace
# ------------------------------------------------------------

CREATE TABLE `Namespace` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  `ClusterName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Cluster Name',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'Namespace Name',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId_ClusterName_NamespaceName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_NamespaceName` (`NamespaceName`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Namespace';



# Dump of table namespacelock
# ------------------------------------------------------------

DROP TABLE IF EXISTS `NamespaceLock`;

CREATE TABLE `NamespaceLock` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement id',
  `NamespaceId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'colony NamespaceId',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT 'default' COMMENT 'Last modified by mailbox prefix',
  `IsDeleted` bit(1) DEFAULT b'0' COMMENT 'Soft delete',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `IX_NamespaceId` (`NamespaceId`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='namespace Edit lock for';



# Dump of table release
# ------------------------------------------------------------

DROP TABLE IF EXISTS `Release`;

CREATE TABLE `Release` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `ReleaseKey` varchar(64) NOT NULL DEFAULT '' COMMENT 'Published Key',
  `Name` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Release name',
  `NamespaceName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `Configurations` longtext NOT NULL COMMENT 'Publishing configuration',
  `IsAbandoned` bit(1) NOT NULL DEFAULT b'0' COMMENT 'Discard or not',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  PRIMARY KEY (`Id`),
  KEY `AppId_ClusterName_GroupName` (`AppId`(191),`ClusterName`(191),`NamespaceName`(191)),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),
  KEY `IX_ReleaseKey` (`ReleaseKey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='release';


# Dump of table releasehistory
# ------------------------------------------------------------

DROP TABLE IF EXISTS `ReleaseHistory`;

CREATE TABLE `ReleaseHistory` (
  `ClusterName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'ClusterName',
  `NamespaceName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'namespaceName',
  `BranchName` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Publish branch name',
  `ReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Associated Release Id',
  `PreviousReleaseId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Last published ReleaseId',
  `OperationContext` longtext NOT NULL COMMENT 'Publishing context information',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  KEY `IX_ReleaseId` (`ReleaseId`),
  KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Release history';


# Dump of table releasemessage
DROP TABLE IF EXISTS `ReleaseMessage`;

CREATE TABLE `ReleaseMessage` (
  `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Auto increment primary key',
  `Message` varchar(1024) NOT NULL DEFAULT '' COMMENT 'Published message content',
  PRIMARY KEY (`Id`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`),




DROP TABLE IF EXISTS `ServerConfig`;

CREATE TABLE `ServerConfig` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Autoincrement Id',
  `Key` varchar(64) NOT NULL DEFAULT 'default' COMMENT 'Configuration item Key',
  `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT 'Configuration item value',
  `Comment` varchar(1024) DEFAULT '' COMMENT 'annotation',
  `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT 'Creator mailbox prefix',
  `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Creation time',
  `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT 'Last modified by mailbox prefix',
  `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last modification time',
  PRIMARY KEY (`Id`),
  KEY `IX_Key` (`Key`),
  KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Configure service self configuration';

# Config
# ------------------------------------------------------------
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`, `Comment`)
VALUES
    ('eureka.service.url', 'default', 'http://Localhost:8080/eureka/','eureka service Url, multiple services> are separated by English commas'),
    ('namespace.lock.switch', 'default', 'false', 'Only one person can modify the switch at a time'),
    ('item.key.length.limit', 'default', '128', 'item key Maximum length limit'),
    ('item.value.length.limit', 'default', '20000', 'item value Maximum length limit'),
    ('config-service.cache.enabled', 'default', 'false', 'ConfigService Whether the cache is enabled, which can improve performance
 Yes, but it will increase memory consumption!');

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

(7) Database script for importing prod environment

[root@mfyxw10 ~]# mysql -uroot -p < apolloconfigprod.sql
Enter password:                  #Enter the database password to complete the import

(8) View the created database name and table name

[root@mfyxw10 ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 63
Server version: 10.1.45-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| ApolloConfigDB     |
| ApolloConfigProdDB |
| ApolloConfigTestDB |
| ApolloPortalDB     |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
7 rows in set (0.00 sec)

MariaDB [(none)]> 
MariaDB [(none)]> use ApolloConfigProdDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloConfigProdDB]> show tables;
+------------------------------+
| Tables_in_ApolloConfigProdDB |
+------------------------------+
| App                          |
| AppNamespace                 |
| Audit                        |
| Cluster                      |
| Commit                       |
| GrayReleaseRule              |
| Instance                     |
| InstanceConfig               |
| Item                         |
| Namespace                    |
| NamespaceLock                |
| Release                      |
| ReleaseHistory               |
| ReleaseMessage               |
| ServerConfig                 |
+------------------------------+
15 rows in set (0.00 sec)

MariaDB [ApolloConfigProdDB]> 

(9) Modify the Value of ServerConfig of ApolloConfigProdDB database

View the Value of the original ServerConfig

MariaDB [(none)]> use ApolloConfigProdDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloConfigProdDB]> select * from ServerConfig\G
*************************** 1. row ***************************
                       Id: 1
                      Key: eureka.service.url
                  Cluster: default
                    Value: http://localhost:8080/eureka/
                  Comment: Eureka service Url,Multiple service Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 2. row ***************************
                       Id: 2
                      Key: namespace.lock.switch
                  Cluster: default
                    Value: false
                  Comment: Only one person can modify the switch at a time
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 3. row ***************************
                       Id: 3
                      Key: item.key.length.limit
                  Cluster: default
                    Value: 128
                  Comment: item key Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 4. row ***************************
                       Id: 4
                      Key: item.value.length.limit
                  Cluster: default
                    Value: 20000
                  Comment: item value Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 5. row ***************************
                       Id: 5
                      Key: config-service.cache.enabled
                  Cluster: default
                    Value: false
                  Comment: ConfigService Whether to enable the cache, which can improve performance but increase memory consumption!
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
5 rows in set (0.00 sec)

MariaDB [ApolloConfigProdDB]> 

Update the Value value of ServerConfig

MariaDB [ApolloConfigProdDB]> update ApolloConfigProdDB.ServerConfig set ServerConfig.Value="http://config-prod.od.com/eureka" where ServerConfig.key="eureka.service.url";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

MariaDB [ApolloConfigProdDB]> 

View the Value value of the updated ServerConfig

MariaDB [ApolloConfigProdDB]> select * from ServerConfig\G;
*************************** 1. row ***************************
                       Id: 1
                      Key: eureka.service.url
                  Cluster: default
                    Value: http://config-prod.od.com/eureka
                  Comment: Eureka service Url,Multiple service Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 2. row ***************************
                       Id: 2
                      Key: namespace.lock.switch
                  Cluster: default
                    Value: false
                  Comment: Only one person can modify the switch at a time
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 3. row ***************************
                       Id: 3
                      Key: item.key.length.limit
                  Cluster: default
                    Value: 128
                  Comment: item key Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 4. row ***************************
                       Id: 4
                      Key: item.value.length.limit
                  Cluster: default
                    Value: 20000
                  Comment: item value Maximum length limit
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
*************************** 5. row ***************************
                       Id: 5
                      Key: config-service.cache.enabled
                  Cluster: default
                    Value: false
                  Comment: ConfigService Whether to enable the cache, which can improve performance but increase memory consumption!
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-09 23:04:16
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:04:16
5 rows in set (0.00 sec)

ERROR: No query specified

MariaDB [ApolloConfigProdDB]>

(5) Authorize the ApolloConfigProdDB database

MariaDB [(none)]> grant INSERT,DELETE,UPDATE,SELECT on ApolloConfigProdDB.* to "apolloconfig"@"192.168.80.%" identified by "123456";
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 

5. modify the Value of ServerConfig in ApolloPortalDB

(1) View the value of the original ServerConfig

MariaDB [(none)]> use ApolloPortalDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloPortalDB]> show tables;
+--------------------------+
| Tables_in_ApolloPortalDB |
+--------------------------+
| App                      |
| AppNamespace             |
| Authorities              |
| Consumer                 |
| ConsumerAudit            |
| ConsumerRole             |
| ConsumerToken            |
| Favorite                 |
| Permission               |
| Role                     |
| RolePermission           |
| ServerConfig             |
| UserRole                 |
| Users                    |
+--------------------------+
14 rows in set (0.00 sec)

MariaDB [ApolloPortalDB]> select * from ServerConfig\G;
*************************** 1. row ***************************
                       Id: 1
                      Key: apollo.portal.envs
                    Value: dev
                  Comment: List of supported environments
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 2. row ***************************
                       Id: 2
                      Key: organizations
                    Value: [{"orgId":"yf1","orgName":"Linux college"},{"orgId":"yf2","orgName":"Cloud computing College"},{"orgId":"yf3","orgName":"Python college"},{"orgId":"yf4","orgName":"Big data Institute"}]
                  Comment: Department list
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:31:50
*************************** 3. row ***************************
                       Id: 3
                      Key: superAdmin
                    Value: apollo
                  Comment: Portal Super administrator
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 4. row ***************************
                       Id: 4
                      Key: api.readTimeout
                    Value: 10000
                  Comment: http interface read timeout
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 5. row ***************************
                       Id: 5
                      Key: consumer.token.salt
                    Value: someSalt
                  Comment: consumer token salt
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 6. row ***************************
                       Id: 6
                      Key: admin.createPrivateNamespace.switch
                    Value: true
                  Comment: Allow project administrators to create private namespace
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 7. row ***************************
                       Id: 7
                      Key: configView.memberOnly.envs
                    Value: pro
                  Comment: The list of environments that display configuration information only for project members, multiple env Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
7 rows in set (0.00 sec)

ERROR: No query specified

MariaDB [ApolloPortalDB]> 

(2) Update the Value of ServerConfig to fat,pro

MariaDB [ApolloPortalDB]> update ApolloPortalDB.ServerConfig set ServerConfig.Value='fat,pro' where Id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [ApolloPortalDB]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [ApolloPortalDB]>

(3) View the Value of Value with ID 1 of update ServerConfig

MariaDB [ApolloPortalDB]> select * from ServerConfig\G
*************************** 1. row ***************************
                       Id: 1
                      Key: apollo.portal.envs
                    Value: fat,pro
                  Comment: List of supported environments
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-09 23:22:50
*************************** 2. row ***************************
                       Id: 2
                      Key: organizations
                    Value: [{"orgId":"yf1","orgName":"Linux college"},{"orgId":"yf2","orgName":"Cloud computing College"},{"orgId":"yf3","orgName":"Python college"},{"orgId":"yf4","orgName":"Big data Institute"}]
                  Comment: Department list
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:31:50
*************************** 3. row ***************************
                       Id: 3
                      Key: superAdmin
                    Value: apollo
                  Comment: Portal Super administrator
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 4. row ***************************
                       Id: 4
                      Key: api.readTimeout
                    Value: 10000
                  Comment: http interface read timeout
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 5. row ***************************
                       Id: 5
                      Key: consumer.token.salt
                    Value: someSalt
                  Comment: consumer token salt
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 6. row ***************************
                       Id: 6
                      Key: admin.createPrivateNamespace.switch
                    Value: true
                  Comment: Allow project administrators to create private namespace
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
*************************** 7. row ***************************
                       Id: 7
                      Key: configView.memberOnly.envs
                    Value: pro
                  Comment: The list of environments that display configuration information only for project members, multiple env Separated by English commas
                IsDeleted:  
     DataChange_CreatedBy: default
   DataChange_CreatedTime: 2020-07-06 10:15:59
DataChange_LastModifiedBy: 
      DataChange_LastTime: 2020-07-06 10:15:59
7 rows in set (0.00 sec)

MariaDB [ApolloPortalDB]>

6. modify the configmap Yaml resource configuration list and Application

On the operation and maintenance host mfyxw50 Mfyxw Operation on COM

(1) Modify the configmap resource configuration list of Apollo portal

[root@mfyxw50 ~]# cat > /data/k8s-yaml/apollo-portal/configmap.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: apollo-portal-cm
  namespace: infra
data:
  application-github.properties: |
    # DataSource
    spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloPortalDB?characterEncoding=utf8
    spring.datasource.username = apolloportal
    spring.datasource.password = 123456
  app.properties: |
    appId=100003173
  apollo-env.properties: |
    fat.meta=http://config-test.od.com
    pro.meta=http://config-prod.od.com
EOF

(2) The configmap resource configuration list of the application Apollo portal

Operate on any host in the master node (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/apollo-portal/configmap.yaml
configmap/apollo-portal-cm configured
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get cm -n infra
NAME                      DATA   AGE
apollo-adminservice-cm    2      3d22h
apollo-configservice-cm   2      6d15h
apollo-portal-cm          3      3d15h
dubbo-monitor-cm          1      21d
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl describe cm apollo-portal-cm -n infra
Name:         apollo-portal-cm
Namespace:    infra
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"v1","data":{"apollo-env.properties":"fat.meta=http://config-test.od.com\npro.meta=http://config-prod.od.com\n","app.propert...

Data
====
app.properties:
----
appId=100003173

application-github.properties:
----
# DataSource
spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = apolloportal
spring.datasource.password = 123456

apollo-env.properties:
----
fat.meta=http://config-test.od.com
pro.meta=http://config-prod.od.com

Events:  <none>

7. create resource configuration list

(1) Create resource configuration list storage directory

Operate on the operation and maintenance host (mfyxw50.mfyxw.com)

[root@mfyxw50 ~]# mkdir -p /data/k8s-yaml/test/{apollo-configservice,apollo-adminservice,dubbo-demo-service,dubbo-demo-consumer}
[root@mfyxw50 ~]# mkdir -p /data/k8s-yaml/prod/{apollo-configservice,apollo-adminservice,dubbo-demo-service,dubbo-demo-consumer}

(2) Create the Apollo configservice resource configuration list of the test environment

Operate on the operation and maintenance host (mfyxw50.mfyxw.com)

deployment.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-configservice/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: apollo-configservice
  namespace: test
  labels:
    name: apollo-configservice
spec:
  replicas: 1
  selector:
    matchLabels:
      name: apollo-configservice
  template:
    metadata:
      labels:
        app: apollo-configservice
        name: apollo-configservice
    spec:
      volumes:
      - name: configmap-volume
        configMap:
          name: apollo-configservice-cm
      containers:
      - name: apollo-configservice
        image: harbor.od.com/infra/apollo-configservice:v1.5.1
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: configmap-volume
          mountPath: /apollo-configservice/config
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

configmap.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-configservice/configmap.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: apollo-configservice-cm
  namespace: test
data:
  application-github.properties: |
    # DataSource
    spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigTestDB?characterEncoding=utf8
    spring.datasource.username = apolloconfig
    spring.datasource.password = 123456
    eureka.service.url = http://config-test.od.com/eureka
  app.properties: |
    appId=100003171
EOF

service.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-configservice/service.yaml <<EOF
kind: Service
apiVersion: v1
metadata: 
  name: apollo-configservice
  namespace: test
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector: 
    app: apollo-configservice
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None
EOF

Ingress.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-configservice/Ingress.yaml <<EOF
kind: Ingress
apiVersion: extensions/v1beta1
metadata: 
  name: apollo-configservice
  namespace: test
spec:
  rules:
  - host: config-test.od.com
    http:
      paths:
      - path: /
        backend: 
          serviceName: apollo-configservice
          servicePort: 8080
EOF

(3) Apollo configservice configuration resource list of application test environment

Execute on any one of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n test
No resources found.
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-configservice/configmap.yaml
configmap/apollo-configservice-cm created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-configservice/deployment.yaml
deployment.extensions/apollo-configservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-configservice/service.yaml
service/apollo-configservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-configservice/Ingress.yaml
ingress.extensions/apollo-configservice created
[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-configservice-5f6555448-qrj77   1/1     Running   0          40s

(4) Access config test Od COM

In eurake, you can see that the Apollo configservice of the test environment has been registered with eurake

(5) Create the Apollo adminservice resource configuration list of the test environment

On the operation and maintenance host mfyxw50 Mfyxw Execute on COM

deployment.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-adminservice/deployment.yaml <<EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: apollo-adminservice
  namespace: test
  labels:
    name: apollo-adminservice
spec:
  replicas: 1
  selector:
    matchLabels:
      name: apollo-adminservice
  template:
    metadata:
      labels:
        app: apollo-adminservice
        name: apollo-adminservice
    spec:
      volumes:
      - name: configmap-volume
        configMap:
          name: apollo-adminservice-cm
      containers:
      - name: apollo-adminservice
        image: harbor.od.com/infra/apollo-adminservice:v1.5.1
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: configmap-volume
          mountPath: /apollo-adminservice/config
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

configmap.yaml

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/apollo-adminservice/configmap.yaml <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: apollo-adminservice-cm
  namespace: test
data:
  application-github.properties: |
    # DataSource
    spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigTestDB?characterEncoding=utf8
    spring.datasource.username = apolloconfig
    spring.datasource.password = 123456
    eureka.service.url = http://config-test.od.com/eureka
  app.properties: |
    appId=100003172
EOF

(8) List of Apollo adminservice configuration resources for test

Execute on any one of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-adminservice/configmap.yaml
configmap/apollo-adminservice-cm created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/apollo-adminservice/deployment.yaml
deployment.extensions/apollo-adminservice created
[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-ddjjc   1/1     Running   0          24s
apollo-configservice-5f6555448-qrj77   1/1     Running   0          20m

(9) Access config test Od COM

You can see that both the Apollo configservice and the Apollo adminservice are registered with eurake respectively

(10) Create prod production environment configservice resource configuration list

On the operation and maintenance host mfyxw50 Mfyxw Operation on COM

Deployment Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-configservice/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: apollo-configservice
  namespace: prod
  labels:
    name: apollo-configservice
spec:
  replicas: 1
  selector:
    matchLabels:
      name: apollo-configservice
  template:
    metadata:
      labels:
        app: apollo-configservice
        name: apollo-configservice
    spec:
      volumes:
      - name: configmap-volume
        configMap:
          name: apollo-configservice-cm
      containers:
      - name: apollo-configservice
        image: harbor.od.com/infra/apollo-configservice:v1.5.1
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: configmap-volume
          mountPath: /apollo-configservice/config
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

Configmap Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-configservice/configmap.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: apollo-configservice-cm
  namespace: prod
data:
  application-github.properties: |
    # DataSource
    spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigProdDB?characterEncoding=utf8
    spring.datasource.username = apolloconfig
    spring.datasource.password = 123456
    eureka.service.url = http://config-prod.od.com/eureka
  app.properties: |
    appId=100003171
EOF

Ingress Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-configservice/Ingress.yaml <<EOF
kind: Ingress
apiVersion: extensions/v1beta1
metadata: 
  name: apollo-configservice
  namespace: prod
spec:
  rules:
  - host: config-prod.od.com
    http:
      paths:
      - path: /
        backend: 
          serviceName: apollo-configservice
          servicePort: 8080
EOF

Service Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-configservice/service.yaml <<EOF
kind: Service
apiVersion: v1
metadata: 
  name: apollo-configservice
  namespace: prod
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector: 
    app: apollo-configservice
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None
EOF

(11) Create the prod production environment adminservice resource configuration list

On the operation and maintenance host mfyxw50 Mfyxw Operation on COM

Deployment Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-adminservice/deployment.yaml <<EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: apollo-adminservice
  namespace: prod
  labels:
    name: apollo-adminservice
spec:
  replicas: 1
  selector:
    matchLabels:
      name: apollo-adminservice
  template:
    metadata:
      labels:
        app: apollo-adminservice
        name: apollo-adminservice
    spec:
      volumes:
      - name: configmap-volume
        configMap:
          name: apollo-adminservice-cm
      containers:
      - name: apollo-adminservice
        image: harbor.od.com/infra/apollo-adminservice:v1.5.1
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: configmap-volume
          mountPath: /apollo-adminservice/config
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

Configmap Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/apollo-adminservice/configmap.yaml <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: apollo-adminservice-cm
  namespace: prod
data:
  application-github.properties: |
    # DataSource
    spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloConfigProdDB?characterEncoding=utf8
    spring.datasource.username = apolloconfig
    spring.datasource.password = 123456
    eureka.service.url = http://config-prod.od.com/eureka
  app.properties: |
    appId=100003172
EOF

(12) Create prod production environment configservice and adminservice resource configuration lists

Execute on any one of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n prod
No resources found.
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-configservice/configmap.yaml
configmap/apollo-configservice-cm created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-configservice/deployment.yaml
deployment.extensions/apollo-configservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-configservice/service.yaml
service/apollo-configservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-configservice/Ingress.yaml
ingress.extensions/apollo-configservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-adminservice/configmap.yaml
configmap/apollo-adminservice-cm created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/apollo-adminservice/deployment.yaml
deployment.extensions/apollo-adminservice created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n prod
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-dvlfx   1/1     Running   0          32s
apollo-configservice-5f6555448-7kj46   1/1     Running   0          66s

(13) Access config-prod.od COM

8. apply portal

My portal has been started in the previous experiment and has been set to 0 in the dashboard. It is recommended to log in to portal Od Delete the Dubbo demo service and Dubbo demo web items in. Com or enter the ApolloPortalDB database to delete and clear the contents of the AppNamespace and App tables

Access portal Od COM, indicating that the portal has been stopped

Then I'll operate in the database

In mfyxw10 Mfyxw Operation on COM host

(1) Empty AppNamespace and App content of portal database

[root@mfyxw10 ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 169
Server version: 10.1.45-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use ApolloPortalDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ApolloPortalDB]> select * from AppNamespace;
+----+-------------+--------------------+------------+----------+-----------------------+-----------+----------------------+------------------------+---------------------------+---------------------+
| Id | Name        | AppId              | Format     | IsPublic | Comment               | IsDeleted | DataChange_CreatedBy | DataChange_CreatedTime | DataChange_LastModifiedBy | DataChange_LastTime |
+----+-------------+--------------------+------------+----------+-----------------------+-----------+----------------------+------------------------+---------------------------+---------------------+
|  1 | application | dubbo-demo-service | properties |          | default app namespace |           | apollo               | 2020-07-07 21:22:36    | apollo                    | 2020-07-07 21:22:36 |
|  2 | application | dubbo-demo-web     | properties |          | default app namespace |           | apollo               | 2020-07-09 14:10:45    | apollo                    | 2020-07-09 14:10:45 |
+----+-------------+--------------------+------------+----------+-----------------------+-----------+----------------------+------------------------+---------------------------+---------------------+
2 rows in set (0.00 sec)

MariaDB [ApolloPortalDB]> select * from App;
+----+--------------------+----------------------+-------+-------------+-----------+----------------+-----------+----------------------+------------------------+---------------------------+---------------------+
| Id | AppId              | Name                 | OrgId | OrgName     | OwnerName | OwnerEmail     | IsDeleted | DataChange_CreatedBy | DataChange_CreatedTime | DataChange_LastModifiedBy | DataChange_LastTime |
+----+--------------------+----------------------+-------+-------------+-----------+----------------+-----------+----------------------+------------------------+---------------------------+---------------------+
|  1 | dubbo-demo-service | dubbo Service provider      | yf1   | Linux college   | apollo    | mapleyf@qq.com |           | apollo               | 2020-07-07 21:22:36    | apollo                    | 2020-07-07 21:22:36 |
|  2 | dubbo-demo-web     | dubbo Serving consumers      | yf1   | Linux college   | apollo    | mapleyf@qq.com |           | apollo               | 2020-07-09 14:10:45    | apollo                    | 2020-07-09 14:10:45 |
+----+--------------------+----------------------+-------+-------------+-----------+----------------+-----------+----------------------+------------------------+---------------------------+---------------------+
2 rows in set (0.00 sec)

MariaDB [ApolloPortalDB]> truncate table AppNamespace;
Query OK, 0 rows affected (0.01 sec)

MariaDB [ApolloPortalDB]> truncate table App;
Query OK, 0 rows affected (0.01 sec)

MariaDB [ApolloPortalDB]> select * from AppNamespace;
Empty set (0.00 sec)

MariaDB [ApolloPortalDB]> select * from App;
Empty set (0.00 sec)

MariaDB [ApolloPortalDB]> 

(2) Apply the deployment Yaml resource configuration list

Execute on any of the master nodes (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

The resource configuration list of portal has been applied in the previous section, but the experiment in this section will delete the deployment. Now it is applied again. The configmap has been modified previously

[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                             READY   STATUS    RESTARTS   AGE
dubbo-monitor-6676dd74cc-9hghb   1/1     Running   22         21d
dubbo-monitor-6676dd74cc-rd86g   1/1     Running   21         21d
jenkins-b99776c69-49dnr          1/1     Running   2          2d3h
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/apollo-portal/deployment.yaml
deployment.extensions/apollo-portal created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                             READY   STATUS    RESTARTS   AGE
apollo-portal-57bc86966d-rgvs8   1/1     Running   0          25s
dubbo-monitor-6676dd74cc-9hghb   1/1     Running   22         21d
dubbo-monitor-6676dd74cc-rd86g   1/1     Running   21         21d
jenkins-b99776c69-49dnr          1/1     Running   2          2d3h

(3) Browse portal Od COM, you can see that there is no project

9. create two items and add configuration items in the portal respectively

(1) Add a Dubbo demo service provider project

(2) Add the configuration of the Dubbo demo service provider and publish it

Test environment configuration and release

New configuration

Add a configuration item for the test environment: dubbo Registry

Add a configuration item for the test environment: dubbo Port

Click publish

Publish complete

Configuration and release of production environment

New configuration

Add a configuration item for the production environment: dubbo Registry

Add a configuration item for the production environment: dubbo Port

release

Successful distribution

(3) Add Dubbo demo web consumer project

(4) Add configuration of Dubbo demo web consumer and publish it

Click new configuration item (test environment)

Add a configuration item for the test environment: dubbo Registry

Click publish

Successfully released the service consumer registry of the test environment dubbo

Click Add configuration item (production environment)

Add a configuration item for the production environment: dubbo Registry

Click publish

Successfully published the service consumer registry for the production environment dubbo

10. build the Dubbo demo service image of the test environment

Log in to jenkins and build the Dubbo demo service image

Build successful

11. dubbo provider delivering test environment

(1) Create a Dubbo demo service resource configuration list for the test environment

On the operation and maintenance host mfyxw50 Mfyxw Operation on COM

Deployment Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/dubbo-demo-service/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-service
  namespace: test
  labels:
    name: dubbo-demo-service
spec:
  replicas: 1
  selector:
    matchLabels:
      name: dubbo-demo-service
  template:
    metadata:
      labels:
        app: dubbo-demo-service
        name: dubbo-demo-service
    spec:
      containers:
      - name: dubbo-demo-service
        image: harbor.od.com/app/dubbo-demo-service:apollo_20200707_2136
        ports:
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-server.jar
        - name: C_OPTS
          value: -Denv=fat -Dapollo.meta=http://config-test.od.com
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
EOF

(2) Dubbo demo service resource configuration list of application test environment

Execute at any node of the master node (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-ddjjc   1/1     Running   2          2d23h
apollo-configservice-5f6555448-qrj77   1/1     Running   2          2d23h
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/dubbo-demo-service/deployment.yaml
deployment.extensions/dubbo-demo-service created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-ddjjc   1/1     Running   2          2d23h
apollo-configservice-5f6555448-qrj77   1/1     Running   2          2d23h
dubbo-demo-service-cc6b9d8c7-zm4sw     1/1     Running   0          13s

(3) Modify the configmap of Dubbo monitor

You can log in to the dashboard, find the infra namespace, and find the configmap to modify the zoomeeper of Dubbo monitor cm to point to the test environment

It can also be created and applied through the resource configuration list

Create through resource configuration manifest

On the operation and maintenance host mfyxw50 Mfyxw Execute on COM

[root@mfyxw50 ~]# cat > /data/k8s-yaml/dubbo-monitor/configmap.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: dubbo-monitor-cm
  namespace: infra
data:
  dubbo.properties: |
    dubbo.container=log4j,spring,registry,jetty
    dubbo.application.name=simple-monitor
    dubbo.application.owner=
    dubbo.registry.address=zookeeper://zk-test.od.com:2181
    dubbo.protocol.port=20880
    dubbo.jetty.port=8080
    dubbo.jetty.directory=/dubbo-monitor-simple/monitor
    dubbo.charts.directory=/dubbo-monitor-simple/charts
    dubbo.statistics.directory=/dubbo-monitor-simple/statistics
    dubbo.log4j.file=/dubbo-monitor-simple/logs/dubbo-monitor.log
    dubbo.log4j.level=WARN
EOF

Application Dubbo monitor resource configuration list

Execute on any node of the master node (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

The previous project has already applied the Dubbo monitor resource configuration list. Therefore, delete it first and then create it again. Then delete the pod of Dubbo monitor and automatically regenerate it

[root@mfyxw30 ~]# kubectl delete -f http://k8s-yaml.od.com/dubbo-monitor/configmap.yaml
configmap "dubbo-monitor-cm" deleted
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/dubbo-monitor/configmap.yaml
configmap/dubbo-monitor-cm created
[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                             READY   STATUS    RESTARTS   AGE
apollo-portal-57bc86966d-khxvw   1/1     Running   1          2d18h
dubbo-monitor-6676dd74cc-tlrqz   1/1     Running   0          2m29s
jenkins-b99776c69-49dnr          1/1     Running   4          5d2h
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl delete pod dubbo-monitor-6676dd74cc-tlrqz -n infra
pod "dubbo-monitor-6676dd74cc-tlrqz" deleted
[root@mfyxw30 ~]# kubectl get pod -n infra
NAME                             READY   STATUS    RESTARTS   AGE
apollo-portal-57bc86966d-khxvw   1/1     Running   1          2d19h
dubbo-monitor-6676dd74cc-7bq9j   1/1     Running   0          18m
jenkins-b99776c69-49dnr          1/1     Running   4          5d3h

(4) Log in to Dubbo monitor to view the test environment Dubbo demo service

12. build the dubbo consumption image of the test environment

Successful consumer construction of test environment

13. create and apply the resource configuration list of dubbo consumers in the test environment

(1) Resource configuration list of dubbo consumers who create test environment

On the operation and maintenance host mfyxw50 Mfyxw Execute on COM

Deployment Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/dubbo-demo-consumer/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-consumer
  namespace: test
  labels:
    name: dubbo-demo-consumer
spec:
  replicas: 1
  selector:
    matchLabels:
      name: dubbo-demo-consumer
  template:
    metadata:
      labels:
        app: dubbo-demo-consumer
        name: dubbo-demo-consumer
    spec:
      containers:
      - name: dubbo-demo-consumer
        image: harbor.od.com/app/dubbo-demo-consumer:apollo_20200713_1714
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-client.jar
        - name: C_OPTS
          value: -Denv=fat -Dapollo.meta=http://config-test.od.com
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

Service Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/dubbo-demo-consumer/service.yaml << EOF
kind: Service
apiVersion: v1
metadata:
  name: dubbo-demo-consumer
  namespace: test
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector:
    app: dubbo-demo-consumer
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None
EOF

Ingress Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/test/dubbo-demo-consumer/Ingress.yaml << EOF
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-consumer
  namespace: test
spec:
  rules:
  - host: demo-test.od.com
    http:
      paths:
      - path: /
        backend:
          serviceName: dubbo-demo-consumer
          servicePort: 8080
EOF

(2) Resource configuration list of dubbo consumers applying the test environment

Execute on any node of the master node (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-ddjjc   1/1     Running   2          3d1h
apollo-configservice-5f6555448-qrj77   1/1     Running   2          3d1h
dubbo-demo-service-cc6b9d8c7-h2rdx     1/1     Running   0          82m
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/dubbo-demo-consumer/deployment.yaml
deployment.extensions/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/dubbo-demo-consumer/service.yaml
service/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/test/dubbo-demo-consumer/Ingress.yaml
ingress.extensions/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n test
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-ddjjc   1/1     Running   2          3d1h
apollo-configservice-5f6555448-qrj77   1/1     Running   2          3d1h
dubbo-demo-consumer-68466fb764-k2t47   1/1     Running   0          28s
dubbo-demo-service-cc6b9d8c7-h2rdx     1/1     Running   0          83m

(3) Log in to Dubbo monitor to check whether the Dubbo demo consumer has been registered

14. visit dubbo consumers

Note: the dubbo providers and consumers of the test environment have been delivered to the k8s cluster. The testers will test this version. If there is no problem, you can deliver the image of this version to the production environment.

15. deliver dubbo providers and consumers of the test environment to the production environment

Copy the resource allocation list of dubbo provider and consumer to the production environment respectively

On the operation and maintenance host mfyxw50 Mfyxw Execute on COM

(1) Create or modify the resource configuration list of the dubbo provider

Deployment Yaml file contents are as follows:

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/dubbo-demo-service/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-service
  namespace: prod
  labels:
    name: dubbo-demo-service
spec:
  replicas: 1
  selector:
    matchLabels:
      name: dubbo-demo-service
  template:
    metadata:
      labels:
        app: dubbo-demo-service
        name: dubbo-demo-service
    spec:
      containers:
      - name: dubbo-demo-service
        image: harbor.od.com/app/dubbo-demo-service:apollo_20200707_2136
        ports:
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-server.jar
        - name: C_OPTS
          value: -Denv=pro -Dapollo.meta=http://config-prod.od.com
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
EOF

(2) Create or modify the resource configuration list of dubbo consumers

Deployment Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/dubbo-demo-consumer/deployment.yaml << EOF
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-consumer
  namespace: prod
  labels:
    name: dubbo-demo-consumer
spec:
  replicas: 1
  selector:
    matchLabels:
      name: dubbo-demo-consumer
  template:
    metadata:
      labels:
        app: dubbo-demo-consumer
        name: dubbo-demo-consumer
    spec:
      containers:
      - name: dubbo-demo-consumer
        image: harbor.od.com/app/dubbo-demo-consumer:apollo_20200713_1714
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 20880
          protocol: TCP
        env:
        - name: JAR_BALL
          value: dubbo-client.jar
        - name: C_OPTS
          value: -Denv=pro -Dapollo.meta=http://config-prod.od.com
        imagePullPolicy: IfNotPresent
      imagePullSecrets:
      - name: harbor
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  revisionHistoryLimit: 7
  progressDeadlineSeconds: 600
EOF

Ingress Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/dubbo-demo-consumer/Ingress.yaml << EOF
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: dubbo-demo-consumer
  namespace: prod
spec:
  rules:
  - host: demo-prod.od.com
    http:
      paths:
      - path: /
        backend:
          serviceName: dubbo-demo-consumer
          servicePort: 8080
EOF

Service Yaml file contents are as follows

[root@mfyxw50 ~]# cat > /data/k8s-yaml/prod/dubbo-demo-consumer/service.yaml << EOF
kind: Service
apiVersion: v1
metadata:
  name: dubbo-demo-consumer
  namespace: prod
spec:
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
  selector:
    app: dubbo-demo-consumer
  clusterIP: None
  type: ClusterIP
  sessionAffinity: None
EOF

(3) Application dubbo provider and consumer resource configuration list

Execute on any node of the master node (mfyxw30.mfyxw.com or mfyxw40.mfyxw.com)

[root@mfyxw30 ~]# kubectl get pod -n prod
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-dvlfx   1/1     Running   2          3d
apollo-configservice-5f6555448-7kj46   1/1     Running   2          3d
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/dubbo-demo-service/deployment.yaml
deployment.extensions/dubbo-demo-service created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/dubbo-demo-consumer/deployment.yaml
deployment.extensions/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/dubbo-demo-consumer/service.yaml
service/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl apply -f http://k8s-yaml.od.com/prod/dubbo-demo-consumer/Ingress.yaml
ingress.extensions/dubbo-demo-consumer created
[root@mfyxw30 ~]# 
[root@mfyxw30 ~]# kubectl get pod -n prod
NAME                                   READY   STATUS    RESTARTS   AGE
apollo-adminservice-5cccf97c64-dvlfx   1/1     Running   2          3d
apollo-configservice-5f6555448-7kj46   1/1     Running   2          3d
dubbo-demo-consumer-85c9c67947-f67nh   1/1     Running   0          16s
dubbo-demo-service-bf45dcbbb-qfrzs     1/1     Running   0          24s

16. log in to Dubbo monitor to view

17. dubbo consumers accessing the production environment

Tags: Kubernetes

Posted by xux on Tue, 31 May 2022 20:53:53 +0530