一、安装 Argo CD
- k8s版本是v1.19.1
使用以下命令在 argocd 命名空间部署 Argo CD。
# 创建命名空间
kubectl create namespace argocd
# 部署 argo cd
wget https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.9/manifests/ha/install.yaml
kubectl apply -n argocd -f install.yaml
# 或者 kubectl create -n argocd -f install.yaml
- 卸载argocd
kubectl delete -f install.yaml -n argocd
安装完成后,验证见下:
- 1、Pod
[admin@jenkins]$ kubectl -n argocd get pod
NAME READY STATUS RESTARTS AGE
argocd-application-controller-0 1/1 Running 0 26m
argocd-applicationset-controller-68b9bdbd8b-ld6cf 1/1 Running 0 26m
argocd-dex-server-6cff7fb675-l94r4 1/1 Running 0 26m
argocd-notifications-controller-6dbcbc6849-tr2jb 1/1 Running 0 26m
argocd-redis-599b855497-q5hft 1/1 Running 0 26m
argocd-repo-server-548b5f4c9b-hw2x4 1/1 Running 0 26m
argocd-server-754cbf9fd7-m2tkc 1/1 Running 0 26m
- 2、查看admin用户的密码
xjABvQ9kFSS3DerW
[admin@jenkins]$ kubectl -n argocd get secret \
argocd-initial-admin-secret \
-o jsonpath="{.data.password}" | base64 -d
xjABvQ9kFSS3DerW
二、发布 Argo CD 服务
默认情况下, Argo CD 服务不对外暴露服务,可以通过 LoadBalancer 或者 NodePort 类型的 Service、Ingress、Kubectl 端口转发等方式将 Argo CD 服务发布到 Kubernetes 集群外部。
这里使用以下命令通过 NodePort 服务的方式暴露 Argo CD 到集群外部。
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
因为我没有使用Ingress的方式暴露访问域名,是使用IP+PORT的方式暴露访问地址。
可以看到,argocd-server的类型已经是NodePort了,它生成了一个随机端口30984。所以argocd的访问地址是:https://192.168.80.180:30984/ (192.168.80.180是node节点的ip地址)
[admin@jenkins]$ kubectl get svc -n argocd
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
argocd-applicationset-controller ClusterIP 10.108.149.65 <none> 7000/TCP,8080/TCP 7d20h
argocd-dex-server ClusterIP 10.96.208.150 <none> 5556/TCP,5557/TCP,5558/TCP 7d20h
argocd-metrics ClusterIP 10.99.225.44 <none> 8082/TCP 7d20h
argocd-notifications-controller-metrics ClusterIP 10.97.136.140 <none> 9001/TCP 7d20h
argocd-redis ClusterIP 10.99.13.121 <none> 6379/TCP 7d20h
argocd-repo-server ClusterIP 10.97.72.137 <none> 8081/TCP,8084/TCP 7d20h
argocd-server NodePort 10.111.136.78 <none> 80:30984/TCP,443:30348/TCP 7d20h
argocd-server-metrics ClusterIP 10.106.102.243 <none> 8083/TCP 7d20h
三、对接LDAP
- 1、编写ldap-patch-dex.yaml
[admin@jenkins]$ vi ldap-patch-dex.yaml
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
dex.config: |-
connectors:
- type: ldap
name: ..................
id: ld