首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2022-07-25:xiu是用rust语言编写的流媒体服务器软件项目。k8s安装xiu,drone文件如何写?

2022-07-25:xiu是用rust语言编写的流媒体服务器软件项目。k8s安装xiu,drone文件如何写?

作者头像
福大大架构师每日一题
发布2022-11-06 09:57:39
4320
发布2022-11-06 09:57:39
举报

2022-07-25:xiu是用rust语言编写的流媒体服务器软件项目。k8s安装xiu,drone文件如何写?

答案2022-07-25:

云原生环境不可能完全一样,只能做参考。

我采用的是drone,重点是rust编译环境。

drone文件内容如下:

kind: pipeline
type: docker
name: dev

#取消git clone代码
clone:
  disable: true

steps:
  - name: clone
    image: drone/git
    pull: if-not-exists
    volumes:
      - name: cache
        path: /etc/hosts
    commands:
      - git clone http://git.dsy.com/dsygroup/compile-xiu.git .
      - git clone https://gitee.com/moonfdd/xiu.git
      #- git checkout $DRONE_COMMIT

  - name: build
    image: rust:latest
    pull: if-not-exists
    environment:
      RUSTUP_DIST_SERVER: https://mirrors.ustc.edu.cn/rust-static
      RUSTUP_UPDATE_ROOT: https://mirrors.ustc.edu.cn/rust-static/rustup
    volumes:
      - name: cache
        path: /etc/hosts
    commands:
      - sed -i "s/【DRONE_COMMIT:0:8】/${DRONE_COMMIT:0:8}/g" .helm/dev/values.yaml
      - cp config /usr/local/cargo/config
      - cd xiu/application/xiu
      - echo $RUSTUP_DIST_SERVER
      - echo $RUSTUP_UPDATE_ROOT
      - echo $CARGO_HOME
      - rustup target add x86_64-unknown-linux-musl
      - cargo build --release --target=x86_64-unknown-linux-musl
      - cd ../..
      - ldd target/x86_64-unknown-linux-musl/release/xiu
      - strip -s target/x86_64-unknown-linux-musl/release/xiu

  - name: image
    image: plugins/docker
    pull: if-not-exists
    volumes:
      - name: cache
        path: /etc/hosts
      - name: d
        path: /var/run/docker.sock
    commands:
      - docker version
      - docker build -f ./MyDockerfile -t dockergit.dsy.com/dsygroup/compile-xiu:${DRONE_COMMIT:0:8} ./xiu
      - docker push dockergit.dsy.com/dsygroup/compile-xiu:${DRONE_COMMIT:0:8}

  - name: deploy
    image: "pelotech/drone-helm3"
    pull: if-not-exists
    volumes:
      - name: cache
        path: /etc/hosts
      - name: d
        path: /var/run/docker.sock
    settings:
      mode: upgrade
      chart: ./.helm/dev
      vaules_yaml: ./.helm/dev/values.yaml
      release: xiu
      namespace: maoaoandemoname
      kube_api_server: "https://git.dsy.com:6443"
      kube_token:
        from_secret: kube_token
      skip_tls_verify: true
      values:
        - image.tag=${DRONE_COMMIT:0:8}

trigger:
  branch:
    - master
    - aaa

volumes:
  - name: cache
    host:
      path: /etc/hosts
  - name: d
    host:
      path: /var/run/docker.sock

dockerfile文件内容如下:

FROM scratch
COPY application/xiu/src/config/config_rtmp.toml /conf/config_rtmp.toml
COPY target/x86_64-unknown-linux-musl/release/xiu /bin/xiu

config文件是设置cargo的国内镜像源,内容如下:

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

helm的内容就不贴在这里了,具体见 [码云地址](https://gitee.com/moonfdd/compile-xiu.git)

k8s里暴露的端口如下:

推送视频到k8s里,命令如下:

ffmpeg -i 俄罗斯.mp4 -rtsp_transport tcp -vcodec h264 -acodec aac -f flv rtmp://172.16.11.111:42308/live/test1

运行结果如下:

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-07-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 福大大架构师每日一题 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档