1、配置git环境
创建github仓库
- 登录github后,选择主页的Repositories,点击New创建一个仓库
配置仓库的访问权限(二选一,必须)
ssh-keygen -t ed25519 -C "你的邮箱" # 客户端生成ssh密钥
cat ~/.ssh/id_ed25519.pub # 复制公钥内容,粘贴到github的SSH密钥配置里
# 具体位置:登录github--点头像--Settings--SSH and GPG keys--New SSH key
- HTTPS 账号 / Token(简单,适合临时用)
- 不用配密钥,推送时会弹窗 / 终端提示输入账号和密码
配置身份信息,让git知道是谁在提交
git config --global user.email "94xxxxxxx@qq.com"
git config --global user.name "clx"
配置本地仓库环境
git init # 首次使用需要初始化本地仓库
git rev-parse --show-toplevel # 打印本地仓库的根路径
touch readme.md # 创建要提交到仓库的文件,测试用,名字任意
git add readme.md # 将文件提交到暂存区
git commit -m "first commit" # 提交到本地版本库,必须写提交信息
关联远程仓库
# 绑定远程仓库(默认命名为 origin,也可以自定义名字)
git remote add origin https://github.com/你的账号/仓库名.git
# 更换新的提交仓库
git remote set-url origin 新地址
推送文件到仓库
# 首次推送需要指定分支
git branch -M main # 切换到master分支
git push -u origin main # 或者提交时选择master分支
git push # 后续推送直接执行
2、安装Argo CD
安装argocd
kubectl create namespace argocd
kubectl apply -n argocd --server-side --force-conflicts -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
查看argocd的安装情况
![image]()
访问Web UI
- 修改svc/argocd-server为nodeport类型
![image]()
- 在浏览器通过192.168.40.11:30365访问web ui。默认用户名:admin。默认密码获得方式如下:
# 将secret中的密码以base64格式解密得到密码
kubectl get secret -n argocd argocd-initial-admin-secret -o yaml
echo Zm8xN0d0aG1SOXdtd04zbA== | base64 -d
![image]()
安装Argo CD CLI
wget https://github.com/argoproj/argo-cd/releases/download/v3.3.3/argocd-linux-amd64
chmod 555 argocd-linux-amd64
mv argocd-linux-amd64 /usr/local/bin/argocd
argocd version # 查看版本
argocd admin initial-password -n argocd
- 使用argo cli登录argocd,这里使用的是443暴露的端口
argocd login 192.168.40.11:32167
argocd account update-password
创建ArgoCD Application
自动部署helm chart至K8S
- ArgoCD作为K8s声明式GitOps工具,可以监控Git仓库中各类K8s配置文件/模板的变更,并自动同步到集群。不管是纯YAML、Kustomize配置,还是HelmChart
![image]()
![image]()
![image]()