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

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

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

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

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

docker rm -f reference;
docker run --name reference \
--network macvlan -dp 3000:3000 \
--restart=always \
wcjiang/reference

docker-compose安装

docker-compose up -d
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。
kubectl apply -f all.yaml -n stateless
---
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    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值