argo部署
argo部署
argo项目中,4个子项目可以单独部署,这里部署argocd、argo rollout
argocd部署
github:https://github.com/argoproj/argo-cd
官网文档:https://argo-cd.readthedocs.io/en/stable/getting_started/
部署方式
多租户部署
用于多开发团队、平台维护团队的场景使用
- 支持高可用和非高可用方式部署
- 支持web和cli方式访问
方式
- install.yaml:集群级别部署,需要有集群管理员权限(管理集群应用)
- namespace-install.yaml:仅需要命名空间级别的权限就可安装(仅ns使用)
核心化部署
简易安装,不包含api-server和ui,且不提供高可用
仅用于独立使用argocd且不需要多租户特性的场景,不用管理权限
需要通过命令行管理argocd
部署
1)部署argocd
mkdir argocd
cd !$
export https_proxy=http://frp1.freefrp.net:16324
version=v2.8.4
url_list=(
https://raw.githubusercontent.com/argoproj/argo-cd/${version}/manifests/install.yaml
https://raw.githubusercontent.com/argoproj/argo-cd/${version}/manifests/ha/install.yaml
https://github.com/argoproj/argo-cd/releases/download/${version}/argocd-linux-amd64
)
for url in ${url_list[*]} ;do
for i in {1..3} ;do
wget -q --show-progress $url && break ||echo "下载失败,正在重试$i: $url";
done
done
unset https_proxy
mv install.yaml.1 install-ha.yaml
##### 部署argocd,方式二选一
kubectl create namespace argocd
#非高可用部署,测试使用
kubectl apply -n argocd -f install.yaml
#高可用部署,生产使用
kubectl apply -n argocd -f install-ha.yaml
##### 配置cli客户端
install -m 755 argocd-linux-amd64 /usr/local/bin/argocd
argocd completion bash > /etc/bash_completion.d/argocd
source <(argocd completion bash)
2)允许外部访问
默认argocd的api-server是clusterIP,外部访问需要暴露一下
svc直接暴露
ip link a vip0 type dummy
ip a a 2.2.2..68/32 dev vip0
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer","externalIPs":["2.2.2.68"]}}'
ingress暴露
kubectl apply -f - <<eof
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: argocd-dashboard-gateway
namespace: istio-system
spec:
selector:
app: istio-ingressgateway
servers:
- hosts:
- "argocd.hj.com"
port:
number: 80
name: http
protocol: HTTP
tls:
httpsRedirect: true
- hosts:
- "argocd.hj.com"
port:
number: 443
name: https
protocol: HTTPS
tls:
mode: PASSTHROUGH
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: argocd-dashboard-vs
namespace: argocd
spec:
hosts:
- "argocd.hj.com"
gateways:
- istio-system/argocd-dashboard-gateway
tls:
- match:
- port: 443
sniHosts:
- argocd.hj.com
route:
- destination:
host: argocd-server
port:
number: 443
eof
3)配置webUI登录密码
echo '2.2.2.66 argocd.hj.com' >> /etc/hosts
curl -Ik https://argocd.hj.com
#获取登录密码与ip
argocd_ip=`kubectl get svc -n argocd argocd-server |awk 'NR==2{print $3}'`
argocd_pw=`argocd admin initial-password -n argocd |head -n1`
#命令行登录,改密码
argocd login $argocd_ip --insecure --username admin --password $argocd_pw
argocd account update-password --insecure --current-password $argocd_pw --new-password Qaz123456
argocd的图形化好像有点bug,不知道是我运行环境有问题还是图形化的问题,未详细证实,部署最新版本后,浏览器访问,跳转有点小问题,报某些资源404
argo rollout部署
github:https://github.com/argoproj/argo-rollouts/
文档:https://argoproj.github.io/argo-rollouts/installation/
文件说明
- dashboard-install.yaml:图形化单独运行,svc监听3100/tcp端口
- install.yaml:集群级全部资源运行,内置图形化
- namespace-install.yaml:ns级全部资源运行
- kubectl-argo-rollouts-linux-amd64:cli客户端
- notifications-install.yaml:通知器,可单独部署
部署
1)下载所有文件
mkdir argo-rollout
cd !$
export https_proxy=http://frp1.freefrp.net:16324
version=v1.6.4
url_list=(
https://github.com/argoproj/argo-rollouts/releases/download/${version}/install.yaml
https://github.com/argoproj/argo-rollouts/releases/download/${version}/dashboard-install.yaml
https://github.com/argoproj/argo-rollouts/releases/download/${version}/kubectl-argo-rollouts-linux-amd64
)
for url in ${url_list[*]} ;do
for i in {1..3} ;do
wget -q --show-progress $url && break ||echo "下载失败,正在重试$i: $url";
done
done
unset https_proxy
2)部署argo-rollout
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f install.yaml
kubectl apply -n argo-rollouts -f dashboard-install.yaml
3)安装cli
install -m 755 kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
kubectl-argo-rollouts completion bash > /etc/bash_completion.d/kubectl-argo-rollouts
source <(kubectl-argo-rollouts completion bash)
4)暴露dashboard图形界面
使用istio的ingress
kubectl apply -f - <<eof
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: argo-rollouts-dashboard-gateway
namespace: istio-system
spec:
selector:
app: istio-ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "argo-rollouts.hj.com"
- "rollouts.hj.com"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: argo-rollouts-dashboard-virtualservice
namespace: argo-rollouts
spec:
hosts:
- "argo-rollouts.hj.com"
- "rollouts.hj.com"
gateways:
- istio-system/argo-rollouts-dashboard-gateway
http:
- match:
- uri:
prefix: /
route:
- destination:
host: argo-rollouts-dashboard
port:
number: 3100
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: argo-rollouts-dashboard
namespace: argo-rollouts
spec:
host: argo-rollouts-dashboard
trafficPolicy:
tls:
mode: DISABLE
eof