本篇目录链接
Argo CD 服务端安装
安装参考:https://argoproj.github.io/argo-cd/getting_started
官方demo:https://cd.apps.argoproj.io/applications
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
查看部署的资源
kubectl -n argocd get pods
Argo的访问方式-LoadBalancer
修改serivce类型为nodeport,以访问Argo CD API Server
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
#LoadBalancer、NodePort均可以实现
查看service
kubectl -n argocd get svc
Argo的访问方式-基于ingress部署
cat argocd-ingress-http.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server-ingress
namespace: argocd
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
# If you encounter a redirect loop or are getting a 307 response code
# then you need to force the nginx ingress to connect to the backend using HTTPS.
#
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- host: argocd.kktd.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
name: https
tls:
- hosts:
- argocd.kktd.com
secretName: argocd-secret # do not change, this is provided by Argo CD
Argo CD 客户端安装
要与API Server进行交互,我们需要部署CLI:
linux命令行
wget https://github.com/argoproj/argo-cd/releases/download/v2.1.2/argocd-linux-amd64
cp argocd-linux-amd64 /usr/local/bin/argocd
chmod +x /usr/local/bin/argocd
MAC版
brew install argocd
查看argocdCLI版本
argocd version
获取pod名称
```bash
podName=`kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2`
将服务注册到k8s集群
argocd login argocd.kktd.com --username admin --password $podName
修改默认密码
argocd account update-password \
--current-password ******** \
--new-password Argocd@123
浏览器访问argocd
https://argocd.kktd.com
helm部署argocd
参考:
https://artifacthub.io/packages/helm/argo/argo-cd
https://github.com/argoproj/argo-helm/tree/master/charts/argo-cd
添加helm仓库
helm repo add argo https://argoproj.github.io/argo-helm
部署argocd
helm install argocd \
--namespace=argocd --create-namespace \
--set global.image.repository="argoproj/argocd" \
--set dex.image.repository="dexidp/dex" \
--set server.service.type=NodePort \
--set server.service.nodePortHttp=30085 \
argo/argo-cd
获取admin用户密码
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
多集群管理
多集群管理是通过argo对连接不同的k8s集群,然后实现对各个集群上服务的管理。
获取到目标集群的config配置信息
根据config配置信息,获取到目标集群的上下文信息
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* 214593738340050306-c74b6dca73229419a818c93f841132449 kubernetes 214593738340050306 #关键信息:NAME和CLUSTER
客户端添加集群
argocd cluster add 214593738340050306-c74b6dca73229419a818c93f841132449 --kubeconfig ~/.kube/config --name test-env
界面查看
首次查看,会显示不成功,但是不影响界面部署