To divide environment, the existing lab environment needs to be split
portal service, each environment can be shared, but apollo-adminservice apollo-configservice and must be separated.
1, zk environment and split into test prod environment
Add dns resolution:
# Vi / was /named/od.com.zone
zk-test.od.com A 10.4.7.11
zk-prod.od.com A 10.4.7.12
2, namespace points environment, create test and prod
# kubectl create ns test
# kubectl create ns prod
Create a secret:
# kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=harbor --docker-password=Harbor12345 -n test
# kubectl create secret docker-registry harbor --docker-server=harbor.od.com --docker-username=harbor --docker-password=Harbor12345 -n prod
3, the database resolution, the limited testing resources, so the use of the form of analog sub-sub-library environment
Modify database initialization script, create separate ApolloConfigTestDB and ApolloConfigProdDB
Modify the database eureka address here uses two new domain name, add their own resolve in the bind9
> update ApolloConfigProdDB.ServerConfig set ServerConfig.Value="http://config-prod.od.com/eureka" where ServerConfig.Key="eureka.service.url"; > grant INSERT,DELETE,UPDATE,SELECT on ApolloConfigProdDB.* to "apolloconfig"@"10.4.7.%" identified by "123456"; > update ApolloConfigTestDB.ServerConfig set ServerConfig.Value="http://config-test.od.com/eureka" where ServerConfig.Key="eureka.service.url"; > grant INSERT,DELETE,UPDATE,SELECT on ApolloConfigTestDB.* to "apolloconfig"@"10.4.7.%" identified by "123456";
Modify portal data to support fat and pro environment:
> update ServerConfig set Value='fat,pro' where Id=1;
The modification portal cm resource allocation list:
# We /data/k8s-yaml/apollo-portal/cm.yaml
# kubectl apply -f http://k8s-yaml.od.com/apollo-portal/cm.yaml
分别创建修改两个环境的资源配置文件:
test:
# cd /data/k8s-yaml
# mkdir -p test/{apollo-adminservice,apollo-configservice,dubbo-demo-server,dubbo-demo-consumer}
# mkdir -p prod/{apollo-adminservice,apollo-configservice,dubbo-demo-server,dubbo-demo-consumer}
将之前的资源配置清单cp到对应环境的目录中,进行修改:
# cd test/apollo-configservice/
# cp ../../apollo-configservice/* ./
1、cm.yaml 修改ns,数据库库名,eureka地址
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
2、dp.yaml
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
3、svc.yaml
kind: Service apiVersion: v1 metadata: name: apollo-configservice namespace: test spec: ports: - protocol: TCP port: 8080 targetPort: 8080 selector: app: apollo-configservice
4、ingress.yaml
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