k8s以Deployment方式部署apollo。最新版本:1.7.1
public-service-ns.yaml
apiVersion: v1kind: NamespaceMetadata: name: public-service
apollo.yaml
apiVersion: v1kind: ConfigMapMetadata: name: apollo-configservice namespace: public-servicedata: application-github.properties: | spring.datasource.url = jdbc:MysqL://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8 spring.datasource.username = root spring.datasource.password = 123456789 apollo.config-service.url = http://apollo-configservice.public-service:8080 apollo.admin-service.url = http://apollo-adminservice.public-service:8090---apiVersion: v1kind: ConfigMapMetadata: name: apollo-adminservice namespace: public-servicedata: application-github.properties: | spring.datasource.url = jdbc:MysqL://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8 spring.datasource.username = root spring.datasource.password = 123456789---apiVersion: v1kind: ConfigMapMetadata: name: apollo-portal namespace: public-servicedata: application-github.properties: | spring.datasource.url = jdbc:MysqL://192.168.30.131:3306/ApolloPortalDB?characterEncoding=utf8 spring.datasource.username = root spring.datasource.password = 123456789 apollo.portal.envs = dev apollo-env.properties: | dev.Meta = http://apollo-configservice:8080---apiVersion: v1kind: ServiceMetadata: name: apollo-configservice namespace: public-service labels: app: apollo-configservicespec: selector: app: apollo-configservice ports: - name: http protocol: TCP port: 8080 targetPort: 8080 ---apiVersion: v1kind: ServiceMetadata: name: apollo-adminservice namespace: public-service labels: app: apollo-adminservicespec: selector: app: apollo-adminservice ports: - name: http protocol: TCP port: 8090 targetPort: 8090---apiVersion: extensions/v1beta1kind: IngressMetadata: name: apollo-portal namespace: public-service labels: app: apollo-portalspec: rules: - host: apollo.lzxlinux.com http: paths: - path: / backend: serviceName: apollo-portal servicePort: 8070---apiVersion: v1kind: ServiceMetadata: name: apollo-portal namespace: public-service labels: app: apollo-portalspec: selector: app: apollo-portal sessionAffinity: ClientIP ports: - name: http protocol: TCP port: 8070 targetPort: 8070 ---apiVersion: apps/v1kind: DeploymentMetadata: name: apollo-configservice namespace: public-service labels: app: apollo-configservicespec: replicas: 1 selector: matchLabels: app: apollo-configservice template: Metadata: labels: app: apollo-configservice spec: containers: - name: apollo-configservice image: apolloconfig/apollo-configservice:latest imagePullPolicy: IfNotPresent ports: - name: http containerPort: 8080 protocol: TCP env: - name: SPRING_PROFILES_ACTIVE value: "github,kubernetes" resources: limits: cpu: "1000m" memory: "1024Mi" requests: cpu: "1000m" memory: "1024Mi" volumeMounts: - name: apollo-configservice-config mountPath: /apollo-configservice/config/application-github.properties subPath: application-github.properties volumes: - name: apollo-configservice-config configMap: name: apollo-configservice items: - key: application-github.properties path: application-github.properties defaultMode: 420 ---apiVersion: apps/v1kind: DeploymentMetadata: name: apollo-adminservice namespace: public-service labels: app: apollo-adminservicespec: replicas: 1 selector: matchLabels: app: apollo-adminservice template: Metadata: labels: app: apollo-adminservice spec: containers: - name: apollo-adminservice image: apolloconfig/apollo-adminservice:latest imagePullPolicy: IfNotPresent ports: - name: http containerPort: 8090 protocol: TCP env: - name: SPRING_PROFILES_ACTIVE value: "github,kubernetes" resources: limits: cpu: "1000m" memory: "1024Mi" requests: cpu: "1000m" memory: "1024Mi" volumeMounts: - name: apollo-adminservice-config mountPath: /apollo-adminservice/config/application-github.properties subPath: application-github.properties volumes: - name: apollo-adminservice-config configMap: name: apollo-adminservice items: - key: application-github.properties path: application-github.properties defaultMode: 420---apiVersion: apps/v1kind: DeploymentMetadata: name: apollo-portal namespace: public-service labels: app: apollo-portalspec: replicas: 1 selector: matchLabels: app: apollo-portal template: Metadata: labels: app: apollo-portal spec: containers: - name: apollo-portal image: apolloconfig/apollo-portal:latest imagePullPolicy: IfNotPresent ports: - name: http containerPort: 8070 protocol: TCP env: - name: SPRING_PROFILES_ACTIVE value: "github,auth" resources: limits: cpu: "1000m" memory: "1024Mi" requests: cpu: "1000m" memory: "1024Mi" volumeMounts: - name: apollo-portal-config mountPath: /apollo-portal/config/application-github.properties subPath: application-github.properties - name: apollo-portal-config mountPath: /apollo-portal/config/apollo-env.properties subPath: apollo-env.properties volumes: - name: apollo-portal-config configMap: name: apollo-portal items: - key: application-github.properties path: application-github.properties - key: apollo-env.properties path: apollo-env.properties defaultMode: 420
git clone https://github.com/ctripcorp/apollo.git MysqL -uroot -p123456789 < apollo/scripts/sql/apolloportaldb.sql MysqL -uroot -p123456789 < apollo/scripts/sql/apolloconfigdb.sql
kubectl apply -f public-service-ns.yaml kubectl apply -f apollo.yaml kubectl get svc -n public-service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE apollo-adminservice ClusterIP 10.110.239.51<none> 8090/TCP 14s apollo-configservice ClusterIP 10.103.129.253<none> 8080/TCP 14s apollo-portal ClusterIP 10.105.237.238<none> 8070/TCP 13s kubectl get pod -n public-service NAME READY STATUS RESTARTS AGE apollo-adminservice-765497fbbc-htskm 1/1 Running 0 35s apollo-configservice-64b4d77457-8w59g 1/1 Running 0 35s apollo-portal-5f585dc954-th96h 1/1 Running 0 34s
添加hosts:apollo.lzxlinux.com
,账号/密码:apollo
/admin
。
k8s部署apollo完成。已存放至个人github:kubernetes
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。