Five minutes to take you to apollo (eight) use k8s deployment, vomiting blood test

The book is connected to the above, the host has customized the postgresql version of apollo, so how to use k8s deployment?

ps: This article only deploys the dev environment and uses yaml files to deploy in Kubernetes-dashboard

If you are not familiar with Kubernetes-dashboard, you can refer to the k8s column address ; https://blog.csdn.net/qq_20143059/category_11047349.html

Deploy apollo-admin

---apiVersion: v1kind: ConfigMapmetadata:  namespace: apollo   #更改自己的namespace  name: configmap-apollo-admin-serverdata:  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: v1kind: Servicemetadata:  namespace: apollo  name: service-apollo-admin-server  labels:    app: service-apollo-admin-serverspec:  ports:    - protocol: TCP      port: 8090      nodePort: 8090  selector:    app: pod-apollo-admin-server  type: NodePort---apiVersion: apps/v1kind: Deploymentmetadata:  namespace: apollo  name: deployment-apollo-admin-server  labels:    app: deployment-apollo-admin-serverspec:  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节点

Deploy apollo-config

---kind: ConfigMapapiVersion: v1metadata:  namespace: apollo  #更改自己的namespace  name: configmap-apollo-config-serverdata:  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: ServiceapiVersion: v1metadata:  namespace: apollo  name: service-apollo-meta-server  labels:    app: service-apollo-meta-serverspec:  ports:    - protocol: TCP      port: 8080      targetPort: 8080  selector:    app: pod-apollo-config-server  type: ClusterIP  clusterIP: None  sessionAffinity: ClientIP---kind: ServiceapiVersion: v1metadata:  namespace: apollo  name: service-apollo-config-server  labels:    app: service-apollo-config-serverspec:  ports:    - protocol: TCP      port: 8080      targetPort: 8080      nodePort: 8080  selector:    app: pod-apollo-config-server  type: NodePort  sessionAffinity: ClientIP---kind: StatefulSetapiVersion: apps/v1metadata:  namespace: apollo  name: statefulset-apollo-config-server  labels:    app: statefulset-apollo-config-serverspec:  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节点名称

apollo-portal

---kind: ConfigMapapiVersion: v1metadata:  namespace: apollo  name: configmap-apollo-portal-serverdata:  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: ServiceapiVersion: v1metadata:  namespace: apollo  name: service-apollo-portal-server  labels:    app: service-apollo-portal-serverspec:  ports:    - protocol: TCP      port: 8070      targetPort: 8070      nodePort: 8070  selector:    app: pod-apollo-portal-server  type: NodePort  sessionAffinity: ClientIP---kind: DeploymentapiVersion: apps/v1metadata:  namespace: apollo  name: deployment-apollo-portal-server  labels:    app: deployment-apollo-portal-serverspec:  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地址

Note: The above yaml must pay attention to the format, such as blank lines and spaces, comments can be removed and must be removed, otherwise various errors will be reported

Modify the jar package configuration

Note that the following configuration in apollo-portal.zip also needs to be modified (otherwise it will always access localhost)