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

推荐订阅源

博客园_首页
F
Full Disclosure
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
L
LangChain Blog
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
GbyAI
GbyAI
Y
Y Combinator Blog
博客园 - Franky
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Jina AI
Jina AI
N
Netflix TechBlog - Medium
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
腾讯CDC
H
Help Net Security
H
Heimdal Security Blog
J
Java Code Geeks
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
The Exploit Database - CXSecurity.com
The Register - Security
The Register - Security
大猫的无限游戏
大猫的无限游戏
T
Threatpost
B
Blog RSS Feed
T
Threat Research - Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
量子位
AWS News Blog
AWS News Blog
Project Zero
Project Zero
P
Proofpoint News Feed
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
S
Schneier on Security

mafeifan 的编程技术分享

mafengwo-mp3-downloader | mafeifan 的编程技术分享 示例页面 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 查看 default namespace 下的 default service account名称 mafeifan 的编程技术分享 检查日志 | mafeifan 的编程技术分享 bridge fdb show dev flannel.1 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 数据收集原理分析 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 几种方法 | mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 check the export on the very top of this document so we can use $do mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 mafeifan 的编程技术分享 延伸 -- 关于前端路由 xdebug 3 和 2 的区别
mafeifan 的编程技术分享
2026-01-16 · via mafeifan 的编程技术分享

springboot 的配置文件是 application.yml 里面会有连接数据库的配置信息,在仓库里明文显示是不行的

部署到k8s里要替换掉,url, username, password 等

yaml

server:
  port: 8040
spring:
  application:
    name: demo
  jackson:
    default-property-inclusion: non_null
    locale: zh
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  datasource:
    druid:
      url: jdbc:mysql://localhost:23306/demo?characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&allowMultiQueries=true
      username: root
      password: root

使用环境变量替换 ​

  1. 首先创建secret,包含键值对,值会自动经过base64处理
kind: Secret
apiVersion: v1
metadata:
  name: demo-secret
  namespace: demo
data:
  rds_conn_str: >-
    amRiYzpteXNFyYWN0ZXJFbmNvZGluZz1VVEYtOCZ1c2VTU0w9ZmFsc2UmdXNlSkRCQ0NvbXBsaWFudFRpbWV6b25lU2hpZnQ9dHJ1ZSZhbGxvd011bHRpUXVlcmllcz10cnVl
  rds_password: aDg2YkNBOUZQOA==
  rds_username: a2Zwcy1ydw==
type: Opaque
  1. 修改 deployment

env 部分是从secret中读取键,对应的值存到环境变量中,这时候登录容器,就是可以查看到环境变量RDS_CONN_STR,RDS_USERNAME和RDS_PASSWORD

然后在args中,使用$(RDS_CONN_STR),$(RDS_USERNAME),$(RDS_PASSWORD)覆盖掉application.yml中的值

    spec:
      containers:
        - name: demo
          image: >-
            demo-image:latest
          command:
            - java
            - '-jar'
          args:
            - '-Dfile.encoding=UTF-8'
            - '-Dspring.profiles.active=pt'
            - '-Dspring.datasource.url=$(RDS_CONN_STR)'
            - '-Dspring.datasource.username=$(RDS_USERNAME)'
            - '-Dspring.datasource.password=$(RDS_PASSWORD)'
            - /opt/app/app.jar
          env:
            - name: RDS_CONN_STR
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_conn_str
            - name: RDS_USERNAME
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_username
            - name: RDS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_password

更进一步

    spec:
      containers:
        - name: demo
          image: >-
            demo-image:latest
          command:
            - java
            - '-jar'
          args:
            - '-Dfile.encoding=UTF-8'
            - '-Dspring.profiles.active=pt'
            - /opt/app/app.jar
          env:
            - name: SPRING.DATASOURCE.URL
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_conn_str
            - name: SPRING.DATASOURCE.USERNAME
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_username
            - name: SPRING.DATASOURCE.PASSWORD
              valueFrom:
                secretKeyRef:
                  name: demo-secret
                  key: rds_password

使用新的配置文件替换,配置文件存到secret中 ​

  1. 把整个application.yml 存到secret中

  2. deployment 添加环境变量

yaml

  spec:
    containers:
      - name: your-app
        image: your-image:tag
        command:
          - java
          - '-jar'
        args:
          - '-Dfile.encoding=UTF-8'
          - '-Dspring.config_location=$(SPRING_CONFIG_LOCATION)'
        ports:
          - containerPort: 8080
        env:
          - name: SPRING_CONFIG_LOCATION
            value: "file:/path/to/application.yaml"
        volumeMounts:
            - name: config-volume
              mountPath: /path/to/application.yaml
    volumes:
      - name: config-volume
        secret:
          secretName: demo-secret