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    
相关推荐
如夏倾城2 小时前
入侵检测系统(IDS)原理、部署模式与 IPS/防火墙对比
大数据·网络·人工智能·网络安全·云原生·架构·kubernetes
Z21-X2 小时前
云原生运维学习笔记:Kubernetes Volume 与 Secret 实验
运维·笔记·学习·云原生·kubernetes
分布式存储与RustFS4 小时前
桶里的文件想当目录使:用 ZeroFS 把 RustFS 挂成一棵 POSIX 树
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
分布式存储与RustFS6 小时前
向量表别堆本地盘:用 LanceDB 把数据集建在 RustFS 上
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
mengge.cloud9 小时前
Python基础保姆级!从入门到入土
开发语言·python·云原生·pygame
阿里云云原生1 天前
阿里云 AI 网关 x 联想百应:构建 Token Plan 平台&词元宝 Token Key 产品,让模型服务走向规模化运营
云原生
阿里云云原生1 天前
基于阿里云 AgentLoop 构建 Agent 进化数据飞轮闭环,让线上 Trace 沉淀为可复用经验
云原生
分布式存储与RustFS1 天前
Zeppelin 笔记本重启就丢:三个环境变量把 .zpln 存进 RustFS 桶
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
阿里云云原生1 天前
AgentScope Durable:让企业 Agent 持续、可靠地运行
云原生
Eyfcom1 天前
〖物流云原生实战 05〗Service Mesh 在快递系统微服务治理中的应用:从“代码侵入”到“基础设施下沉”
微服务·云原生·service_mesh·快递系统·物流云原生实战