# Image Updater

该服务会更新 `pingcap-inc/sre` 仓库中的镜像名称.

## 配置

环境变量

```shell
export GITHUB_TOKEN=ghp_dadnj12.......

# APPS API TOKEN
export COMMUNITY_WEBSITE_PREVIEW_TOKEN=ok
.....
```

## 调用方式

```shell
curl -f -L -XPUT -H 'Content-Type: application/json' -H 'Authorization: token ok' -d '{"image":"registry.cn-hangzhou.aliyuncs.com/pingcap-ee/tidb-community-website-archived:v2"}' http://127.0.0.1:5050/api/apps/community-website-preview
```

> 注意: 在 CI 脚本中调用是应当注意 curl 命令是否执行成功, `curl -f` 会在请求失败的时候返回错误码 `22`.

调用成功后, `image-updater` 会在 `pingcap-inc/sre` 仓库中提交新的 commit 来更新镜像名称, 比如这个 [commit](https://github.com/pingcap-inc/sre/commit/734ab69f178749793e85c9cf6cc38a15d9aea1c6), 然后 flux 会根据新的配置去 K8s 中更新服务.

## TODO

- 使用 HTTPS + 域名的方式在内网暴露服务
