fluxcd2安装

fluxcd2安装_第1张图片

前置条件:

安装了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 --pre
flux install --registry="ccr.ccs.tencentyun.com/fluxcd"   # 可以不指定镜像mirror,但是拉取镜像会很慢甚至拉不下来,建议科学上网本地拉取,然后推送到自己的镜像仓库中,然后这里指定mirror。这里指定的是我在腾讯上公开的镜像仓库,只有个别版本。
  1. 设置Github仓库

// 这里可能需要提前自己在github上创建一个空白仓库

flux bootstrap github   --owner={{your name}}   --repository=fluxcd   --path=clusters/k3s-cluster --personal
git clone [email protected]:{{your name}}/fluxcd.git
cd fluxcd
flux create source git podinfo   --url=https://github.com/stefanprodan/podinfo   --branch=master   --interval=30s   --export > ./clusters/k3s-cluster/podinfo-source.yaml
git 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"

你可能感兴趣的:(devops)