16.使用豆包将docker-compose的yaml转为k8s的yaml,安装各种无状态服务

文章目录

docker方式

httpbin

A simple HTTP Request & Response Service
https://httpbin.org/
https://github.com/postmanlabs/httpbin
https://github.com/mccutchen/go-httpbin

bash 复制代码
docker rm -f httpbin;
docker run --name httpbin \
--network macvlan -dp 80:80 \
--restart=always \
kennethreitz/httpbin

it-tools

Handy tools for developers
https://it-tools.tech/
https://github.com/CorentinTh/it-tools

bash 复制代码
docker run --name it-tools \
--network macvlan -p 80:80 \ 
--restart unless-stopped \
corentinth/it-tools

linux-command

Linux命令搜索
https://wangchujiang.com/linux-command/
https://github.com/jaywcjlove/linux-command

bash 复制代码
docker rm -f linux-command;
docker run --name linux-command \
--network macvlan -dp 3000:3000 \
--restart=always \
wcjiang/linux-command

myip

IP 信息
https://ipcheck.ing/
https://github.com/jason5ng32/MyIP

bash 复制代码
docker rm -f myip;
docker run --name myip \
--network macvlan -dp 18966:18966 \
--restart=always \
jason5ng32/myip

reference

Share quick reference cheat sheet for developers
https://wangchujiang.com/reference/
https://github.com/jaywcjlove/reference
https://hub.docker.com/r/wcjiang/reference

bash 复制代码
docker rm -f reference;
docker run --name reference \
--network macvlan -dp 3000:3000 \
--restart=always \
wcjiang/reference

docker-compose安装

bash 复制代码
docker-compose up -d
yaml 复制代码
name: stateless
services:
    httpbin:
        container_name: httpbin
        ports:
            - 80
        restart: always
        image: kennethreitz/httpbin
    it-tools:
        container_name: it-tools
        ports:
            - 80
        restart: unless-stopped
        image: corentinth/it-tools
    linux-command:
        container_name: linux-command
        ports:
            - 3000
        restart: always
        image: wcjiang/linux-command
    myip:
        container_name: myip
        ports:
            - 18966
        restart: always
        image: jason5ng32/myip
    reference:
        container_name: reference
        ports:
            - 3000
        restart: always
        image: wcjiang/reference

k8s方式

用豆包生成k8s的yaml:

复制代码
将上面的docker-compose转为k8s yaml格式,并配置对应traefik。
放到一个文件中吧,把example.com改为k8s.home.love。
bash 复制代码
kubectl apply -f all.yaml -n stateless
yaml 复制代码
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpbin-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpbin
  template:
    metadata:
      labels:
        app: httpbin
    spec:
      containers:
        - name: httpbin
          image: kennethreitz/httpbin
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: httpbin-service
spec:
  selector:
    app: httpbin
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: httpbin-ingressroute
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`httpbin.k8s.home.love`)
      kind: Rule
      services:
        - name: httpbin-service
          port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: it-tools-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: it-tools
  template:
    metadata:
      labels:
        app: it-tools
    spec:
      containers:
        - name: it-tools
          image: corentinth/it-tools
          ports:
            - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: it-tools-service
spec:
  selector:
    app: it-tools
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: it-tools-ingressroute
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`it-tools.k8s.home.love`)
      kind: Rule
      services:
        - name: it-tools-service
          port: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: linux-command-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: linux-command
  template:
    metadata:
      labels:
        app: linux-command
    spec:
      containers:
        - name: linux-command
          image: wcjiang/linux-command
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: linux-command-service
spec:
  selector:
    app: linux-command
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: linux-command-ingressroute
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`linux-command.k8s.home.love`)
      kind: Rule
      services:
        - name: linux-command-service
          port: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myip-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myip
  template:
    metadata:
      labels:
        app: myip
    spec:
      containers:
        - name: myip
          image: jason5ng32/myip
          ports:
            - containerPort: 18966
---
apiVersion: v1
kind: Service
metadata:
  name: myip-service
spec:
  selector:
    app: myip
  ports:
    - protocol: TCP
      port: 18966
      targetPort: 18966
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: myip-ingressroute
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`myip.k8s.home.love`)
      kind: Rule
      services:
        - name: myip-service
          port: 18966
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reference-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: reference
  template:
    metadata:
      labels:
        app: reference
    spec:
      containers:
        - name: reference
          image: wcjiang/reference
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: reference-service
spec:
  selector:
    app: reference
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: reference-ingressroute
spec:
  entryPoints:
    - web
  routes:
    - match: Host(`reference.k8s.home.love`)
      kind: Rule
      services:
        - name: reference-service
          port: 3000    
相关推荐
分布式存储与RustFS19 小时前
RustFS 该跟 stable 还是 nightly?两条版本线的分工、风险与回退,一张表说清
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
ggaofeng21 小时前
k8s中的dns
云原生·容器·kubernetes
我不会起名字3221 天前
K8s Ingress 返回 502 但后端日志正常:4 类上游断连与排查链
kubernetes·k8s·ingress·502·keepalive
XLYcmy1 天前
《数字经济赋能城市低碳治理的路径研究检索报告》审阅与修改指导意见——基于完整检索报告体例的完整性诊断、学术规范核查与方法论纠偏 上
数据库·ai·chatgpt·文心一言·检索·知网·豆包
我不会起名字3222 天前
Pod 一直 Pending:调度器 5 类失败原因与 kubectl describe 的正确读法
云原生·kubernetes·调度·排查
我不会起名字3222 天前
K8s 服务 DNS 解析偶发 5 秒超时:conntrack 与 ndots 的 3 个坑
kubernetes·k8s·dns·conntrack·coredns
risc1234562 天前
万变不离其宗
人工智能·低代码·云原生
T.O.P_KING2 天前
Falco vs. Tetragon:云原生运行时安全选型指南
安全·云原生
七夜zippoe2 天前
把 OpenClaw Agent 搬进 K8s:容器化部署全记录
ai·云原生·容器·kubernetes·openclaw