五分钟带你玩转apollo(八)使用k8s部署,吐血亲验

本文涉及的产品
云原生数据库 PolarDB MySQL 版,通用型 2核8GB 50GB
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
简介: 五分钟带你玩转apollo(八)使用k8s部署,吐血亲验


书接上文 楼主定制了postgresql版本的apollo 那么怎么使用k8s部署呢

ps :本文只部署dev环境 使用yaml文件在Kubernetes-dashboard部署

如果有对Kubernetes-dashboard不熟悉的 可以参考k8s专栏 地址;https://blog.csdn.net/qq_20143059/category_11047349.html

部署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节点

部署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节点名称

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地址

注意:以上yaml 一定注意格式 比如空行 空格 注释 能去掉一定去掉 否则会报各种错误

修改jar包配置

注意 以下apollo-portal.zip中的配置也需要修改(否则一直会访问localhost)

image.png

image.png


相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
5天前
|
人工智能 Kubernetes 异构计算
大道至简-基于ACK的Deepseek满血版分布式推理部署实战
本教程演示如何在ACK中多机分布式部署DeepSeek R1满血版。
|
5天前
|
存储 Kubernetes 对象存储
部署DeepSeek但GPU不足,ACK One注册集群助力解决IDC GPU资源不足
借助阿里云ACK One注册集群,充分利用阿里云强大ACS GPU算力,实现DeepSeek推理模型高效部署。
|
10天前
|
存储 Kubernetes 测试技术
企业级LLM推理部署新范式:基于ACK的DeepSeek蒸馏模型生产环境落地指南
本教程演示如何在ACK中使用vLLM框架快速部署DeepSeek R1模型推理服务。
|
11天前
|
存储 人工智能 弹性计算
NVIDIA NIM on ACK:优化生成式AI模型的部署与管理
本文结合NVIDIA NIM和阿里云容器服务,提出了基于ACK的完整服务化管理方案,用于优化生成式AI模型的部署和管理。
|
2月前
|
存储 Kubernetes 容器
K8S部署nexus
该配置文件定义了Nexus 3的Kubernetes部署,包括PersistentVolumeClaim、Deployment和服务。PVC请求20Gi存储,使用NFS存储类。Deployment配置了一个Nexus 3容器,内存限制为6G,CPU为1000m,并挂载数据卷。Service类型为NodePort,通过30520端口对外提供服务。所有资源位于`nexus`命名空间中。
|
3月前
|
Kubernetes Cloud Native 微服务
云原生入门与实践:Kubernetes的简易部署
云原生技术正改变着现代应用的开发和部署方式。本文将引导你了解云原生的基础概念,并重点介绍如何使用Kubernetes进行容器编排。我们将通过一个简易的示例来展示如何快速启动一个Kubernetes集群,并在其上运行一个简单的应用。无论你是云原生新手还是希望扩展现有知识,本文都将为你提供实用的信息和启发性的见解。
|
3月前
|
存储 Kubernetes Devops
Kubernetes集群管理和服务部署实战
Kubernetes集群管理和服务部署实战
102 0
|
4月前
|
NoSQL 关系型数据库 Redis
高可用和性能:基于ACK部署Dify的最佳实践
本文介绍了基于阿里云容器服务ACK,部署高可用、可伸缩且具备高SLA的生产可用的Dify服务的详细解决方案。
|
4月前
|
Prometheus Kubernetes 监控
k8s部署针对外部服务器的prometheus服务
通过上述步骤,您不仅成功地在Kubernetes集群内部署了Prometheus,还实现了对集群外服务器的有效监控。理解并实施网络配置是关键,确保监控数据的准确无误传输。随着监控需求的增长,您还可以进一步探索Prometheus生态中的其他组件,如Alertmanager、Grafana等,以构建完整的监控与报警体系。
180 60
|
4月前
|
Prometheus Kubernetes 监控
k8s部署针对外部服务器的prometheus服务
通过上述步骤,您不仅成功地在Kubernetes集群内部署了Prometheus,还实现了对集群外服务器的有效监控。理解并实施网络配置是关键,确保监控数据的准确无误传输。随着监控需求的增长,您还可以进一步探索Prometheus生态中的其他组件,如Alertmanager、Grafana等,以构建完整的监控与报警体系。
309 62

热门文章

最新文章