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    
相关推荐
沉迷学习 日益消瘦9 小时前
10-Gateway API
运维·kubernetes·gateway
减瓦10 小时前
深入 Quarkus:云原生时代 Java 的重生之路
java·开发语言·云原生
写代码的强哥11 小时前
TiDB 和 OceanBase 对比:架构师视角下的企业选型实战指南
数据库·云原生·架构
张忠琳12 小时前
【NVIDIA】NVIDIA k8s-device-plugin v0.19.3 配置API模块深度分析之二
云原生·容器·架构·kubernetes·nvidia
在水一缸13 小时前
深入浅出:Node.js 下一代 ORM 架构设计与实战解析
数据库·微服务·云原生·node.js·orm·架构设计
IT二叔14 小时前
Kubernetes(K8s)-02-Minikube安装
云原生·容器·kubernetes
观远数据15 小时前
云原生BI的战略价值:不是技术选择,而是业务弹性的决定因素
java·人工智能·云原生
瀛川15 小时前
microVM 技术解析:面向多租户 Serverless 与 AI Agent 的微虚拟机架构
后端·云原生
爱莉希雅&&&16 小时前
Rocky Linux 10.1 + K8s 1.36.3 离线集群部署笔记(Kubernetes)
linux·笔记·docker·kubernetes·calico