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 小时前
【Kubernetes】从零搭建K8s集群:虚拟机环境配置全指南(DNS/网络/防火墙/SELinux全解析一站式配置图文教程)
linux·网络·kubernetes
xingsfdz11 小时前
Java微服务-新建demo
微服务·云原生·架构
白露与泡影11 小时前
阿里一面:微服务拆分需要考虑什么因素?
微服务·云原生·架构
大咖分享课11 小时前
微服务数据一致性技术解析:从单体到微服务的数据困局
微服务·云原生·架构·最佳实践·微服务数据一致性
2501_9111212311 小时前
Docker 高级管理笔记
云原生·eureka
2401_8532757312 小时前
什么是 OpenFeigin ?微服务中的具体使用方式
微服务·云原生·架构
heart000_114 小时前
如何用 eBPF 实现 Kubernetes 网络可观测性?实战指南
网络·云原生·容器·kubernetes
yuren_xia15 小时前
Eureka 和 Feign(二)
云原生·eureka
漫谈网络15 小时前
YAML 数据格式详解
python·yml·yaml·数据格式
蚊子不吸吸19 小时前
在Docker、KVM、K8S常见主要命令以及在Centos7.9中部署的关键步骤学习备存
linux·学习·docker·kubernetes·centos·k8s·kvm