前置条件:

装置了K3S或者K8S。

装置步骤:

下载 fluxcd 的装置脚本并执行

curl -s https://fluxcd.io/install.sh | sudo bash
  1. 批改.bashrc文件,配置环境变量
export GITHUB_TOKEN="{{your token}}"export GITHUB_USER="{{your name}}"export KUBECONFIG=/etc/rancher/k3s/k3s.yaml  # 如果是k8s,这里须要批改为本人的门路
  1. 检测装置状态
flux check --preflux install --registry="ccr.ccs.tencentyun.com/fluxcd"   # 能够不指定镜像mirror,然而拉取镜像会很慢甚至拉不下来,倡议迷信上网本地拉取,而后推送到本人的镜像仓库中,而后这里指定mirror。这里指定的是我在腾讯上公开的镜像仓库,只有个别版本。
  1. 设置Github仓库

// 这里可能须要提前本人在github上创立一个空白仓库

flux bootstrap github   --owner={{your name}}   --repository=fluxcd   --path=clusters/k3s-cluster --personalgit clone git@github.com:{{your name}}/fluxcd.gitcd fluxcdflux create source git podinfo   --url=https://github.com/stefanprodan/podinfo   --branch=master   --interval=30s   --export > ./clusters/k3s-cluster/podinfo-source.yamlgit add -A && git commit -m "Add podinfo GitRepository"git push
  1. 执行fluxcd创立命令

    flux create kustomization podinfo \  --target-namespace=default \  --source=podinfo \  --path="./kustomize" \  --prune=true \  --interval=5m \  --export > ./clusters/k3s-cluster/podinfo-kustomization.yaml
  2. 查看部署状况

能够在dashboard中查看各个pod的状况。

常见问题

镜像拉取失败,这个不好解决,个别能够本地拉取,而后推送到云上,而后flux install --registry="xxxx"