docker,k8s部署Apollo

      網友投稿 897 2022-05-30

      因為樓主更改了apollo源碼,所以需要重新打包,然后在制作鏡像。

      1.docker部署Apollo

      1. 打包

      可以參考上文。

      2.制作鏡像

      分別獲取打包之后zip包,在/apollo-portal/target/,apollo-adminservice/target/,apollo-configservice/target/中。

      分別在apollo-portal,apollo-adminservice,apollo-configservice中獲取dockerflie。

      docker build -t apollo-portal . docker build -t apollo-adminservice . docker build -t apollo-configservice .

      1

      2

      3

      3.運行容器

      在虛擬機中執行以下命令即可。

      adminconfig docker run -d -p 8090:8090 --net=host -e SPRING_DATASOURCE_URL="jdbc:postgresql://ip:5432/apolloconfig?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=apolloconfig -e SPRING_DATASOURCE_PASSWORD=123 -d -v /tmp/logs:/opt/logs --name apollo-adminservice apollo-adminservice SPRING_DATASOURCE_URL: 對應環境ApolloConfigDB的地址 SPRING_DATASOURCE_USERNAME: 對應環境ApolloConfigDB的用戶名 SPRING_DATASOURCE_PASSWORD: 對應環境ApolloConfigDB的密碼 --name apollo-adminservice apollo-adminservice:為鏡像同名 下面同理 apollo-configservice docker run -p 8080:8080 --net=host -e SPRING_DATASOURCE_URL="jdbc:postgresql://ip:5432/apolloconfig?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=apolloconfig -e SPRING_DATASOURCE_PASSWORD=123 -d -v /tmp/logs:/opt/logs --name apollo-configservice apollo-configservice SPRING_DATASOURCE_URL: 對應環境ApolloConfigDB的地址 SPRING_DATASOURCE_USERNAME: 對應環境ApolloConfigDB的用戶名 SPRING_DATASOURCE_PASSWORD: 對應環境ApolloConfigDB的密碼 apollo-portal docker run -p 8070:8070 --net=host -e SPRING_DATASOURCE_URL="jdbc:postgresql://ip:5432/apolloportal" -e SPRING_DATASOURCE_USERNAME=apolloportal -e SPRING_DATASOURCE_PASSWORD=123 -e APOLLO_PORTAL_ENVS=dev -e DEV_META=http://localhost:8080 -d -v /tmp/logs:/opt/logs --name apollo-portal apollo-portal SPRING_DATASOURCE_URL: 對應環境ApolloPortalDB的地址 SPRING_DATASOURCE_USERNAME: 對應環境ApolloPortalDB的用戶名 SPRING_DATASOURCE_PASSWORD: 對應環境ApolloPortalDB的密碼 APOLLO_PORTAL_ENVS(可選): 對應ApolloPortalDB中的apollo.portal.envs配置項,如果沒有在數據庫中配置的話,可以通過此環境參數配置 DEV_META/PRO_META(可選): 配置對應環境的Meta Service地址,以${ENV}_META命名,需要注意的是如果配置了ApolloPortalDB中的apollo.portal.meta.servers配置,則以apollo.portal.meta.servers中的配置為準

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      docker,k8s部署Apollo

      19

      20

      21

      22

      23

      如沒有定制數據庫需求,可以參考官方文檔

      https://github.com/ctripcorp/apollo/wiki/%E5%88%86%E5%B8%83%E5%BC%8F%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97#2-apolloportalmetaservers—%E5%90%84%E7%8E%AF%E5%A2%83meta-service%E5%88%97%E8%A1%A8

      2.k8s部署Apollo

      書接上文 樓主定制了oracle版本的apollo,那么怎么使用k8s部署呢,本文只部署dev環境,使用yaml文件在Kubernetes-dashboard部署。

      如果有對Kubernetes-dashboard不熟悉的,可以參考k8s專欄 。

      1.部署apollo-admin

      --- apiVersion: v1 kind: ConfigMap metadata: namespace: apollo #更改自己的namespace name: configmap-apollo-admin-server data: application-github.properties: | spring.datasource.url = jdbc:postgresql://ip:5432/apolloconfig?characterEncoding=utf8 spring.datasource.username = apolloconfig spring.datasource.password = 123 eureka.service.url = ip:5001/eureka --- apiVersion: v1 kind: Service metadata: namespace: apollo name: service-apollo-admin-server labels: app: service-apollo-admin-server spec: ports: - protocol: TCP port: 8090 nodePort: 8090 selector: app: pod-apollo-admin-server type: NodePort --- apiVersion: apps/v1 kind: Deployment metadata: namespace: apollo name: deployment-apollo-admin-server labels: app: deployment-apollo-admin-server spec: replicas: 1 selector: matchLabels: app: pod-apollo-admin-server strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: labels: app: pod-apollo-admin-server spec: volumes: - name: volume-configmap-apollo-admin-server configMap: name: configmap-apollo-admin-server items: - key: application-github.properties path: application-github.properties containers: - image: ip:9000/apollo/apollo-adminservice:latest #鏡像地址 樓主這里使用了私人倉庫 securityContext: privileged: true imagePullPolicy: IfNotPresent name: container-apollo-admin-server ports: - protocol: TCP containerPort: 8090 volumeMounts: - name: volume-configmap-apollo-admin-server mountPath: /apollo-admin-server/config/application-github.properties subPath: application-github.properties env: - name: APOLLO_ADMIN_SERVICE_NAME value: "service-apollo-admin-server.sre" readinessProbe: tcpSocket: port: 8090 initialDelaySeconds: 10 periodSeconds: 5 livenessProbe: tcpSocket: port: 8090 initialDelaySeconds: 120 periodSeconds: 10 dnsPolicy: ClusterFirst restartPolicy: Always nodeName: apollo #指定的nodes節點

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      2.部署apollo-config

      --- kind: ConfigMap apiVersion: v1 metadata: namespace: apollo #更改自己的namespace name: configmap-apollo-config-server data: application-github.properties: | spring.datasource.url = jdbc:postgresql://ip:5432/apolloconfig?characterEncoding=utf8 spring.datasource.username = apolloconfig spring.datasource.password = 123 eureka.service.url = ip:5001/eureka --- kind: Service apiVersion: v1 metadata: namespace: apollo name: service-apollo-meta-server labels: app: service-apollo-meta-server spec: ports: - protocol: TCP port: 8080 targetPort: 8080 selector: app: pod-apollo-config-server type: ClusterIP clusterIP: None sessionAffinity: ClientIP --- kind: Service apiVersion: v1 metadata: namespace: apollo name: service-apollo-config-server labels: app: service-apollo-config-server spec: ports: - protocol: TCP port: 8080 targetPort: 8080 nodePort: 8080 selector: app: pod-apollo-config-server type: NodePort sessionAffinity: ClientIP --- kind: StatefulSet apiVersion: apps/v1 metadata: namespace: apollo name: statefulset-apollo-config-server labels: app: statefulset-apollo-config-server spec: serviceName: service-apollo-meta-server replicas: 1 selector: matchLabels: app: pod-apollo-config-server updateStrategy: type: RollingUpdate template: metadata: labels: app: pod-apollo-config-server spec: volumes: - name: volume-configmap-apollo-config-server configMap: name: configmap-apollo-config-server items: - key: application-github.properties path: application-github.properties containers: - image: ip:9000/apollo/apollo-configservice:latest #私人倉庫 securityContext: privileged: true imagePullPolicy: IfNotPresent name: container-apollo-config-server ports: - protocol: TCP containerPort: 8080 volumeMounts: - name: volume-configmap-apollo-config-server mountPath: /apollo-config-server/config/application-github.properties subPath: application-github.properties env: - name: APOLLO_CONFIG_SERVICE_NAME value: "service-apollo-config-server.sre" readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 10 periodSeconds: 5 livenessProbe: tcpSocket: port: 8080 initialDelaySeconds: 120 periodSeconds: 10 dnsPolicy: ClusterFirst restartPolicy: Always nodeName: apollo #nodes節點名稱

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      96

      97

      98

      99

      100

      101

      102

      103

      104

      105

      3.apollo-portal

      --- kind: ConfigMap apiVersion: v1 metadata: namespace: apollo name: configmap-apollo-portal-server data: application-github.properties: | spring.datasource.url = jdbc:postgresql://ip:5432/apolloportal spring.datasource.username = apolloportal spring.datasource.password = 123 apollo-env.properties: | dev.meta=http://ip:8080 #上文的apollo-config 切記不用寫localhost --- kind: Service apiVersion: v1 metadata: namespace: apollo name: service-apollo-portal-server labels: app: service-apollo-portal-server spec: ports: - protocol: TCP port: 8070 targetPort: 8070 nodePort: 8070 selector: app: pod-apollo-portal-server type: NodePort sessionAffinity: ClientIP --- kind: Deployment apiVersion: apps/v1 metadata: namespace: apollo name: deployment-apollo-portal-server labels: app: deployment-apollo-portal-server spec: replicas: 1 selector: matchLabels: app: pod-apollo-portal-server strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: labels: app: pod-apollo-portal-server spec: volumes: - name: volume-configmap-apollo-portal-server configMap: name: configmap-apollo-portal-server items: - key: application-github.properties path: application-github.properties - key: apollo-env.properties path: apollo-env.properties containers: - image: ip:9000/apollo/apollo-portal:latest #私人倉庫 securityContext: privileged: true imagePullPolicy: IfNotPresent name: container-apollo-portal-server ports: - protocol: TCP containerPort: 8070 volumeMounts: - name: volume-configmap-apollo-portal-server mountPath: /apollo-portal-server/config/application-github.properties subPath: application-github.properties - name: volume-configmap-apollo-portal-server mountPath: /apollo-portal-server/config/apollo-env.properties subPath: apollo-env.properties env: - name: APOLLO_PORTAL_SERVICE_NAME value: "service-apollo-portal-server.sre" readinessProbe: tcpSocket: port: 8070 initialDelaySeconds: 10 periodSeconds: 5 livenessProbe: tcpSocket: port: 8070 initialDelaySeconds: 120 periodSeconds: 15 dnsPolicy: ClusterFirst restartPolicy: Always nodeName: apollo #nodes地址

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      58

      59

      60

      61

      62

      63

      64

      65

      66

      67

      68

      69

      70

      71

      72

      73

      74

      75

      76

      77

      78

      79

      80

      81

      82

      83

      84

      85

      86

      87

      88

      89

      90

      91

      92

      93

      94

      95

      注意:以上yaml 一定注意格式,比如空行,空格,注釋,能去掉一定去掉,否則會報各種錯誤。

      注意 ,以下apollo-portal.zip中的配置也需要修改(否則一直會訪問localhost)

      Docker 容器

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:【愚公系列】2022年01月 Java教學課程 77-注解的多種方式
      下一篇:測試用例(包含測經典試點全集圖解,強烈建議保存收藏)
      相關文章
      亚洲日韩AV无码一区二区三区人| 久久久久久亚洲Av无码精品专口| 亚洲av无码成h人动漫无遮挡| 亚洲熟妇成人精品一区| 久久亚洲sm情趣捆绑调教| 狠狠色伊人亚洲综合成人| 亚洲福利中文字幕在线网址| 精品久久久久久亚洲综合网| 亚洲成AV人影片在线观看| 亚洲老熟女五十路老熟女bbw | 亚洲精品成人片在线播放| 国产成人A亚洲精V品无码| 91麻豆国产自产在线观看亚洲 | 亚洲AV成人无码天堂| 亚洲国产成+人+综合| 亚洲中文久久精品无码1| 亚洲欧洲日产国码www| 亚洲国产成人久久| 亚洲香蕉在线观看| 久久亚洲精品国产精品婷婷| 亚洲欧美日韩久久精品| 久久亚洲中文无码咪咪爱| 最新亚洲人成网站在线观看| 亚洲精品WWW久久久久久| 亚洲乱码日产精品a级毛片久久| 亚洲午夜国产片在线观看| 亚洲最大激情中文字幕| 亚洲av无码一区二区三区网站 | 久久精品国产亚洲av四虎| 色婷婷亚洲十月十月色天| 亚洲第一精品电影网| 亚洲一区二区影视| 亚洲欧美精品午睡沙发| 亚洲av日韩片在线观看| 亚洲人成无码网站| 亚洲高清无在码在线电影不卡| 亚洲伊人久久大香线蕉影院| 亚洲日韩一区精品射精| 婷婷亚洲综合一区二区| 国产精品亚洲mnbav网站 | 亚洲偷偷自拍高清|