惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
A
About on SuperTechFans
博客园_首页
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
NISL@THU
NISL@THU
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
V
V2EX
D
DataBreaches.Net
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 聂微东
Vercel News
Vercel News
博客园 - 叶小钗
F
Full Disclosure
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享
博客园 - Franky
WordPress大学
WordPress大学
小众软件
小众软件
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
Jina AI
Jina AI
月光博客
月光博客
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
美团技术团队
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
Recent Announcements
Recent Announcements

ike‘s blog

mac软件推荐 用Siri来控制Windows电脑开机关机吧 clickhouse的一些优化建议和工具 2023sumppary 记录一下我的第一个网页游戏Mazeball 如何使用Clickhouse的索引 如何从zookeeper切换为clickhouse—keeper cloki分布式查询和clickhouse副本存储 使用ilogtail+cloki+clickhouse来做日志系统吧 clickhouse集群部署指南 快速安装部署clickhouse和cloki 快速部署thanos架构 如何使用go的jwt 如何修改git commit记录 游戏企划 Prometheus Metrics精简优化2 来在线听音乐吧 Chatgpt的API入门 简单搭建国内也可以使用的chatgpt Prometheus Metrics精简优化 Kubernetes的探针机制 本地部署chatAI【chatglm】 AI绘画工具webui简单入门 之 高清化 写在地下城邂逅Ⅳ·灾厄篇·完结之后 如何部署gitalk作为评论系统 AI绘画工具webui简单入门 之 工具安装 grafanadb迁移到mysql kubectl常用命令 开始写博客啦 隐私政策URL Markdown Example Include Video in the Posts Markdown Extended Features Simple Guides for Fuwari Golang net/http & HTTP Serve 源码分析
业务容器化需要注意的一些地方
ike · 2023-06-01 · via ike‘s blog

废话不多说,直接上yaml文件。#

apiVersion: apps/v1
kind: Deployment
metadata:
  name: java-web
  namespace: ops
  labels:
    app: java-web
spec:
  selector:
    matchLabels:
      app: java-web
  replicas: 2
  strategy:
    type: RollingUpdate
  template:
    metadata:
      name: java-web
      annotations:   # 第一点:新增注解
        loki.io/scrape: 'true' # 抓取直接输出的日志到loki里
        prometheus.io/path: /metrics #采集的监控地址
        prometheus.io/port: '2112'  #采集暴露的监控端口
        prometheus.io/scrape: 'true'  #打开采集开关
      labels:
        app: java-web
    spec:
      imagePullSecrets:  # 第二点:添加权限
        - name: my-docker #只有该用户才有pull镜像的权限
      containers:
        - name: java-web
          image: hb.ops.top/ops/java-web:5917f92c
          imagePullPolicy: IfNotPresent
          readinessProbe:  # 第三点:新增存活检测,当前是针对监控端口进行存活检测,也就是说只有当监控端口起来了,程序才算完全启动
            httpGet:
              port: 2112
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          startupProbe:
            httpGet:
              port: 2112
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          livenessProbe:
            httpGet:
              port: 2112
              path: /metrics/prometheus
            initialDelaySeconds: 60
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          resources: # 第四点:设置资源限制,如果是java程序,建议limit比request大,这样可以合理分配堆内存和非堆内存
            requests:
              memory: 1024Mi
            limits:
              memory: 2048Mi
          ports:
            - name: web-port
              containerPort: 8889
          env: # 第五点:设置环境变量,可以设置时区,指定EVN环境,添加JAVA参数等
            - name: JVM_OPTS
              value: -javaagent:/opt/skywalking/skywalking-agent.jar -Xmx1G -Xms1G
            - name: TZ
              value: Asia/Shanghai
            - name: APOLLO_LABEL
              value: gray
            - name: SW_AGENT_NAME
              value: 'k8s-java-web'
            - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
              value: '10.0.0.123:11800'
            - name: ENV
              value: prod

---

apiVersion: v1
kind: Service
metadata:
  labels:
    app: java-web
  name: java-web
  namespace: ops
spec:
  ports:
  - name: java-web-port
    port: 8889
    protocol: TCP
    targetPort: 8889
    nodePort: 30009
  selector:
    app: java-web
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}